From 89ce4597eeb392be29e8e7e58d991742cfd38a41 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Thu, 27 Aug 2009 00:09:53 +0000 Subject: Make audio and video in sync while playback rate != 1.0 BUG=20290 TEST=play a video with rate 0.5, audio and video should be in sync This change use the playback rate as a scaling factor for delay introduced in the audio hardware buffer. After we scaled the amount of audio buffer not played, we'll be able to make audio / video in sync again. Review URL: http://codereview.chromium.org/174584 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24568 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/media/audio_renderer_impl.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'chrome/renderer/media') diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc index 783acf3..6b1ecf0 100644 --- a/chrome/renderer/media/audio_renderer_impl.cc +++ b/chrome/renderer/media/audio_renderer_impl.cc @@ -291,6 +291,13 @@ void AudioRendererImpl::OnNotifyPacketReady() { } } + // Finally we need to adjust the delay according to playback rate. + if (GetPlaybackRate() != 1.0f) { + request_delay = base::TimeDelta::FromMicroseconds( + static_cast(ceil(request_delay.InMicroseconds() * + GetPlaybackRate()))); + } + size_t filled = FillBuffer(static_cast(shared_memory_->memory()), shared_memory_size_, request_delay); -- cgit v1.1