Bug 1827142. r=media-playback-reviewers,alwu a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D175017
This commit is contained in:
Andrew Osmond 2024-11-23 01:14:34 +00:00
parent 27abdb2cd7
commit 2befada946
3 changed files with 16 additions and 9 deletions

View file

@ -20,6 +20,7 @@ RefPtr<WMFCDMImpl::InitPromise> WMFCDMImpl::Init(
const WMFCDMImpl::InitParams& aParams) { const WMFCDMImpl::InitParams& aParams) {
if (!mCDM) { if (!mCDM) {
mCDM = MakeRefPtr<MFCDMChild>(mKeySystem); mCDM = MakeRefPtr<MFCDMChild>(mKeySystem);
mCDM->EnsureRemote();
} }
RefPtr<WMFCDMImpl> self = this; RefPtr<WMFCDMImpl> self = this;
mCDM->Init(aParams.mOrigin, aParams.mInitDataTypes, mCDM->Init(aParams.mOrigin, aParams.mInitDataTypes,
@ -58,6 +59,7 @@ WMFCDMCapabilites::GetCapabilities(
nsTArray<RefPtr<CapabilitiesPromise>> promises; nsTArray<RefPtr<CapabilitiesPromise>> promises;
for (const auto& request : aRequests) { for (const auto& request : aRequests) {
RefPtr<MFCDMChild> cdm = new MFCDMChild(request.mKeySystem); RefPtr<MFCDMChild> cdm = new MFCDMChild(request.mKeySystem);
cdm->EnsureRemote();
promises.AppendElement(cdm->GetCapabilities(MFCDMCapabilitiesRequest{ promises.AppendElement(cdm->GetCapabilities(MFCDMCapabilitiesRequest{
nsString{request.mKeySystem}, nsString{request.mKeySystem},
request.mDecryption == KeySystemConfig::DecryptionInfo::Hardware, request.mDecryption == KeySystemConfig::DecryptionInfo::Hardware,

View file

@ -73,19 +73,25 @@ MFCDMChild::MFCDMChild(const nsAString& aKeySystem)
: mKeySystem(aKeySystem), : mKeySystem(aKeySystem),
mManagerThread(RemoteDecoderManagerChild::GetManagerThread()), mManagerThread(RemoteDecoderManagerChild::GetManagerThread()),
mState(NS_ERROR_NOT_INITIALIZED), mState(NS_ERROR_NOT_INITIALIZED),
mShutdown(false) { mShutdown(false) {}
mRemotePromise = EnsureRemote();
}
MFCDMChild::~MFCDMChild() {} MFCDMChild::~MFCDMChild() {}
RefPtr<MFCDMChild::RemotePromise> MFCDMChild::EnsureRemote() { void MFCDMChild::EnsureRemote() {
if (mRemotePromise) {
LOG("already created remote promise");
return;
}
if (!mManagerThread) { if (!mManagerThread) {
LOG("no manager thread"); LOG("no manager thread");
mState = NS_ERROR_NOT_AVAILABLE; mState = NS_ERROR_NOT_AVAILABLE;
return RemotePromise::CreateAndReject(mState, __func__); mRemotePromise = RemotePromise::CreateAndReject(mState, __func__);
return;
} }
mRemotePromise = mRemotePromiseHolder.Ensure(__func__);
RefPtr<MFCDMChild> self = this; RefPtr<MFCDMChild> self = this;
RemoteDecoderManagerChild::LaunchUtilityProcessIfNeeded( RemoteDecoderManagerChild::LaunchUtilityProcessIfNeeded(
RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM) RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM)
@ -115,7 +121,6 @@ RefPtr<MFCDMChild::RemotePromise> MFCDMChild::EnsureRemote() {
mRemotePromiseHolder.RejectIfExists(rv, __func__); mRemotePromiseHolder.RejectIfExists(rv, __func__);
}) })
->Track(mRemoteRequest); ->Track(mRemoteRequest);
return mRemotePromiseHolder.Ensure(__func__);
} }
void MFCDMChild::Shutdown() { void MFCDMChild::Shutdown() {

View file

@ -85,6 +85,8 @@ class MFCDMChild final : public PMFCDMChild {
mState = NS_ERROR_NOT_AVAILABLE; mState = NS_ERROR_NOT_AVAILABLE;
} }
} }
void EnsureRemote();
void Shutdown(); void Shutdown();
nsISerialEventTarget* ManagerThread() { return mManagerThread; } nsISerialEventTarget* ManagerThread() { return mManagerThread; }
@ -95,9 +97,6 @@ class MFCDMChild final : public PMFCDMChild {
private: private:
~MFCDMChild(); ~MFCDMChild();
using RemotePromise = GenericNonExclusivePromise;
RefPtr<RemotePromise> EnsureRemote();
void AssertSendable(); void AssertSendable();
const nsString mKeySystem; const nsString mKeySystem;
@ -105,6 +104,7 @@ class MFCDMChild final : public PMFCDMChild {
const RefPtr<nsISerialEventTarget> mManagerThread; const RefPtr<nsISerialEventTarget> mManagerThread;
RefPtr<MFCDMChild> mIPDLSelfRef; RefPtr<MFCDMChild> mIPDLSelfRef;
using RemotePromise = GenericNonExclusivePromise;
RefPtr<RemotePromise> mRemotePromise; RefPtr<RemotePromise> mRemotePromise;
MozPromiseHolder<RemotePromise> mRemotePromiseHolder; MozPromiseHolder<RemotePromise> mRemotePromiseHolder;
MozPromiseRequestHolder<RemotePromise> mRemoteRequest; MozPromiseRequestHolder<RemotePromise> mRemoteRequest;