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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 1027553002: Change the TimeSource interface to return wallclock time for video. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove underflow changes. Created 5 years, 9 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/renderers/audio_renderer_impl.h ('k') | media/renderers/renderer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/audio_renderer_impl.cc
diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc
index bb6dffa38da45dc5e82d3f10b3e349960503226a..6f839db9d651cda230328721876aff08fe82549d 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -166,15 +166,27 @@ base::TimeDelta AudioRendererImpl::CurrentMediaTime() {
return current_media_time;
}
-base::TimeDelta AudioRendererImpl::CurrentMediaTimeForSyncingVideo() {
- DVLOG(3) << __FUNCTION__;
-
+base::TimeTicks AudioRendererImpl::GetWallClockTime(base::TimeDelta time) {
base::AutoLock auto_lock(lock_);
- if (last_render_ticks_.is_null())
- return audio_clock_->front_timestamp();
+ if (last_render_ticks_.is_null() || playback_rate_ == 0.0)
+ return base::TimeTicks();
+
+ base::TimeDelta base_time;
+ if (time < audio_clock_->front_timestamp()) {
+ // See notes about |time| values less than |base_time| in TimeSource header.
+ base_time = audio_clock_->front_timestamp();
+ } else if (time > audio_clock_->back_timestamp()) {
+ base_time = audio_clock_->back_timestamp();
+ } else {
+ // No need to estimate time, so return the actual wallclock time.
+ return last_render_ticks_ + audio_clock_->TimeUntilPlayback(time);
+ }
- return audio_clock_->TimestampSinceWriting(base::TimeTicks::Now() -
- last_render_ticks_);
+ // In practice, most calls will be estimates given the relatively small window
+ // in which clients can get the actual time.
+ return last_render_ticks_ + audio_clock_->TimeUntilPlayback(base_time) +
+ base::TimeDelta::FromMicroseconds((time - base_time).InMicroseconds() /
+ playback_rate_);
}
TimeSource* AudioRendererImpl::GetTimeSource() {
« no previous file with comments | « media/renderers/audio_renderer_impl.h ('k') | media/renderers/renderer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698