Index: media/audio/clockless_audio_sink.cc |
diff --git a/media/audio/clockless_audio_sink.cc b/media/audio/clockless_audio_sink.cc |
index ab56115c27fefe5304dff4d506b257fedc4cc945..ff809d0541dd49fc87f6559bf901563cb5c92cdc 100644 |
--- a/media/audio/clockless_audio_sink.cc |
+++ b/media/audio/clockless_audio_sink.cc |
@@ -36,10 +36,16 @@ class ClocklessAudioSinkThread : public base::DelegateSimpleThread::Delegate { |
private: |
// Call Render() repeatedly, keeping track of the rendering time. |
virtual void Run() OVERRIDE { |
- base::TimeTicks start = base::TimeTicks::HighResNow(); |
+ base::TimeTicks start; |
while (!stop_event_->IsSignaled()) { |
int frames_received = callback_->Render(audio_bus_.get(), 0); |
- if (frames_received > 0) { |
+ if (frames_received <= 0) { |
+ // No data received, so let other threads run to provide data. |
+ base::PlatformThread::YieldCurrentThread(); |
+ } else if (start.is_null()) { |
+ // First time we processed some audio, so record the starting time. |
+ start = base::TimeTicks::HighResNow(); |
+ } else { |
// Keep track of the last time data was rendered. |
playback_time_ = base::TimeTicks::HighResNow() - start; |
} |