Index: media/base/pipeline.cc |
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc |
index 90444c446506d4409989ff13da85b048f39d16a0..00ac71214d194260510237a7dd29f5be68ccf3b2 100644 |
--- a/media/base/pipeline.cc |
+++ b/media/base/pipeline.cc |
@@ -19,11 +19,11 @@ |
#include "base/synchronization/condition_variable.h" |
#include "media/base/audio_decoder.h" |
#include "media/base/audio_renderer.h" |
-#include "media/base/clock.h" |
#include "media/base/filter_collection.h" |
#include "media/base/media_log.h" |
#include "media/base/text_renderer.h" |
#include "media/base/text_track_config.h" |
+#include "media/base/time_delta_interpolator.h" |
#include "media/base/video_decoder.h" |
#include "media/base/video_decoder_config.h" |
#include "media/base/video_renderer.h" |
@@ -41,8 +41,8 @@ Pipeline::Pipeline( |
did_loading_progress_(false), |
volume_(1.0f), |
playback_rate_(0.0f), |
- clock_(new Clock(&default_tick_clock_)), |
- clock_state_(CLOCK_PAUSED), |
+ interpolator_(new TimeDeltaInterpolator(&default_tick_clock_)), |
+ interpolation_state_(INTERPOLATION_STOPPED), |
status_(PIPELINE_OK), |
state_(kCreated), |
audio_ended_(false), |
@@ -156,7 +156,7 @@ void Pipeline::SetVolume(float volume) { |
TimeDelta Pipeline::GetMediaTime() const { |
base::AutoLock auto_lock(lock_); |
- return std::min(clock_->Elapsed(), duration_); |
+ return std::min(interpolator_->GetInterpolatedTime(), duration_); |
} |
Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { |
@@ -181,8 +181,9 @@ PipelineStatistics Pipeline::GetStatistics() const { |
return statistics_; |
} |
-void Pipeline::SetClockForTesting(Clock* clock) { |
- clock_.reset(clock); |
+void Pipeline::SetTimeDeltaInterpolatorForTesting( |
+ TimeDeltaInterpolator* interpolator) { |
+ interpolator_.reset(interpolator); |
} |
void Pipeline::SetErrorForTesting(PipelineStatus status) { |
@@ -290,15 +291,15 @@ void Pipeline::OnAudioTimeUpdate(TimeDelta time, TimeDelta max_time) { |
DCHECK_LE(time.InMicroseconds(), max_time.InMicroseconds()); |
base::AutoLock auto_lock(lock_); |
- if (clock_state_ == CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE && |
- time < clock_->Elapsed()) { |
+ if (interpolation_state_ == INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE && |
+ time < interpolator_->GetInterpolatedTime()) { |
return; |
} |
if (state_ == kSeeking) |
return; |
- clock_->SetTime(time, max_time); |
+ interpolator_->SetTime(time, max_time); |
StartClockIfWaitingForTimeUpdate_Locked(); |
} |
@@ -312,8 +313,8 @@ void Pipeline::OnVideoTimeUpdate(TimeDelta max_time) { |
return; |
base::AutoLock auto_lock(lock_); |
- DCHECK_NE(clock_state_, CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE); |
- clock_->SetMaxTime(max_time); |
+ DCHECK_NE(interpolation_state_, INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE); |
+ interpolator_->SetMaxTime(max_time); |
} |
void Pipeline::SetDuration(TimeDelta duration) { |
@@ -378,7 +379,7 @@ void Pipeline::StateTransitionTask(PipelineStatus status) { |
base::AutoLock l(lock_); |
// We do not want to start the clock running. We only want to set the |
// base media time so our timestamp calculations will be correct. |
- clock_->SetTime(base::TimeDelta(), base::TimeDelta()); |
+ interpolator_->SetTime(base::TimeDelta(), base::TimeDelta()); |
} |
if (!audio_renderer_ && !video_renderer_) { |
done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER); |
@@ -640,7 +641,7 @@ void Pipeline::PlaybackRateChangedTask(float playback_rate) { |
{ |
base::AutoLock auto_lock(lock_); |
- clock_->SetPlaybackRate(playback_rate); |
+ interpolator_->SetPlaybackRate(playback_rate); |
} |
if (audio_renderer_) |
@@ -689,7 +690,7 @@ void Pipeline::SeekTask(TimeDelta time, const PipelineStatusCB& seek_cb) { |
{ |
base::AutoLock auto_lock(lock_); |
PauseClockAndStopRendering_Locked(); |
- clock_->SetTime(time, time); |
+ interpolator_->SetTime(time, time); |
acolwell GONE FROM CHROMIUM
2014/07/09 00:42:46
This form appears to be used in a bunch of places.
scherkus (not reviewing)
2014/07/09 01:54:31
I'm going to the keep the API roughly intact for t
|
} |
DoSeek(time, base::Bind( |
&Pipeline::OnStateTransition, base::Unretained(this))); |
@@ -707,7 +708,7 @@ void Pipeline::DoAudioRendererEnded() { |
// Start clock since there is no more audio to trigger clock updates. |
{ |
base::AutoLock auto_lock(lock_); |
- clock_->SetMaxTime(duration_); |
+ interpolator_->SetMaxTime(duration_); |
StartClockIfWaitingForTimeUpdate_Locked(); |
} |
@@ -753,7 +754,7 @@ void Pipeline::RunEndedCallbackIfNeeded() { |
{ |
base::AutoLock auto_lock(lock_); |
PauseClockAndStopRendering_Locked(); |
- clock_->SetTime(duration_, duration_); |
+ interpolator_->SetTime(duration_, duration_); |
} |
DCHECK_EQ(status_, PIPELINE_OK); |
@@ -870,7 +871,7 @@ void Pipeline::PausePlayback() { |
void Pipeline::StartPlayback() { |
DVLOG(1) << __FUNCTION__; |
DCHECK_EQ(state_, kPlaying); |
- DCHECK_EQ(clock_state_, CLOCK_PAUSED); |
+ DCHECK_EQ(interpolation_state_, INTERPOLATION_STOPPED); |
DCHECK(!WaitingForEnoughData()); |
DCHECK(task_runner_->BelongsToCurrentThread()); |
@@ -878,43 +879,43 @@ void Pipeline::StartPlayback() { |
// We use audio stream to update the clock. So if there is such a |
// stream, we pause the clock until we receive a valid timestamp. |
base::AutoLock auto_lock(lock_); |
- clock_state_ = CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE; |
+ interpolation_state_ = INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE; |
audio_renderer_->StartRendering(); |
} else { |
base::AutoLock auto_lock(lock_); |
- clock_state_ = CLOCK_PLAYING; |
- clock_->SetMaxTime(duration_); |
- clock_->Play(); |
+ interpolation_state_ = INTERPOLATION_STARTED; |
+ interpolator_->SetMaxTime(duration_); |
acolwell GONE FROM CHROMIUM
2014/07/09 00:42:46
Yeah.. this stuff should be in the interpolator_
scherkus (not reviewing)
2014/07/09 01:54:31
Ditto.
|
+ interpolator_->StartInterpolating(); |
} |
} |
void Pipeline::PauseClockAndStopRendering_Locked() { |
lock_.AssertAcquired(); |
- switch (clock_state_) { |
- case CLOCK_PAUSED: |
+ switch (interpolation_state_) { |
+ case INTERPOLATION_STOPPED: |
return; |
- case CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE: |
+ case INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE: |
audio_renderer_->StopRendering(); |
break; |
- case CLOCK_PLAYING: |
+ case INTERPOLATION_STARTED: |
if (audio_renderer_) |
audio_renderer_->StopRendering(); |
- clock_->Pause(); |
+ interpolator_->StopInterpolating(); |
break; |
} |
- clock_state_ = CLOCK_PAUSED; |
+ interpolation_state_ = INTERPOLATION_STOPPED; |
} |
void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
lock_.AssertAcquired(); |
- if (clock_state_ != CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE) |
+ if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) |
return; |
- clock_state_ = CLOCK_PLAYING; |
- clock_->Play(); |
+ interpolation_state_ = INTERPOLATION_STARTED; |
+ interpolator_->StartInterpolating(); |
} |
} // namespace media |