diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 22:41:55 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 22:41:55 +0000 |
commit | 698835d3e64c96bb5e7a29ab66d2ecbee375fc63 (patch) | |
tree | 4e06c91dbf1c245fb3f0b4d80c327463e7951fe0 /chrome/renderer/media/audio_renderer_impl.cc | |
parent | ec9767f8c6889b40494ec8aab55f0cd913f97746 (diff) | |
download | chromium_src-698835d3e64c96bb5e7a29ab66d2ecbee375fc63.zip chromium_src-698835d3e64c96bb5e7a29ab66d2ecbee375fc63.tar.gz chromium_src-698835d3e64c96bb5e7a29ab66d2ecbee375fc63.tar.bz2 |
Fixed a lot threading issues during tear down of <video>
Fixed a lot of dead locks during tead down of <video> due
to DataSourceImpl.
Most of the issues come from that during a tab close
RenderThread is destroyed and new tasks posted on it
will not executed, but DataSourceImpl is waiting for
those tasks to finish to complete stopping. Another
dead lock comes from that when RenderThread is
destroyed the owner loop of it (a IO Message Loop) is
being destroyed too and DataSourceImpl shouldn't post
tasks to that message loop when stopping.
Review URL: http://codereview.chromium.org/42675
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/media/audio_renderer_impl.cc')
-rw-r--r-- | chrome/renderer/media/audio_renderer_impl.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc index 9677b32..a830b40 100644 --- a/chrome/renderer/media/audio_renderer_impl.cc +++ b/chrome/renderer/media/audio_renderer_impl.cc @@ -57,7 +57,8 @@ bool AudioRendererImpl::OnInitialize(const media::MediaFormat& media_format) { void AudioRendererImpl::OnStop() { if (!resource_release_event_.IsSignaled()) { render_loop_->PostTask(FROM_HERE, - NewRunnableMethod(this, &AudioRendererImpl::ReleaseRendererResources)); + NewRunnableMethod(this, + &AudioRendererImpl::ReleaseResources, false)); resource_release_event_.Wait(); } } @@ -90,6 +91,7 @@ void AudioRendererImpl::SetVolume(float volume) { void AudioRendererImpl::OnCreated(base::SharedMemoryHandle handle, size_t length) { shared_memory_.reset(new base::SharedMemory(handle, false)); + shared_memory_->Map(length); shared_memory_size_ = length; // TODO(hclam): is there any better place to do this? OnStartAudioStream(); @@ -97,6 +99,9 @@ void AudioRendererImpl::OnCreated(base::SharedMemoryHandle handle, void AudioRendererImpl::OnRequestPacket() { packet_requested_ = true; + // Post a task to render thread and try to grab a packet for sending back. + render_loop_->PostTask(FROM_HERE, + NewRunnableMethod(this, &AudioRendererImpl::OnNotifyAudioPacketReady)); } void AudioRendererImpl::OnStateChanged(AudioOutputStream::State state, @@ -120,8 +125,9 @@ void AudioRendererImpl::OnVolume(double left, double right) { // pipeline. } -void AudioRendererImpl::ReleaseRendererResources() { - OnCloseAudioStream(); +void AudioRendererImpl::ReleaseResources(bool is_render_thread_dying) { + if (!is_render_thread_dying) + OnCloseAudioStream(); resource_release_event_.Signal(); } @@ -151,8 +157,10 @@ void AudioRendererImpl::OnNotifyAudioPacketReady() { // Fill into the shared memory. size_t filled = FillBuffer(static_cast<uint8*>(shared_memory_->memory()), shared_memory_size_); - packet_requested_ = false; - // Then tell browser process we are done filling into the buffer. - delegate_->view()->NotifyAudioPacketReady(stream_id_, filled); + if (filled > 0) { + packet_requested_ = false; + // Then tell browser process we are done filling into the buffer. + delegate_->view()->NotifyAudioPacketReady(stream_id_, filled); + } } } |