зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1109389 - Don't share task queues with all EMEDecryptors the EME PDM creates. r=kinetik
This commit is contained in:
Родитель
3b9c59eb6d
Коммит
e859dcdb44
|
@ -14,6 +14,8 @@
|
|||
#include "mozilla/Base64.h"
|
||||
#include "nsIRandomGenerator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "MediaTaskQueue.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -269,5 +271,24 @@ GenerateRandomPathName(nsCString& aOutSalt, uint32_t aLength)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
class CreateTaskQueueTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<MediaTaskQueue> mTaskQueue;
|
||||
};
|
||||
|
||||
already_AddRefed<MediaTaskQueue>
|
||||
CreateMediaDecodeTaskQueue()
|
||||
{
|
||||
// We must create the MediaTaskQueue/SharedThreadPool on the main thread.
|
||||
nsRefPtr<CreateTaskQueueTask> t(new CreateTaskQueueTask());
|
||||
nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return t->mTaskQueue.forget();
|
||||
}
|
||||
|
||||
} // end namespace mozilla
|
||||
|
|
|
@ -263,6 +263,11 @@ ExtractH264CodecDetails(const nsAString& aCodecs,
|
|||
nsresult
|
||||
GenerateRandomPathName(nsCString& aOutSalt, uint32_t aLength);
|
||||
|
||||
class MediaTaskQueue;
|
||||
|
||||
already_AddRefed<MediaTaskQueue>
|
||||
CreateMediaDecodeTaskQueue();
|
||||
|
||||
} // end namespace mozilla
|
||||
|
||||
#endif
|
||||
|
|
|
@ -75,26 +75,6 @@ PlatformDecoderModule::Init()
|
|||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
class CreateTaskQueueTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<MediaTaskQueue> mTaskQueue;
|
||||
};
|
||||
|
||||
static already_AddRefed<MediaTaskQueue>
|
||||
CreateTaskQueue()
|
||||
{
|
||||
// We must create the MediaTaskQueue/SharedThreadPool on the main thread.
|
||||
nsRefPtr<CreateTaskQueueTask> t(new CreateTaskQueueTask());
|
||||
nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return t->mTaskQueue.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
PlatformDecoderModule*
|
||||
PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy,
|
||||
|
@ -123,8 +103,7 @@ PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy,
|
|||
return new EMEDecoderModule(aProxy,
|
||||
pdm.forget(),
|
||||
cdmDecodesAudio,
|
||||
cdmDecodesVideo,
|
||||
CreateTaskQueue());
|
||||
cdmDecodesVideo);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/EMELog.h"
|
||||
#include "EMEH264Decoder.h"
|
||||
#include "EMEAudioDecoder.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include <string>
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -31,19 +32,19 @@ public:
|
|||
|
||||
EMEDecryptor(MediaDataDecoder* aDecoder,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
MediaTaskQueue* aTaskQueue,
|
||||
CDMProxy* aProxy)
|
||||
: mDecoder(aDecoder)
|
||||
, mCallback(aCallback)
|
||||
, mTaskQueue(aTaskQueue)
|
||||
, mTaskQueue(CreateMediaDecodeTaskQueue())
|
||||
, mProxy(aProxy)
|
||||
{
|
||||
}
|
||||
|
||||
virtual nsresult Init() MOZ_OVERRIDE {
|
||||
return mTaskQueue->SyncDispatch(
|
||||
NS_NewRunnableMethod(mDecoder,
|
||||
&MediaDataDecoder::Init));
|
||||
nsresult rv = mTaskQueue->SyncDispatch(
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDataDecoder::Init));
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
class RedeliverEncryptedInput : public nsRunnable {
|
||||
|
@ -123,40 +124,44 @@ public:
|
|||
}
|
||||
|
||||
void Decrypted(mp4_demuxer::MP4Sample* aSample) {
|
||||
mTaskQueue->Dispatch(
|
||||
nsresult rv = mTaskQueue->Dispatch(
|
||||
NS_NewRunnableMethodWithArg<mp4_demuxer::MP4Sample*>(
|
||||
mDecoder,
|
||||
&MediaDataDecoder::Input,
|
||||
aSample));
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
|
||||
virtual nsresult Flush() MOZ_OVERRIDE {
|
||||
mTaskQueue->SyncDispatch(
|
||||
nsresult rv = mTaskQueue->SyncDispatch(
|
||||
NS_NewRunnableMethod(
|
||||
mDecoder,
|
||||
&MediaDataDecoder::Flush));
|
||||
return NS_OK;
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
virtual nsresult Drain() MOZ_OVERRIDE {
|
||||
mTaskQueue->Dispatch(
|
||||
nsresult rv = mTaskQueue->Dispatch(
|
||||
NS_NewRunnableMethod(
|
||||
mDecoder,
|
||||
&MediaDataDecoder::Drain));
|
||||
return NS_OK;
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
virtual nsresult Shutdown() MOZ_OVERRIDE {
|
||||
mTaskQueue->SyncDispatch(
|
||||
nsresult rv = mTaskQueue->SyncDispatch(
|
||||
NS_NewRunnableMethod(
|
||||
mDecoder,
|
||||
&MediaDataDecoder::Shutdown));
|
||||
unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
mDecoder = nullptr;
|
||||
mTaskQueue->BeginShutdown();
|
||||
mTaskQueue->AwaitShutdownAndIdle();
|
||||
mTaskQueue = nullptr;
|
||||
mProxy = nullptr;
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -170,11 +175,9 @@ private:
|
|||
EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy,
|
||||
PlatformDecoderModule* aPDM,
|
||||
bool aCDMDecodesAudio,
|
||||
bool aCDMDecodesVideo,
|
||||
already_AddRefed<MediaTaskQueue> aTaskQueue)
|
||||
bool aCDMDecodesVideo)
|
||||
: mProxy(aProxy)
|
||||
, mPDM(aPDM)
|
||||
, mTaskQueue(aTaskQueue)
|
||||
, mCDMDecodesAudio(aCDMDecodesAudio)
|
||||
, mCDMDecodesVideo(aCDMDecodesVideo)
|
||||
{
|
||||
|
@ -190,8 +193,6 @@ EMEDecoderModule::Shutdown()
|
|||
if (mPDM) {
|
||||
return mPDM->Shutdown();
|
||||
}
|
||||
mTaskQueue->BeginShutdown();
|
||||
mTaskQueue->AwaitShutdownAndIdle();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -227,7 +228,6 @@ EMEDecoderModule::CreateVideoDecoder(const VideoDecoderConfig& aConfig,
|
|||
|
||||
nsRefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
|
||||
aCallback,
|
||||
mTaskQueue,
|
||||
mProxy));
|
||||
return emeDecoder.forget();
|
||||
}
|
||||
|
@ -258,7 +258,6 @@ EMEDecoderModule::CreateAudioDecoder(const AudioDecoderConfig& aConfig,
|
|||
|
||||
nsRefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
|
||||
aCallback,
|
||||
mTaskQueue,
|
||||
mProxy));
|
||||
return emeDecoder.forget();
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@ public:
|
|||
EMEDecoderModule(CDMProxy* aProxy,
|
||||
PlatformDecoderModule* aPDM,
|
||||
bool aCDMDecodesAudio,
|
||||
bool aCDMDecodesVideo,
|
||||
already_AddRefed<MediaTaskQueue> aDecodeTaskQueue);
|
||||
bool aCDMDecodesVideo);
|
||||
|
||||
virtual ~EMEDecoderModule();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче