Bug 1147730 part 1 - Prevent data race between CDMProxy and CDM caps and video decoder startup. r=edwin

This commit is contained in:
Chris Pearce 2015-03-26 19:53:05 +13:00
parent 7aeed01333
commit 70f880c263
2 changed files with 26 additions and 5 deletions

View File

@ -305,6 +305,18 @@ MediaSourceDecoder::SetCDMProxy(CDMProxy* aProxy)
rv = mReader->SetCDMProxy(aProxy);
NS_ENSURE_SUCCESS(rv, rv);
{
// The sub readers can't decrypt EME content until they have a CDMProxy,
// and the CDMProxy knows the capabilities of the CDM. The MediaSourceReader
// remains in "waiting for resources" state until then. We need to kick the
// reader out of waiting if the CDM gets added with known capabilities.
CDMCaps::AutoLock caps(aProxy->Capabilites());
if (!caps.AreCapsKnown()) {
nsCOMPtr<nsIRunnable> task(
NS_NewRunnableMethod(this, &MediaDecoder::NotifyWaitingForResourcesStatusChanged));
caps.CallOnMainThreadWhenCapsAvailable(task);
}
}
return NS_OK;
}
#endif

View File

@ -97,13 +97,22 @@ MediaSourceReader::IsWaitingOnCDMResource()
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
MOZ_ASSERT(!IsWaitingMediaResources());
for (auto& trackBuffer : mTrackBuffers) {
if (trackBuffer->IsWaitingOnCDMResource()) {
return true;
}
if (!mInfo.IsEncrypted()) {
return false;
}
// We'll need to wait on the CDMProxy being added, and it having received
// notification from the child GMP of its capabilities; whether it can
// decode, or whether we need to decode on our side.
if (!mCDMProxy) {
return true;
}
{
CDMCaps::AutoLock caps(mCDMProxy->Capabilites());
return !caps.AreCapsKnown();
}
return mInfo.IsEncrypted() && !mCDMProxy;
#else
return false;
#endif