summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-03 21:15:36 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-03 21:15:36 +0000
commit1e5f0256a2d63ada7268084ed35df3fc460b930e (patch)
treecd284a4e0876834c2fb73c7da7a08ed0065698b2 /media
parent9395af55b075d0927f51762cb7c281ee2f44f703 (diff)
downloadchromium_src-1e5f0256a2d63ada7268084ed35df3fc460b930e.zip
chromium_src-1e5f0256a2d63ada7268084ed35df3fc460b930e.tar.gz
chromium_src-1e5f0256a2d63ada7268084ed35df3fc460b930e.tar.bz2
Fix a few races due to lack of locking in AudioRendererImpl::FillBuffer().
Also switched to using kNoTimestamp() to represent uninitialized timestamps. TBR=timurrrr BUG=109875,112418,122447 TEST=tsan is happy, also run http://mastodon.sea/demos/crbug122447 Review URL: https://chromiumcodereview.appspot.com/10355006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/audio_renderer_impl.cc35
-rw-r--r--media/filters/audio_renderer_impl.h1
2 files changed, 20 insertions, 16 deletions
diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc
index ddb2d287..3821093 100644
--- a/media/filters/audio_renderer_impl.cc
+++ b/media/filters/audio_renderer_impl.cc
@@ -20,6 +20,7 @@ AudioRendererImpl::AudioRendererImpl(media::AudioRendererSink* sink)
pending_read_(false),
received_end_of_stream_(false),
rendered_end_of_stream_(false),
+ audio_time_buffered_(kNoTimestamp()),
bytes_per_frame_(0),
bytes_per_second_(0),
stopped_(false),
@@ -119,7 +120,7 @@ void AudioRendererImpl::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
seek_timestamp_ = time;
// Throw away everything and schedule our reads.
- audio_time_buffered_ = base::TimeDelta();
+ audio_time_buffered_ = kNoTimestamp();
received_end_of_stream_ = false;
rendered_end_of_stream_ = false;
@@ -377,11 +378,8 @@ int AudioRendererImpl::Render(const std::vector<float*>& audio_data,
uint32 AudioRendererImpl::FillBuffer(uint8* dest,
uint32 requested_frames,
const base::TimeDelta& playback_delay) {
- // The |audio_time_buffered_| is the ending timestamp of the last frame
- // buffered at the audio device. |playback_delay| is the amount of time
- // buffered at the audio device. The current time can be computed by their
- // difference.
- base::TimeDelta current_time = audio_time_buffered_ - playback_delay;
+ base::TimeDelta current_time = kNoTimestamp();
+ base::TimeDelta max_time = kNoTimestamp();
size_t frames_written = 0;
base::Closure underflow_cb;
@@ -432,17 +430,24 @@ uint32 AudioRendererImpl::FillBuffer(uint8* dest,
// Otherwise fill the buffer.
frames_written = algorithm_->FillBuffer(dest, requested_frames);
}
- }
- base::TimeDelta previous_time_buffered = audio_time_buffered_;
- // The call to FillBuffer() on |algorithm_| has increased the amount of
- // buffered audio data. Update the new amount of time buffered.
- audio_time_buffered_ = algorithm_->GetTime();
+ // The |audio_time_buffered_| is the ending timestamp of the last frame
+ // buffered at the audio device. |playback_delay| is the amount of time
+ // buffered at the audio device. The current time can be computed by their
+ // difference.
+ if (audio_time_buffered_ != kNoTimestamp()) {
+ current_time = audio_time_buffered_ - playback_delay;
+ }
+
+ // The call to FillBuffer() on |algorithm_| has increased the amount of
+ // buffered audio data. Update the new amount of time buffered.
+ max_time = audio_time_buffered_ = algorithm_->GetTime();
+ }
- if (previous_time_buffered.InMicroseconds() > 0 &&
- (previous_time_buffered != audio_time_buffered_ ||
- current_time > host()->GetTime())) {
- time_cb_.Run(current_time, audio_time_buffered_);
+ if (current_time != kNoTimestamp() &&
+ current_time > host()->GetTime() &&
+ max_time != kNoTimestamp()) {
+ time_cb_.Run(current_time, max_time);
}
if (!underflow_cb.is_null())
diff --git a/media/filters/audio_renderer_impl.h b/media/filters/audio_renderer_impl.h
index e39f75b..8897bc6 100644
--- a/media/filters/audio_renderer_impl.h
+++ b/media/filters/audio_renderer_impl.h
@@ -156,7 +156,6 @@ class MEDIA_EXPORT AudioRendererImpl
bool rendered_end_of_stream_;
// The timestamp of the last frame (i.e. furthest in the future) buffered.
- // TODO(ralphl): Update this value after seeking.
base::TimeDelta audio_time_buffered_;
// Filter callbacks.