diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 00:54:17 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 00:54:17 +0000 |
commit | a37ebbc3c152f9e2ff6b1e1726cf6cd2ad4da8a0 (patch) | |
tree | 4dd861b51dd194af1f7051a4213d350ab63325c8 | |
parent | 59316ec0027a6e6eec0f71405edc8d2a53039db0 (diff) | |
download | chromium_src-a37ebbc3c152f9e2ff6b1e1726cf6cd2ad4da8a0.zip chromium_src-a37ebbc3c152f9e2ff6b1e1726cf6cd2ad4da8a0.tar.gz chromium_src-a37ebbc3c152f9e2ff6b1e1726cf6cd2ad4da8a0.tar.bz2 |
Don't update the clock if we don't have a reliable timestamp available.
Turns out vorbis packets only have an accurate timestamp every second or so while the rest of the packets have a timestamp of zero. Problem was we were overwriting |last_fill_buffer_time_| with zeros and then updating the clock, effectively causing a ton of drift.
Review URL: http://codereview.chromium.org/115593
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16561 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/filters/audio_renderer_base.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc index 28acd82..8466c2e 100644 --- a/media/filters/audio_renderer_base.cc +++ b/media/filters/audio_renderer_base.cc @@ -79,10 +79,14 @@ void AudioRendererBase::OnReadComplete(Buffer* buffer_in) { } } +// TODO(scherkus): clean up FillBuffer().. it's overly complex!! size_t AudioRendererBase::FillBuffer(uint8* dest, size_t dest_len, float rate) { - // Update the pipeline's time. - host_->SetTime(last_fill_buffer_time_); + // Update the pipeline's time if it was set last time. + if (last_fill_buffer_time_.InMicroseconds() > 0) { + host_->SetTime(last_fill_buffer_time_); + last_fill_buffer_time_ = base::TimeDelta(); + } size_t buffers_released = 0; size_t dest_written = 0; @@ -128,7 +132,9 @@ size_t AudioRendererBase::FillBuffer(uint8* dest, size_t dest_len, // Update the time. If this is the last buffer in the queue, we'll // drop out of the loop before len == 0, so we need to always update // the time here. - last_fill_buffer_time_ = buffer->GetTimestamp() + buffer->GetDuration(); + if (buffer->GetTimestamp().InMicroseconds() > 0) { + last_fill_buffer_time_ = buffer->GetTimestamp() + buffer->GetDuration(); + } // Dequeue the buffer. queue_.pop_front(); @@ -142,8 +148,11 @@ size_t AudioRendererBase::FillBuffer(uint8* dest, size_t dest_len, // Integer divide so multiply before divide to work properly. int64 us_written = (buffer->GetDuration().InMicroseconds() * data_offset_) / buffer->GetDataSize(); - last_fill_buffer_time_ = buffer->GetTimestamp() + - base::TimeDelta::FromMicroseconds(us_written); + + if (buffer->GetTimestamp().InMicroseconds() > 0) { + last_fill_buffer_time_ = buffer->GetTimestamp() + + base::TimeDelta::FromMicroseconds(us_written); + } } } |