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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 1136513004: Switch GetWallClockTime to using vectors for input and output. (Closed) Base URL: https://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..ec838b7067cbe8553f874bc1afc8755b940e1b9c 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -166,27 +166,39 @@ base::TimeDelta AudioRendererImpl::CurrentMediaTime() {
return current_media_time;
}
-base::TimeTicks AudioRendererImpl::GetWallClockTime(base::TimeDelta time) {
+bool AudioRendererImpl::GetWallClockTime(
+ const std::vector<base::TimeDelta>& media_timestamps,
+ std::vector<base::TimeTicks>* wall_clock_times) {
base::AutoLock auto_lock(lock_);
- 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);
- }
+ if (last_render_ticks_.is_null() || !playback_rate_)
+ return false;
+
+ DCHECK(wall_clock_times->empty());
+ wall_clock_times->reserve(media_timestamps.size());
+ for (const auto& media_timestamp : media_timestamps) {
+ base::TimeDelta base_time;
+ if (media_timestamp < audio_clock_->front_timestamp()) {
+ // See notes about |media_time| values less than |base_time| in TimeSource
+ // header.
+ base_time = audio_clock_->front_timestamp();
+ } else if (media_timestamp > audio_clock_->back_timestamp()) {
+ base_time = audio_clock_->back_timestamp();
+ } else {
+ // No need to estimate time, so return the actual wallclock time.
+ wall_clock_times->push_back(
+ last_render_ticks_ +
+ audio_clock_->TimeUntilPlayback(media_timestamp));
xhwang 2015/05/12 04:46:53 nit: will base_time = media_timestamp work? Or are
DaleCurtis 2015/05/12 05:35:42 It would, but I felt it was misleading to have the
+ continue;
+ }
- // 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_);
+ // In practice, most calls will be estimates given the relatively small
+ // window in which clients can get the actual time.
+ wall_clock_times->push_back(
+ last_render_ticks_ + audio_clock_->TimeUntilPlayback(base_time) +
+ base::TimeDelta::FromMicroseconds(
+ (media_timestamp - base_time).InMicroseconds() / playback_rate_));
+ }
+ return true;
}
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