Bug 878449 - Fixed mismatched CoInitialize call causing crash in JumpList. r=padenot.

This commit is contained in:
Brian R. Bondy 2013-06-20 08:57:46 -04:00
parent 867dc5785d
commit 07fdbc24d3
2 changed files with 14 additions and 4 deletions

View File

@ -54,7 +54,8 @@ WMFReader::WMFReader(AbstractMediaDecoder* aDecoder)
mHasVideo(false),
mUseHwAccel(false),
mMustRecaptureAudioPosition(true),
mIsMP3Enabled(WMFDecoder::IsMP3Supported())
mIsMP3Enabled(WMFDecoder::IsMP3Supported()),
mCOMInitialized(false)
{
NS_ASSERTION(NS_IsMainThread(), "Must be on main thread.");
MOZ_COUNT_CTOR(WMFReader);
@ -79,15 +80,22 @@ void
WMFReader::OnDecodeThreadStart()
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
NS_ENSURE_TRUE_VOID(SUCCEEDED(hr));
// XXX WebAudio will call this on the main thread so CoInit will definitely
// fail. You cannot change the concurrency model once already set.
// The main thread will continue to be STA, which seems to work, but MSDN
// recommends that MTA be used.
mCOMInitialized = SUCCEEDED(CoInitializeEx(0, COINIT_MULTITHREADED));
NS_ENSURE_TRUE_VOID(mCOMInitialized);
}
void
WMFReader::OnDecodeThreadFinish()
{
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
CoUninitialize();
if (mCOMInitialized) {
CoUninitialize();
}
}
bool

View File

@ -115,6 +115,8 @@ private:
// checks a pref, so we cache its value in mIsMP3Enabled and use that on
// the decode thread.
const bool mIsMP3Enabled;
bool mCOMInitialized;
};
} // namespace mozilla