Index: media/filters/audio_renderer_base.cc |
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc |
index 049a39a1005856fc38032ddc3da4b879636bccf5..d40bac46460968419b4f48408fa78501fdefbd25 100644 |
--- a/media/filters/audio_renderer_base.cc |
+++ b/media/filters/audio_renderer_base.cc |
@@ -67,6 +67,7 @@ void AudioRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) { |
base::AutoLock auto_lock(lock_); |
DCHECK_EQ(kPaused, state_); |
DCHECK(!pending_read_) << "Pending read must complete before seeking"; |
+ DCHECK(pause_callback_.is_null()); |
DCHECK(seek_cb_.is_null()); |
state_ = kSeeking; |
seek_cb_ = cb; |
@@ -151,30 +152,35 @@ void AudioRendererBase::DecodedAudioReady(scoped_refptr<Buffer> buffer) { |
return; |
} |
- // Don't enqueue an end-of-stream buffer because it has no data, otherwise |
- // discard decoded audio data until we reach our desired seek timestamp. |
- if (buffer->IsEndOfStream()) { |
- recieved_end_of_stream_ = true; |
- |
- // Transition to kPlaying if we are currently handling an underflow since no |
- // more data will be arriving. |
- if (state_ == kUnderflow || state_ == kRebuffering) |
- state_ = kPlaying; |
- } else if (state_ == kSeeking && !buffer->IsEndOfStream() && |
- (buffer->GetTimestamp() + buffer->GetDuration()) < |
- seek_timestamp_) { |
- ScheduleRead_Locked(); |
- } else { |
- // Note: Calling this may schedule more reads. |
- algorithm_->EnqueueBuffer(buffer); |
+ if (buffer) { |
Ami GONE FROM CHROMIUM
2012/01/27 23:44:58
that you can't reverse the test and early-return (
acolwell GONE FROM CHROMIUM
2012/01/29 03:00:41
Done. Cleaned things up nicely and uncovered an un
|
+ // Don't enqueue an end-of-stream buffer because it has no data, otherwise |
+ // discard decoded audio data until we reach our desired seek timestamp. |
+ if (buffer->IsEndOfStream()) { |
+ recieved_end_of_stream_ = true; |
+ |
+ // Transition to kPlaying if we are currently handling an underflow since |
+ // no more data will be arriving. |
+ if (state_ == kUnderflow || state_ == kRebuffering) |
+ state_ = kPlaying; |
+ } else if (state_ == kSeeking && !buffer->IsEndOfStream() && |
+ (buffer->GetTimestamp() + buffer->GetDuration()) < |
+ seek_timestamp_) { |
+ ScheduleRead_Locked(); |
+ } else { |
+ // Note: Calling this may schedule more reads. |
+ algorithm_->EnqueueBuffer(buffer); |
+ } |
} |
// Check for our preroll complete condition. |
if (state_ == kSeeking) { |
DCHECK(!seek_cb_.is_null()); |
- if (algorithm_->IsQueueFull() || recieved_end_of_stream_) { |
- // Transition into paused whether we have data in |algorithm_| or not. |
- // FillBuffer() will play silence if there's nothing to fill. |
+ |
+ // Transition to paused if we have enough data or have reached the end of |
+ // the stream. A NULL buffer also triggers the transition because it |
+ // indicates that another seek will happen right after we complete this one |
+ // so there is no point in continuing to preroll. |
+ if (algorithm_->IsQueueFull() || recieved_end_of_stream_ || !buffer) { |
state_ = kPaused; |
ResetAndRunCB(&seek_cb_, PIPELINE_OK); |
} |