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

Unified Diff: media/base/silent_sink_suspender.cc

Issue 2567143002: media::SilentSinkSuspender should simulate |delay| and |delay_timestamp| (Closed)
Patch Set: Created 4 years 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
Index: media/base/silent_sink_suspender.cc
diff --git a/media/base/silent_sink_suspender.cc b/media/base/silent_sink_suspender.cc
index 2f01ed9fcd990cedd797d3a04224e5285bfff27b..7c26da408f76401529f9039347567c979a59567a 100644
--- a/media/base/silent_sink_suspender.cc
+++ b/media/base/silent_sink_suspender.cc
@@ -53,8 +53,14 @@ int SilentSinkSuspender::Render(base::TimeDelta delay,
// the audio data for a future transition out of silence.
if (!dest) {
DCHECK(is_using_fake_sink_);
- DCHECK_EQ(delay, base::TimeDelta());
DCHECK_EQ(prior_frames_skipped, 0);
+ // |delay_timestamp| contains the value cached at
+ // |fake_sink_transition_time_|
+ // so we simulate the real sink output, promoting |delay_timestamp| with
+ // |elapsedTime|.
+ base::TimeDelta elapsedTime =
+ base::TimeTicks::Now() - fake_sink_transition_time_;
+ delay_timestamp += elapsedTime;
chcunningham 2016/12/20 18:36:43 Could be a little simpler. // Same comment... DCH
Mikhail 2016/12/20 21:45:50 sorry, I made a mistake in the comment :( it cache
chcunningham 2016/12/21 07:02:54 No worries. But the core of my comment is about re
// If we have no buffers or a transition is pending, one or more extra
// Render() calls have occurred in before TransitionSinks() can run, so we
@@ -90,6 +96,9 @@ int SilentSinkSuspender::Render(base::TimeDelta delay,
first_silence_time_ = now;
if (now - first_silence_time_ > silence_timeout_) {
is_transition_pending_ = true;
+ latest_output_delay_ = delay;
+ latest_output_delay_timestamp_ = delay_timestamp;
+ fake_sink_transition_time_ = now;
task_runner_->PostTask(
FROM_HERE, base::Bind(sink_transition_callback_.callback(), true));
}
@@ -124,8 +133,8 @@ void SilentSinkSuspender::TransitionSinks(bool use_fake_sink) {
}
fake_sink_.Start(
base::Bind(base::IgnoreResult(&SilentSinkSuspender::Render),
- base::Unretained(this), base::TimeDelta(),
- base::TimeTicks::Now(), 0, nullptr));
+ base::Unretained(this), latest_output_delay_,
+ latest_output_delay_timestamp_, 0, nullptr));
} else {
fake_sink_.Stop();

Powered by Google App Engine
This is Rietveld 408576698