WMFClearKeyCDM::RuntimeClassInitialize was building its own WMFPMPServer (and therefore its own in-process IMFMediaSession, via MFCreatePMPMediaSession(MFPMPSESSION_IN_PROCESS, ...)) per CDM instance. Under mochitest-media-wmfme on Windows code-coverage builds, tests create several WMFClearKey CDMs in quick succession, and MFCreatePMPMediaSession eventually starts returning MF_E_SHUTDOWN (0xC00D3E85) even with a proper IMFMediaSession::Shutdown() on each released session - evidently some process-wide MF state for in-process PMP sessions accumulates and isn't released by per-session teardown. The failure surfaced in test_eme_request_notifications.html (and test_eme_setMediaKeys_before_attach_MediaSource.html) as "WMFCDMProxy::Init: WMFCDM init error" with the test hanging on an unresolved observer until the 370s harness timeout. Side-step the MF-side limitation: WMFPMPServer exists purely to satisfy the Media Engine's in-process PMP query path (clearkey itself doesn't actually need PMP), and none of its callers mutate it. Cache a single process-wide instance behind a GetOrCreateSharedPMPServer accessor in WMFClearKeyCDM.cpp; GetService() fetches it on demand, so the CDM holds no mPMPServer member. MFCreatePMPMediaSession is now called at most once per utility-process lifetime. Add WMFPMPServer::Shutdown() that explicitly calls mMediaSession->Shutdown() before releasing ComPtrs, satisfying the IMFMediaSession lifecycle contract. ~WMFPMPServer() calls Shutdown(), so static destruction of the function-local singleton at DLL unload tears the session down cleanly. Differential Revision: https://phabricator.services.mozilla.com/D296409
80 lines
2.2 KiB
C++
80 lines
2.2 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "WMFPMPServer.h"
|
|
|
|
#include <mfapi.h>
|
|
#include <mferror.h>
|
|
|
|
#include "WMFClearKeyUtils.h"
|
|
|
|
namespace mozilla {
|
|
|
|
using Microsoft::WRL::ComPtr;
|
|
using Microsoft::WRL::MakeAndInitialize;
|
|
|
|
HRESULT WMFPMPServer::RuntimeClassInitialize(
|
|
ABI::Windows::Foundation::Collections::IPropertySet* aPropertyPmp) {
|
|
ENTRY_LOG();
|
|
mPropertyPmp = aPropertyPmp;
|
|
RETURN_IF_FAILED(MFCreatePMPMediaSession(MFPMPSESSION_IN_PROCESS, nullptr,
|
|
&mMediaSession, nullptr));
|
|
RETURN_IF_FAILED(MFGetService(mMediaSession.Get(), MF_PMP_SERVER_CONTEXT,
|
|
IID_PPV_ARGS(&mPmpServer)));
|
|
RETURN_IF_FAILED(MFGetService(mMediaSession.Get(), MF_PMP_SERVICE,
|
|
IID_PPV_ARGS(&mPmpHost)));
|
|
return S_OK;
|
|
}
|
|
|
|
void WMFPMPServer::Shutdown() {
|
|
ENTRY_LOG();
|
|
if (mMediaSession) {
|
|
mMediaSession->Shutdown();
|
|
}
|
|
mPmpHost.Reset();
|
|
mPmpServer.Reset();
|
|
mMediaSession.Reset();
|
|
mPropertyPmp.Reset();
|
|
}
|
|
|
|
STDMETHODIMP WMFPMPServer::GetIids(ULONG* aIidCount, IID** aIids) {
|
|
NOT_IMPLEMENTED();
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
STDMETHODIMP WMFPMPServer::GetRuntimeClassName(
|
|
_COM_Outptr_ HSTRING* aClassName) {
|
|
NOT_IMPLEMENTED();
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
STDMETHODIMP WMFPMPServer::GetTrustLevel(TrustLevel* aTrustLevel) {
|
|
NOT_IMPLEMENTED();
|
|
return E_NOTIMPL;
|
|
}
|
|
STDMETHODIMP WMFPMPServer::get_Properties(
|
|
ABI::Windows::Foundation::Collections::IPropertySet** aPpProperties) {
|
|
ENTRY_LOG();
|
|
RETURN_IF_FAILED(mPropertyPmp.CopyTo(aPpProperties));
|
|
return S_OK;
|
|
}
|
|
|
|
STDMETHODIMP WMFPMPServer::GetService(REFGUID aGuidService, REFIID aRiid,
|
|
LPVOID* aObject) {
|
|
ENTRY_LOG();
|
|
if (!aObject) {
|
|
return E_POINTER;
|
|
}
|
|
if (aGuidService == MF_PMP_SERVER_CONTEXT) {
|
|
RETURN_IF_FAILED(mPmpServer.CopyTo(aRiid, aObject));
|
|
} else if (aGuidService == MF_PMP_SERVICE && aRiid == IID_IMFPMPHost) {
|
|
RETURN_IF_FAILED(mPmpHost.CopyTo(aRiid, aObject));
|
|
} else {
|
|
RETURN_IF_FAILED(MF_E_UNSUPPORTED_SERVICE);
|
|
}
|
|
return S_OK;
|
|
}
|
|
|
|
} // namespace mozilla
|