From 0b0b95405156089a0413e05ebb705359af988bc6 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Fri, 19 Sep 2014 15:44:27 +1200 Subject: [PATCH] Bug 1068996 - Make WMFMediaDataDecoder::Shutdown() actually shutdown. r=kentuckyfriedtakahe --- content/media/fmp4/wmf/WMFAudioMFTManager.cpp | 6 ++++++ content/media/fmp4/wmf/WMFAudioMFTManager.h | 3 +++ content/media/fmp4/wmf/WMFMediaDataDecoder.cpp | 10 +++++++++- content/media/fmp4/wmf/WMFMediaDataDecoder.h | 5 +++++ content/media/fmp4/wmf/WMFVideoMFTManager.cpp | 6 ++++++ content/media/fmp4/wmf/WMFVideoMFTManager.h | 2 ++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/content/media/fmp4/wmf/WMFAudioMFTManager.cpp b/content/media/fmp4/wmf/WMFAudioMFTManager.cpp index e12af14a98d4..a22bb8d2d163 100644 --- a/content/media/fmp4/wmf/WMFAudioMFTManager.cpp +++ b/content/media/fmp4/wmf/WMFAudioMFTManager.cpp @@ -308,4 +308,10 @@ WMFAudioMFTManager::Output(int64_t aStreamOffset, return S_OK; } +void +WMFAudioMFTManager::Shutdown() +{ + mDecoder = nullptr; +} + } // namespace mozilla diff --git a/content/media/fmp4/wmf/WMFAudioMFTManager.h b/content/media/fmp4/wmf/WMFAudioMFTManager.h index 130cc57dcdb8..f9b78b3d6230 100644 --- a/content/media/fmp4/wmf/WMFAudioMFTManager.h +++ b/content/media/fmp4/wmf/WMFAudioMFTManager.h @@ -29,6 +29,9 @@ public: // a null aOutput in this case. virtual HRESULT Output(int64_t aStreamOffset, nsAutoPtr& aOutput) MOZ_OVERRIDE; + + virtual void Shutdown() MOZ_OVERRIDE; + private: HRESULT UpdateOutputType(); diff --git a/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp b/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp index 04fddeb63801..e0569986f365 100644 --- a/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp +++ b/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp @@ -48,10 +48,18 @@ WMFMediaDataDecoder::Init() nsresult WMFMediaDataDecoder::Shutdown() { - mDecoder = nullptr; + mTaskQueue->FlushAndDispatch(NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown)); return NS_OK; } +void +WMFMediaDataDecoder::ProcessShutdown() +{ + mMFTManager->Shutdown(); + mMFTManager = nullptr; + mDecoder = nullptr; +} + // Inserts data into the decoder's pipeline. nsresult WMFMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample) diff --git a/content/media/fmp4/wmf/WMFMediaDataDecoder.h b/content/media/fmp4/wmf/WMFMediaDataDecoder.h index 71630db80c0a..1d0d17a5e23e 100644 --- a/content/media/fmp4/wmf/WMFMediaDataDecoder.h +++ b/content/media/fmp4/wmf/WMFMediaDataDecoder.h @@ -43,6 +43,9 @@ public: // MP4Reader. virtual HRESULT Output(int64_t aStreamOffset, nsAutoPtr& aOutput) = 0; + + // Destroys all resources. + virtual void Shutdown() = 0; }; // Decodes audio and video using Windows Media Foundation. Samples are decoded @@ -81,6 +84,8 @@ private: // all available output. void ProcessDrain(); + void ProcessShutdown(); + RefPtr mTaskQueue; MediaDataDecoderCallback* mCallback; diff --git a/content/media/fmp4/wmf/WMFVideoMFTManager.cpp b/content/media/fmp4/wmf/WMFVideoMFTManager.cpp index 0cabf8286bbb..01f727e65772 100644 --- a/content/media/fmp4/wmf/WMFVideoMFTManager.cpp +++ b/content/media/fmp4/wmf/WMFVideoMFTManager.cpp @@ -399,4 +399,10 @@ WMFVideoMFTManager::Output(int64_t aStreamOffset, return S_OK; } +void +WMFVideoMFTManager::Shutdown() +{ + mDecoder = nullptr; +} + } // namespace mozilla diff --git a/content/media/fmp4/wmf/WMFVideoMFTManager.h b/content/media/fmp4/wmf/WMFVideoMFTManager.h index 259d6bfd2bb3..61df8ed46861 100644 --- a/content/media/fmp4/wmf/WMFVideoMFTManager.h +++ b/content/media/fmp4/wmf/WMFVideoMFTManager.h @@ -33,6 +33,8 @@ public: virtual HRESULT Output(int64_t aStreamOffset, nsAutoPtr& aOutput) MOZ_OVERRIDE; + virtual void Shutdown() MOZ_OVERRIDE; + private: bool InitializeDXVA();