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

Side by Side Diff: media/renderers/renderer_impl.cc

Issue 1148473003: Fix deferred video underflow if audio underflows first. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CHECK. 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/renderers/renderer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/renderers/renderer_impl.h" 5 #include "media/renderers/renderer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 DCHECK(task_runner_->BelongsToCurrentThread()); 398 DCHECK(task_runner_->BelongsToCurrentThread());
399 399
400 if (state_ == STATE_ERROR) { 400 if (state_ == STATE_ERROR) {
401 DCHECK(flush_cb_.is_null()); 401 DCHECK(flush_cb_.is_null());
402 return; 402 return;
403 } 403 }
404 404
405 DCHECK_EQ(state_, STATE_FLUSHING); 405 DCHECK_EQ(state_, STATE_FLUSHING);
406 DCHECK(!flush_cb_.is_null()); 406 DCHECK(!flush_cb_.is_null());
407 407
408 // If we had a deferred video renderer underflow prior to the flush, it should
409 // have been cleared by the audio renderer changing to BUFFERING_HAVE_NOTHING.
410 DCHECK(deferred_underflow_cb_.IsCancelled());
411
408 DCHECK_EQ(audio_buffering_state_, BUFFERING_HAVE_NOTHING); 412 DCHECK_EQ(audio_buffering_state_, BUFFERING_HAVE_NOTHING);
409 audio_ended_ = false; 413 audio_ended_ = false;
410 FlushVideoRenderer(); 414 FlushVideoRenderer();
411 } 415 }
412 416
413 void RendererImpl::FlushVideoRenderer() { 417 void RendererImpl::FlushVideoRenderer() {
414 DVLOG(1) << __FUNCTION__; 418 DVLOG(1) << __FUNCTION__;
415 DCHECK(task_runner_->BelongsToCurrentThread()); 419 DCHECK(task_runner_->BelongsToCurrentThread());
416 DCHECK_EQ(state_, STATE_FLUSHING); 420 DCHECK_EQ(state_, STATE_FLUSHING);
417 DCHECK(!flush_cb_.is_null()); 421 DCHECK(!flush_cb_.is_null());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 454
451 void RendererImpl::OnBufferingStateChanged(BufferingState* buffering_state, 455 void RendererImpl::OnBufferingStateChanged(BufferingState* buffering_state,
452 BufferingState new_buffering_state) { 456 BufferingState new_buffering_state) {
453 const bool is_audio = buffering_state == &audio_buffering_state_; 457 const bool is_audio = buffering_state == &audio_buffering_state_;
454 DVLOG(1) << __FUNCTION__ << "(" << *buffering_state << ", " 458 DVLOG(1) << __FUNCTION__ << "(" << *buffering_state << ", "
455 << new_buffering_state << ") " << (is_audio ? "audio" : "video"); 459 << new_buffering_state << ") " << (is_audio ? "audio" : "video");
456 DCHECK(task_runner_->BelongsToCurrentThread()); 460 DCHECK(task_runner_->BelongsToCurrentThread());
457 461
458 bool was_waiting_for_enough_data = WaitingForEnoughData(); 462 bool was_waiting_for_enough_data = WaitingForEnoughData();
459 463
460 // When audio is present, defer underflow callbacks for some time to avoid 464 // When audio is present and has enough data, defer video underflow callbacks
461 // unnecessary glitches in audio; see http://crbug.com/144683#c53. 465 // for some time to avoid unnecessary glitches in audio; see
466 // http://crbug.com/144683#c53.
462 if (audio_renderer_ && !is_audio && state_ == STATE_PLAYING) { 467 if (audio_renderer_ && !is_audio && state_ == STATE_PLAYING) {
463 if (video_buffering_state_ == BUFFERING_HAVE_ENOUGH && 468 if (video_buffering_state_ == BUFFERING_HAVE_ENOUGH &&
469 audio_buffering_state_ == BUFFERING_HAVE_ENOUGH &&
464 new_buffering_state == BUFFERING_HAVE_NOTHING && 470 new_buffering_state == BUFFERING_HAVE_NOTHING &&
465 deferred_underflow_cb_.IsCancelled()) { 471 deferred_underflow_cb_.IsCancelled()) {
466 deferred_underflow_cb_.Reset(base::Bind( 472 deferred_underflow_cb_.Reset(base::Bind(
467 &RendererImpl::OnBufferingStateChanged, weak_factory_.GetWeakPtr(), 473 &RendererImpl::OnBufferingStateChanged, weak_factory_.GetWeakPtr(),
468 buffering_state, new_buffering_state)); 474 buffering_state, new_buffering_state));
469 task_runner_->PostDelayedTask(FROM_HERE, 475 task_runner_->PostDelayedTask(FROM_HERE,
470 deferred_underflow_cb_.callback(), 476 deferred_underflow_cb_.callback(),
471 video_underflow_threshold_); 477 video_underflow_threshold_);
472 return; 478 return;
473 } 479 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 637 }
632 638
633 // After OnError() returns, the pipeline may destroy |this|. 639 // After OnError() returns, the pipeline may destroy |this|.
634 base::ResetAndReturn(&error_cb_).Run(error); 640 base::ResetAndReturn(&error_cb_).Run(error);
635 641
636 if (!flush_cb_.is_null()) 642 if (!flush_cb_.is_null())
637 base::ResetAndReturn(&flush_cb_).Run(); 643 base::ResetAndReturn(&flush_cb_).Run();
638 } 644 }
639 645
640 } // namespace media 646 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/renderers/renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698