Bug 1047824 - Call PlatformDecoderModule::Shutdown() in MP4Reader::Shutdown() on the decode task queue. r=kinetik

This commit is contained in:
Chris Pearce 2014-08-03 19:28:39 +12:00
parent 9991c6dfee
commit 4b33c80b1c
6 changed files with 21 additions and 17 deletions

View File

@ -142,6 +142,11 @@ MP4Reader::Shutdown()
}
// Dispose of the queued sample before shutting down the demuxer
mQueuedVideoSample = nullptr;
if (mPlatform) {
mPlatform->Shutdown();
mPlatform = nullptr;
}
}
void

View File

@ -60,13 +60,12 @@ public:
virtual nsresult ResetDecode() MOZ_OVERRIDE;
virtual void Shutdown() MOZ_OVERRIDE;
private:
void ExtractCryptoInitData(nsTArray<uint8_t>& aInitData);
// Destroys all decoder resources.
void Shutdown();
// Initializes mLayersBackendType if possible.
void InitLayersBackendType();

View File

@ -109,6 +109,9 @@ PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy,
PlatformDecoderModule*
PlatformDecoderModule::Create()
{
// Note: This runs on the decode thread.
MOZ_ASSERT(!NS_IsMainThread());
if (sUseBlankDecoder) {
return CreateBlankDecoderModule();
}

View File

@ -63,23 +63,24 @@ public:
// instance. It's expected that there will be multiple
// PlatformDecoderModules alive at the same time. There is one
// PlatformDecoderModule created per MP4Reader.
// This is called on the decode thread.
// This is called on the decode task queue.
static PlatformDecoderModule* Create();
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
// decrypt-and-decode EME encrypted content. If the CDM only decrypts and
// does not decode, we create a PDM and use that to create MediaDataDecoders
// that we use on on aTaskQueue to decode the decrypted stream.
// This is called on the decode task queue.
static PlatformDecoderModule* CreateCDMWrapper(CDMProxy* aProxy,
bool aHasAudio,
bool aHasVideo,
MediaTaskQueue* aTaskQueue);
// Called to shutdown the decoder module and cleanup state. This should
// block until shutdown is complete. This is called after Shutdown() has
// been called on all MediaDataDecoders created from this
// PlatformDecoderModule.
// Called on the main thread only.
// Called to shutdown the decoder module and cleanup state. The PDM
// is deleted immediately after Shutdown() is called. Shutdown() is
// called after Shutdown() has been called on all MediaDataDecoders
// created from this PlatformDecoderModule.
// This is called on the decode task queue.
virtual nsresult Shutdown() = 0;
// Creates an H.264 decoder. The layers backend is passed in so that
@ -92,7 +93,7 @@ public:
// COINIT_MULTITHREADED.
// Returns nullptr if the decoder can't be created.
// It is safe to store a reference to aConfig.
// Called on decode thread.
// This is called on the decode task queue.
virtual already_AddRefed<MediaDataDecoder>
CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
@ -109,7 +110,7 @@ public:
// On Windows the task queue's threads in have MSCOM initialized with
// COINIT_MULTITHREADED.
// It is safe to store a reference to aConfig.
// Called on decode thread.
// This is called on the decode task queue.
virtual already_AddRefed<MediaDataDecoder>
CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,

View File

@ -184,7 +184,6 @@ EMEDecoderModule::~EMEDecoderModule()
nsresult
EMEDecoderModule::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
if (mPDM) {
return mPDM->Shutdown();
}

View File

@ -17,14 +17,11 @@ public:
virtual ~WMFDecoderModule();
// Initializes the module, loads required dynamic libraries, etc.
// Main thread only.
nsresult Startup();
// Called when the decoders have shutdown. Main thread only.
// Does this really need to be main thread only????
// Called when the decoders have shutdown.
virtual nsresult Shutdown() MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
@ -32,12 +29,12 @@ public:
MediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Called on main thread.
static void Init();
private:
static bool sIsWMFEnabled;