From e0a4a97c380a34306ec2acbf7ce7d1bda3c684b7 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Fri, 2 Apr 2010 22:54:37 +0000 Subject: Audio cut off ~500ms too early BUG=23055 TEST=layout tests and audio won't cut off too early with this file: http://commons.wikimedia.org/wiki/File:Montreal2.ogg This patch fix the problem by adding an extra condition to determine the end of playback by using the information of buffered audio data in the browser process. If both the renderer process and browser process don't have any more audio data then end of playback is resulted. Review URL: http://codereview.chromium.org/1581008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43546 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/media/audio_renderer_impl.cc | 2 +- media/filters/audio_renderer_base.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc index 70cf769..c39c4d5 100644 --- a/chrome/renderer/media/audio_renderer_impl.cc +++ b/chrome/renderer/media/audio_renderer_impl.cc @@ -195,7 +195,7 @@ void AudioRendererImpl::OnRequestPacket(uint32 bytes_in_buffer, request_delay_ = ConvertToDuration(bytes_in_buffer); } - // Try to fill in the fulfill the packet request. + // Try to fulfill the packet request. OnNotifyPacketReady(); } diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc index 712fc45..f07a4c2 100644 --- a/media/filters/audio_renderer_base.cc +++ b/media/filters/audio_renderer_base.cc @@ -192,8 +192,10 @@ uint32 AudioRendererBase::FillBuffer(uint8* dest, last_fill_buffer_time = last_fill_buffer_time_; last_fill_buffer_time_ = base::TimeDelta(); - // Check if we finally reached end of stream by emptying |algorithm_|. - if (algorithm_->IsQueueEmpty()) { + // Use two conditions to determine the end of playback: + // 1. Algorithm has no audio data. + // 2. Browser process has no audio data. + if (algorithm_->IsQueueEmpty() && !playback_delay.ToInternalValue()) { if (recieved_end_of_stream_ && !rendered_end_of_stream_) { rendered_end_of_stream_ = true; host()->NotifyEnded(); -- cgit v1.1