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

Unified Diff: chromecast/media/cma/pipeline/av_pipeline_impl.cc

Issue 2361103002: [Chromecast] Make sure that Stop() stops buffer decryption (Closed)
Patch Set: fix formatting Created 4 years, 3 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/pipeline/av_pipeline_impl.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/pipeline/av_pipeline_impl.cc
diff --git a/chromecast/media/cma/pipeline/av_pipeline_impl.cc b/chromecast/media/cma/pipeline/av_pipeline_impl.cc
index 808a56ba91a20484f12f5a942a58e506b64c8706..fe4110c7b8bc33f2330ea2c18f087981cae28484 100644
--- a/chromecast/media/cma/pipeline/av_pipeline_impl.cc
+++ b/chromecast/media/cma/pipeline/av_pipeline_impl.cc
@@ -47,7 +47,8 @@ AvPipelineImpl::AvPipelineImpl(MediaPipelineBackend::Decoder* decoder,
pending_read_(false),
cast_cdm_context_(NULL),
player_tracker_callback_id_(kNoCallbackId),
- weak_factory_(this) {
+ weak_factory_(this),
+ decrypt_weak_factory_(this) {
DCHECK(decoder_);
decoder_->SetDelegate(this);
weak_this_ = weak_factory_.GetWeakPtr();
@@ -147,6 +148,13 @@ void AvPipelineImpl::Stop() {
CMALOG(kLogControl) << __FUNCTION__;
// Stop feeding the pipeline.
enable_feeding_ = false;
+ // Drop any pending asynchronous decryption, so any pending
+ // OnBufferDecrypted() callback will not be called. StartPlayingFrom() sets
+ // enable_feeding_ back to true, so if a pending decryption callback from
+ // before Stop() is allowed to complete after StartPlayingFrom() is called
+ // again, it will think everything is fine and try to push a buffer, resulting
+ // in a double push.
+ decrypt_weak_factory_.InvalidateWeakPtrs();
set_state(kStopped);
}
@@ -235,10 +243,10 @@ void AvPipelineImpl::ProcessPendingBuffer() {
if (decrypt_context->CanDecryptToBuffer()) {
auto buffer = pending_buffer_;
pending_buffer_ = nullptr;
- DecryptDecoderBuffer(
- buffer, decrypt_context.get(),
- base::Bind(&AvPipelineImpl::OnBufferDecrypted, weak_this_,
- base::Passed(&decrypt_context)));
+ DecryptDecoderBuffer(buffer, decrypt_context.get(),
+ base::Bind(&AvPipelineImpl::OnBufferDecrypted,
+ decrypt_weak_factory_.GetWeakPtr(),
+ base::Passed(&decrypt_context)));
return;
}
« no previous file with comments | « chromecast/media/cma/pipeline/av_pipeline_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698