summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-27 00:09:53 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-27 00:09:53 +0000
commit89ce4597eeb392be29e8e7e58d991742cfd38a41 (patch)
treeecd7dadb4358a57cc149f8ad71cb407c29573734
parent8e334099687557dcdca8128626ef46c857db2dcc (diff)
downloadchromium_src-89ce4597eeb392be29e8e7e58d991742cfd38a41.zip
chromium_src-89ce4597eeb392be29e8e7e58d991742cfd38a41.tar.gz
chromium_src-89ce4597eeb392be29e8e7e58d991742cfd38a41.tar.bz2
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
-rw-r--r--chrome/renderer/media/audio_renderer_impl.cc7
-rw-r--r--media/filters/audio_renderer_impl.cc1
2 files changed, 8 insertions, 0 deletions
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<int64>(ceil(request_delay.InMicroseconds() *
+ GetPlaybackRate())));
+ }
+
size_t filled = FillBuffer(static_cast<uint8*>(shared_memory_->memory()),
shared_memory_size_,
request_delay);
diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc
index cf31af7..180dc35 100644
--- a/media/filters/audio_renderer_impl.cc
+++ b/media/filters/audio_renderer_impl.cc
@@ -57,6 +57,7 @@ size_t AudioRendererImpl::OnMoreData(AudioOutputStream* stream, void* dest_void,
// TODO(scherkus): Maybe change OnMoreData to pass in char/uint8 or similar.
// TODO(fbarchard): Waveout_output_win.h should handle zero length buffers
// without clicking.
+ pending_bytes = static_cast<int>(ceil(pending_bytes * GetPlaybackRate()));
base::TimeDelta delay = base::TimeDelta::FromMicroseconds(
base::Time::kMicrosecondsPerSecond * pending_bytes / bytes_per_second_);
return FillBuffer(static_cast<uint8*>(dest_void), len, delay);