Bug 1145101: Part3. Ensure PDM is shutdown after decoder. r=cpearce

A MediaDataDecoder object can't be used once the PDM that created it is
shutdown.
We ensure that if the PDM is in use by the SharedDecoderManager we do not
shut it down.
This commit is contained in:
Jean-Yves Avenard 2015-03-23 11:12:58 +11:00
Родитель 51d848ba61
Коммит 2a25b5ab4d
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -205,7 +205,10 @@ MP4Reader::Shutdown()
mQueuedVideoSample = nullptr;
if (mPlatform) {
mPlatform->Shutdown();
if (!mSharedDecoderManager ||
!mSharedDecoderManager->IsPDMInUse(mPlatform)) {
mPlatform->Shutdown();
}
mPlatform = nullptr;
}

Просмотреть файл

@ -83,8 +83,10 @@ SharedDecoderManager::CreateVideoDecoder(
mDecoder = aPDM->CreateVideoDecoder(
aConfig, aLayersBackend, aImageContainer, mTaskQueue, mCallback);
if (!mDecoder) {
mPDM = nullptr;
return nullptr;
}
mPDM = aPDM;
nsresult rv = mDecoder->Init();
NS_ENSURE_SUCCESS(rv, nullptr);
}
@ -103,8 +105,10 @@ SharedDecoderManager::Recreate(PlatformDecoderModule* aPDM,
mDecoder->Shutdown();
mDecoder = aPDM->CreateVideoDecoder(aConfig, aLayersBackend, aImageContainer, mTaskQueue, mCallback);
if (!mDecoder) {
mPDM = nullptr;
return false;
}
mPDM = aPDM;
nsresult rv = mDecoder->Init();
return rv == NS_OK;
}
@ -168,6 +172,10 @@ SharedDecoderManager::Shutdown()
mDecoder->Shutdown();
mDecoder = nullptr;
}
if (mPDM) {
mPDM->Shutdown();
mPDM = nullptr;
}
if (mTaskQueue) {
mTaskQueue->BeginShutdown();
mTaskQueue->AwaitShutdownAndIdle();
@ -175,6 +183,12 @@ SharedDecoderManager::Shutdown()
}
}
bool
SharedDecoderManager::IsPDMInUse(const mozilla::PlatformDecoderModule* aPDM) const
{
return aPDM == mPDM;
}
SharedDecoderProxy::SharedDecoderProxy(
SharedDecoderManager* aManager, MediaDataDecoderCallback* aCallback)
: mManager(aManager), mCallback(aCallback)

Просмотреть файл

@ -36,6 +36,7 @@ public:
void SetIdle(MediaDataDecoder* aProxy);
void ReleaseMediaResources();
void Shutdown();
bool IsPDMInUse(const PlatformDecoderModule* aPDM) const;
friend class SharedDecoderProxy;
friend class SharedDecoderCallback;
@ -49,6 +50,7 @@ private:
virtual ~SharedDecoderManager();
void DrainComplete();
nsRefPtr<PlatformDecoderModule> mPDM;
nsRefPtr<MediaDataDecoder> mDecoder;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
SharedDecoderProxy* mActiveProxy;