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
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -621,10 +621,23 @@ ChromiumCDMParent::Drain()
}
ipc::IPCResult
ChromiumCDMParent::RecvDrainComplete()
{
mDecodePromise.ResolveIfExists(MediaDataDecoder::DecodedData(), __func__);
return IPC_OK();
}
+RefPtr<ShutdownPromise>
+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
--- a/dom/media/gmp/ChromiumCDMParent.h
+++ b/dom/media/gmp/ChromiumCDMParent.h
@@ -68,16 +68,18 @@ public:
RefPtr<MediaDataDecoder::DecodePromise> DecryptAndDecodeFrame(
MediaRawData* aSample);
RefPtr<MediaDataDecoder::FlushPromise> FlushVideoDecoder();
RefPtr<MediaDataDecoder::DecodePromise> Drain();
+ RefPtr<ShutdownPromise> ShutdownVideoDecoder();
+
protected:
~ChromiumCDMParent() {}
ipc::IPCResult Recv__delete__() override;
ipc::IPCResult RecvOnResolveNewSessionPromise(
const uint32_t& aPromiseId,
const nsCString& aSessionId) override;
ipc::IPCResult RecvOnResolvePromise(const uint32_t& aPromiseId) override;
--- a/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp
+++ b/dom/media/platforms/agnostic/eme/ChromiumCDMVideoDecoder.cpp
@@ -129,12 +129,20 @@ ChromiumCDMVideoDecoder::Drain()
MOZ_ASSERT(mCDMParent);
RefPtr<gmp::ChromiumCDMParent> cdm = mCDMParent;
return InvokeAsync(mGMPThread, __func__, [cdm]() { return cdm->Drain(); });
}
RefPtr<ShutdownPromise>
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<gmp::ChromiumCDMParent> cdm = mCDMParent;
+ return InvokeAsync(
+ mGMPThread, __func__, [cdm]() { return cdm->ShutdownVideoDecoder(); });
}
} // namespace mozilla