Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: media/filters/video_renderer_algorithm.cc

Issue 1129323003: Allow callers of TimeSource::GetWallClockTime() to suspend time. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/video_renderer_algorithm.h ('k') | media/renderers/audio_renderer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_algorithm.cc
diff --git a/media/filters/video_renderer_algorithm.cc b/media/filters/video_renderer_algorithm.cc
index 5bad074339eb2f420bd39a3652079f63738cfa41..b1817d457480ef25e04843a334d436369f0ef812 100644
--- a/media/filters/video_renderer_algorithm.cc
+++ b/media/filters/video_renderer_algorithm.cc
@@ -30,13 +30,13 @@ bool VideoRendererAlgorithm::ReadyFrame::operator<(
}
VideoRendererAlgorithm::VideoRendererAlgorithm(
- const TimeConverterCB& time_converter_cb)
+ const TimeSource::WallClockTimeCB& wall_clock_time_cb)
: cadence_estimator_(base::TimeDelta::FromSeconds(
kMinimumAcceptableTimeBetweenGlitchesSecs)),
- time_converter_cb_(time_converter_cb),
+ wall_clock_time_cb_(wall_clock_time_cb),
frame_duration_calculator_(kMovingAverageSamples),
frame_dropping_disabled_(false) {
- DCHECK(!time_converter_cb_.is_null());
+ DCHECK(!wall_clock_time_cb_.is_null());
Reset();
}
@@ -381,7 +381,14 @@ bool VideoRendererAlgorithm::UpdateFrameStatistics() {
for (size_t i = 0; i < frame_queue_.size(); ++i) {
ReadyFrame& frame = frame_queue_[i];
const bool new_frame = frame.start_time.is_null();
- frame.start_time = time_converter_cb_.Run(frame.frame->timestamp());
+ frame.start_time = wall_clock_time_cb_.Run(
+ frame.frame->timestamp(),
+ frame_queue_.size() == 1
+ ? TimeSource::SINGLE_TIMESTAMP
+ : (i == 0 ? TimeSource::SUSPEND_TIME
+ : (i + 1 == frame_queue_.size()
+ ? TimeSource::RESUME_TIME
+ : TimeSource::TIME_IS_SUSPENDED)));
// If time stops or never started, exit immediately.
if (frame.start_time.is_null()) {
@@ -389,16 +396,14 @@ bool VideoRendererAlgorithm::UpdateFrameStatistics() {
return false;
}
- // TODO(dalecurtis): An unlucky tick of a playback rate change could cause
- // this to skew so much that time goes backwards between calls. Fix this by
- // either converting all timestamps at once or with some retry logic.
if (i > 0) {
frame_queue_[i - 1].end_time = frame.start_time;
- const base::TimeDelta delta =
- frame.start_time - frame_queue_[i - 1].start_time;
- CHECK_GT(delta, base::TimeDelta());
- if (new_frame)
+ if (new_frame) {
+ const base::TimeDelta delta =
+ frame.start_time - frame_queue_[i - 1].start_time;
+ DCHECK_GT(delta, base::TimeDelta());
frame_duration_calculator_.AddSample(delta);
+ }
}
}
« no previous file with comments | « media/filters/video_renderer_algorithm.h ('k') | media/renderers/audio_renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698