diff options
author | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 22:35:18 +0000 |
---|---|---|
committer | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 22:35:18 +0000 |
commit | 708167077798a6ced31af8d7b2390b3ce5fc5eac (patch) | |
tree | d747f3d1b01d119c0bf9e2302984be5c7a670890 /media | |
parent | ec3cbea1d64c344f4686725daba1ef34b630e439 (diff) | |
download | chromium_src-708167077798a6ced31af8d7b2390b3ce5fc5eac.zip chromium_src-708167077798a6ced31af8d7b2390b3ce5fc5eac.tar.gz chromium_src-708167077798a6ced31af8d7b2390b3ce5fc5eac.tar.bz2 |
Fix wrong timing when audio is muted.
BUG=131039
TEST=Added case to unit tests, and test in the bug.
Review URL: https://chromiumcodereview.appspot.com/10466007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/audio_output_mixer.cc | 4 | ||||
-rw-r--r-- | media/audio/audio_output_proxy_unittest.cc | 4 | ||||
-rw-r--r-- | media/audio/audio_util.cc | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/media/audio/audio_output_mixer.cc b/media/audio/audio_output_mixer.cc index e0dfe37..edce4ea 100644 --- a/media/audio/audio_output_mixer.cc +++ b/media/audio/audio_output_mixer.cc @@ -194,11 +194,7 @@ uint32 AudioOutputMixer::OnMoreData(uint8* dest, AudioBuffersState(proxy_data->pending_bytes, 0)); if (actual_size == 0) continue; - - // No need to mix muted stream. double volume = proxy_data->volume; - if (volume == 0.0) - continue; // Different handling for first and all subsequent streams. if (first_stream) { diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc index 2838b8f..f2fd6a6 100644 --- a/media/audio/audio_output_proxy_unittest.cc +++ b/media/audio/audio_output_proxy_unittest.cc @@ -465,6 +465,10 @@ TEST_F(AudioOutputProxyTest, TwoStreams_BothPlaying_Mixer) { EXPECT_TRUE(proxy2->Open()); proxy1->Start(&callback_); + + // Mute the proxy. Resulting stream should still have correct length. + proxy1->SetVolume(0.0); + uint8 zeroes[4] = {0, 0, 0, 0}; uint8 buf1[4] = {0}; EXPECT_CALL(callback_, diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index 01d71ee..524b1e8 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -260,7 +260,7 @@ static void InterleaveFloatToInt(const std::vector<float*>& source, void InterleaveFloatToInt(const std::vector<float*>& source, void* dst, size_t number_of_frames, int bytes_per_sample) { - switch(bytes_per_sample) { + switch (bytes_per_sample) { case 1: InterleaveFloatToInt<uint8, int32>(source, dst, number_of_frames); break; @@ -281,6 +281,8 @@ void InterleaveFloatToInt(const std::vector<float*>& source, void* dst, // when we have to adjust volume as well. template<class Format, class Fixed, int min_value, int max_value, int bias> static void MixStreams(Format* dst, Format* src, int count, float volume) { + if (volume == 0.0f) + return; if (volume == 1.0f) { // Most common case -- no need to adjust volume. for (int i = 0; i < count; ++i) { |