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

Unified Diff: chromecast/media/cma/filters/cma_renderer.cc

Issue 869283003: Chromecast buildfix: update CmaRenderer for Initialize API change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed error handling during initialization Created 5 years, 11 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 | « chromecast/media/cma/filters/cma_renderer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/media/cma/filters/cma_renderer.cc
diff --git a/chromecast/media/cma/filters/cma_renderer.cc b/chromecast/media/cma/filters/cma_renderer.cc
index 600ec5bae6eb48c6a5c96780438250522bcff8d6..d9266f8aeafbbe382311427a377f5b51dc97513b 100644
--- a/chromecast/media/cma/filters/cma_renderer.cc
+++ b/chromecast/media/cma/filters/cma_renderer.cc
@@ -62,12 +62,15 @@ CmaRenderer::CmaRenderer(scoped_ptr<MediaPipeline> media_pipeline)
CmaRenderer::~CmaRenderer() {
DCHECK(thread_checker_.CalledOnValidThread());
- FireAllPendingCallbacks();
+ if (!init_cb_.is_null())
+ base::ResetAndReturn(&init_cb_).Run(::media::PIPELINE_ERROR_ABORT);
+ else if (!flush_cb_.is_null())
+ base::ResetAndReturn(&flush_cb_).Run();
}
void CmaRenderer::Initialize(
::media::DemuxerStreamProvider* demuxer_stream_provider,
- const base::Closure& init_cb,
+ const ::media::PipelineStatusCB& init_cb,
const ::media::StatisticsCB& statistics_cb,
const ::media::BufferingStateCB& buffering_state_cb,
const PaintCB& paint_cb,
@@ -259,12 +262,16 @@ void CmaRenderer::InitializeAudioPipeline() {
void CmaRenderer::OnAudioPipelineInitializeDone(
::media::PipelineStatus status) {
DCHECK(thread_checker_.CalledOnValidThread());
+
+ // OnError() may be fired at any time, even before initialization is complete.
+ if (state_ == kError)
+ return;
+
DCHECK_EQ(state_, kUninitialized) << state_;
DCHECK(!init_cb_.is_null());
-
if (status != ::media::PIPELINE_OK) {
has_audio_ = false;
- OnError(status);
+ base::ResetAndReturn(&init_cb_).Run(status);
return;
}
@@ -321,17 +328,21 @@ void CmaRenderer::InitializeVideoPipeline() {
void CmaRenderer::OnVideoPipelineInitializeDone(
::media::PipelineStatus status) {
DCHECK(thread_checker_.CalledOnValidThread());
+
+ // OnError() may be fired at any time, even before initialization is complete.
+ if (state_ == kError)
+ return;
+
DCHECK_EQ(state_, kUninitialized) << state_;
DCHECK(!init_cb_.is_null());
-
if (status != ::media::PIPELINE_OK) {
has_video_ = false;
- OnError(status);
+ base::ResetAndReturn(&init_cb_).Run(status);
return;
}
CompleteStateTransition(kFlushed);
- base::ResetAndReturn(&init_cb_).Run();
+ base::ResetAndReturn(&init_cb_).Run(::media::PIPELINE_OK);
}
void CmaRenderer::OnEosReached(bool is_audio) {
@@ -423,18 +434,18 @@ void CmaRenderer::OnError(::media::PipelineStatus error) {
DCHECK_NE(::media::PIPELINE_OK, error) << "PIPELINE_OK isn't an error!";
LOG(ERROR) << "CMA error encountered: " << error;
- // Pipeline will destroy |this| as the result of error.
- if (state_ != kError)
- error_cb_.Run(error);
-
+ State old_state = state_;
CompleteStateTransition(kError);
- FireAllPendingCallbacks();
-}
-void CmaRenderer::FireAllPendingCallbacks() {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!init_cb_.is_null())
- base::ResetAndReturn(&init_cb_).Run();
+ if (old_state != kError) {
+ if (!init_cb_.is_null()) {
+ base::ResetAndReturn(&init_cb_).Run(error);
+ return;
+ }
+ error_cb_.Run(error);
+ }
+
+ // After OnError() returns, the pipeline may destroy |this|.
if (!flush_cb_.is_null())
base::ResetAndReturn(&flush_cb_).Run();
}
« no previous file with comments | « chromecast/media/cma/filters/cma_renderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698