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

Unified Diff: media/renderers/renderer_impl.cc

Issue 2890603004: Freeze the reported media time while audio is restarted (Closed)
Patch Set: Fixed nits Created 3 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/renderer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/renderer_impl.cc
diff --git a/media/renderers/renderer_impl.cc b/media/renderers/renderer_impl.cc
index eb5710d2eea5f40c4f634d063a62e29f9547c162..d2386f6c8839c7704aae822a5b1b9b5cb46a5ac5 100644
--- a/media/renderers/renderer_impl.cc
+++ b/media/renderers/renderer_impl.cc
@@ -264,6 +264,13 @@ void RendererImpl::SetVolume(float volume) {
base::TimeDelta RendererImpl::GetMediaTime() {
// No BelongsToCurrentThread() checking because this can be called from other
// threads.
+ {
+ base::AutoLock lock(restarting_audio_lock_);
+ if (restarting_audio_) {
+ DCHECK_NE(kNoTimestamp, restarting_audio_time_);
+ return restarting_audio_time_;
+ }
+ }
return time_source_->CurrentMediaTime();
}
@@ -575,7 +582,11 @@ void RendererImpl::OnStreamStatusChanged(DemuxerStream* stream,
} else if (stream->type() == DemuxerStream::AUDIO) {
DCHECK(audio_renderer_);
DCHECK(time_source_);
- restarting_audio_ = true;
+ {
+ base::AutoLock lock(restarting_audio_lock_);
+ restarting_audio_time_ = time;
+ restarting_audio_ = true;
+ }
base::Closure handle_track_status_cb =
base::Bind(stream == current_audio_stream_
? &RendererImpl::RestartAudioRenderer
@@ -769,7 +780,11 @@ void RendererImpl::OnStreamRestartCompleted() {
<< " restarting_video_=" << restarting_video_;
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(restarting_audio_ || restarting_video_);
- restarting_audio_ = false;
+ {
+ base::AutoLock lock(restarting_audio_lock_);
+ restarting_audio_ = false;
+ restarting_audio_time_ = kNoTimestamp;
+ }
restarting_video_ = false;
if (!pending_actions_.empty()) {
base::Closure closure = pending_actions_.front();
« no previous file with comments | « media/renderers/renderer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698