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

Unified Diff: media/renderers/audio_renderer_impl.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/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 dbc1b8ea8da918e670a03a2860606d5e1999808d..8dd7b0478edea416d03e815afb98bdf500b74aa0 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -166,10 +166,16 @@ base::TimeDelta AudioRendererImpl::CurrentMediaTime() {
return current_media_time;
}
-base::TimeTicks AudioRendererImpl::GetWallClockTime(base::TimeDelta time) {
- base::AutoLock auto_lock(lock_);
- if (last_render_ticks_.is_null() || playback_rate_ == 0.0)
+base::TimeTicks AudioRendererImpl::GetWallClockTime(base::TimeDelta time,
+ int request_flags) {
+ if (request_flags & SUSPEND_TIME)
+ lock_.Acquire();
+
+ lock_.AssertAcquired();
+ if (last_render_ticks_.is_null() || playback_rate_ == 0.0) {
+ lock_.Release();
return base::TimeTicks();
+ }
base::TimeDelta base_time;
if (time < audio_clock_->front_timestamp()) {
@@ -179,14 +185,26 @@ base::TimeTicks AudioRendererImpl::GetWallClockTime(base::TimeDelta time) {
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);
+ const base::TimeTicks result =
+ last_render_ticks_ + audio_clock_->TimeUntilPlayback(time);
+
+ if (request_flags & RESUME_TIME)
+ lock_.Release();
+
+ return result;
}
// 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_);
+ const base::TimeTicks result =
+ last_render_ticks_ + audio_clock_->TimeUntilPlayback(base_time) +
+ base::TimeDelta::FromMicroseconds((time - base_time).InMicroseconds() /
+ playback_rate_);
+
+ if (request_flags & RESUME_TIME)
+ lock_.Release();
+
+ return result;
}
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