diff --git a/content/media/wmf/WMFDecoder.cpp b/content/media/wmf/WMFDecoder.cpp index 9674b430cacc..8b4a101fadc8 100644 --- a/content/media/wmf/WMFDecoder.cpp +++ b/content/media/wmf/WMFDecoder.cpp @@ -25,6 +25,7 @@ MediaDecoderStateMachine* WMFDecoder::CreateStateMachine() bool WMFDecoder::IsMP3Supported() { + MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); if (!MediaDecoder::IsWMFEnabled()) { return false; } diff --git a/content/media/wmf/WMFReader.cpp b/content/media/wmf/WMFReader.cpp index 8b112ef5685e..6991b46b9333 100644 --- a/content/media/wmf/WMFReader.cpp +++ b/content/media/wmf/WMFReader.cpp @@ -40,7 +40,8 @@ WMFReader::WMFReader(AbstractMediaDecoder* aDecoder) mVideoStride(0), mHasAudio(false), mHasVideo(false), - mCanSeek(false) + mCanSeek(false), + mIsMP3Enabled(WMFDecoder::IsMP3Supported()) { NS_ASSERTION(NS_IsMainThread(), "Must be on main thread."); MOZ_COUNT_CTOR(WMFReader); @@ -388,13 +389,13 @@ WMFReader::ConfigureVideoDecoder() return S_OK; } -static void -GetSupportedAudioCodecs(const GUID** aCodecs, uint32_t* aNumCodecs) +void +WMFReader::GetSupportedAudioCodecs(const GUID** aCodecs, uint32_t* aNumCodecs) { MOZ_ASSERT(aCodecs); MOZ_ASSERT(aNumCodecs); - if (WMFDecoder::IsMP3Supported()) { + if (mIsMP3Enabled) { static const GUID codecs[] = { MFAudioFormat_AAC, MFAudioFormat_MP3 diff --git a/content/media/wmf/WMFReader.h b/content/media/wmf/WMFReader.h index 5c9919c90658..df994375913a 100644 --- a/content/media/wmf/WMFReader.h +++ b/content/media/wmf/WMFReader.h @@ -55,6 +55,7 @@ private: HRESULT ConfigureAudioDecoder(); HRESULT ConfigureVideoDecoder(); HRESULT ConfigureVideoFrameGeometry(IMFMediaType* aMediaType); + void GetSupportedAudioCodecs(const GUID** aCodecs, uint32_t* aNumCodecs); RefPtr mSourceReader; RefPtr mByteStream; @@ -74,6 +75,11 @@ private: bool mHasAudio; bool mHasVideo; bool mCanSeek; + + // We can't call WMFDecoder::IsMP3Supported() on non-main threads, since it + // checks a pref, so we cache its value in mIsMP3Enabled and use that on + // the decode thread. + const bool mIsMP3Enabled; }; } // namespace mozilla