From 4c421503a8842be1d3e280b03ff95758180bfb19 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 8 Mar 2017 10:20:33 +1300 Subject: [PATCH] Bug 1315850 - Shutdown CDMVideoDecoder. r=jya This severs the ChromiumCDMVideoDecoder's connection with the CDM. The CDM process will shutdown when the MediaKeys also severs its connection. MozReview-Commit-ID: Aqc4y5Nxjvc --HG-- extra : rebase_source : 5a2f77ffe84f9b99b4668520c838b29a428578d3 --- dom/media/gmp/ChromiumCDMParent.cpp | 13 +++++++++++++ dom/media/gmp/ChromiumCDMParent.h | 2 ++ .../agnostic/eme/ChromiumCDMVideoDecoder.cpp | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index 5a8f5d2bc58f..19c9ead58a5f 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -626,5 +626,18 @@ ChromiumCDMParent::RecvDrainComplete() mDecodePromise.ResolveIfExists(MediaDataDecoder::DecodedData(), __func__); return IPC_OK(); } +RefPtr +ChromiumCDMParent::ShutdownVideoDecoder() +{ + mInitVideoDecoderPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, + __func__); + MOZ_ASSERT(mDecodePromise.IsEmpty()); + MOZ_ASSERT(mFlushDecoderPromise.IsEmpty()); + if (!SendDeinitializeVideoDecoder()) { + return ShutdownPromise::CreateAndResolve(true, __func__); + } + return ShutdownPromise::CreateAndResolve(true, __func__); +} + } // namespace gmp } // namespace mozilla diff --git a/dom/media/gmp/ChromiumCDMParent.h b/dom/media/gmp/ChromiumCDMParent.h index fe6875d2df66..64ee30005ee1 100644 --- a/dom/media/gmp/ChromiumCDMParent.h +++ b/dom/media/gmp/ChromiumCDMParent.h @@ -73,6 +73,8 @@ public: RefPtr Drain(); + RefPtr ShutdownVideoDecoder(); + protected: ~ChromiumCDMParent() {} diff --git a/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp b/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp index bc5dc4ac053b..01f1bf4456b9 100644 --- a/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp +++ b/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp @@ -134,7 +134,15 @@ ChromiumCDMVideoDecoder::Drain() RefPtr ChromiumCDMVideoDecoder::Shutdown() { - return ShutdownPromise::CreateAndResolve(true, __func__); + if (!mCDMParent) { + // Must have failed to get the CDMParent from the ChromiumCDMProxy + // in our constructor; the MediaKeys must have shut down the CDM + // before we had a chance to start up the decoder. + return ShutdownPromise::CreateAndResolve(true, __func__); + } + RefPtr cdm = mCDMParent; + return InvokeAsync( + mGMPThread, __func__, [cdm]() { return cdm->ShutdownVideoDecoder(); }); } } // namespace mozilla