summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqinmin <qinmin@chromium.org>2016-02-04 15:41:38 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-04 23:43:11 +0000
commitcb74a389db28459f9e40e421ad0c528646d7654a (patch)
tree6efb1f2a85154ed03b1228d7bc2ebb095ec8d2e5
parent10695181e422360ed1d8f3c33daa28197b0de210 (diff)
downloadchromium_src-cb74a389db28459f9e40e421ad0c528646d7654a.zip
chromium_src-cb74a389db28459f9e40e421ad0c528646d7654a.tar.gz
chromium_src-cb74a389db28459f9e40e421ad0c528646d7654a.tar.bz2
Fix an issue that webaudio breaks when entering silence mode for the 2nd time
When entering the silence mode, android starts a null audio sink by calling Play() And when leaving the silence mode, android calls Stop() on that null audio sink. However, Stop() doesn't actually clean up the playing_ variable. As a result, when entering the silence mode the 2nd time, the Play() call is ignored. BUG=518863 Review URL: https://codereview.chromium.org/1664933002 Cr-Commit-Position: refs/heads/master@{#373664}
-rw-r--r--content/renderer/media/renderer_webaudiodevice_impl.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc
index 2697a08..6c366c1 100644
--- a/content/renderer/media/renderer_webaudiodevice_impl.cc
+++ b/content/renderer/media/renderer_webaudiodevice_impl.cc
@@ -49,6 +49,7 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
security_origin_(security_origin) {
DCHECK(client_callback_);
null_audio_sink_->Initialize(params_, this);
+ null_audio_sink_->Start();
}
RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() {
@@ -128,13 +129,17 @@ int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest,
first_silence_time_ = base::TimeTicks();
if (is_using_null_audio_sink_) {
// This is called on the main render thread when audio is detected.
- output_device_->Play();
+ DCHECK(thread_checker_.CalledOnValidThread());
is_using_null_audio_sink_ = false;
is_first_buffer_after_silence_ = true;
dest->CopyTo(first_buffer_after_silence_.get());
task_runner_->PostTask(
FROM_HERE,
- base::Bind(&media::NullAudioSink::Stop, null_audio_sink_));
+ base::Bind(&media::NullAudioSink::Pause, null_audio_sink_));
+ // Calling output_device_->Play() may trigger reentrancy into this
+ // function, so this should be called at the end.
+ output_device_->Play();
+ return dest->frames();
}
} else if (!is_using_null_audio_sink_) {
// Called on the audio device thread.