Bug 1181204 - Prevent use of the decoder outside the reader's taskqueue. r=cpearce

This fix a potential race when the decoder could be shutting down on the reader's taskqueue while the MediaDecoderStateMachine thread attempts to read it.

--HG--
extra : amend_source : d8a7ac55539c22f69d965299010a20b34c8a4c58
extra : transplant_source : %F6%D2z%A2%40%D1%CE%8BX%FB%9E%CA%2B%ABa%7D%F9%7Fl%BF
This commit is contained in:
Jean-Yves Avenard 2015-07-20 15:14:37 -04:00
Родитель 6ac7016595
Коммит 5d0c759bca
2 изменённых файлов: 9 добавлений и 1 удалений

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

@ -1024,6 +1024,10 @@ MediaFormatReader::Update(TrackType aTrack)
needOutput = true;
if (!decoder.mOutput.IsEmpty()) {
// We have a decoded sample ready to be returned.
if (aTrack == TrackType::kVideoTrack) {
mVideo.mIsHardwareAccelerated =
mVideo.mDecoder && mVideo.mDecoder->IsHardwareAccelerated();
}
nsRefPtr<MediaData> output = decoder.mOutput[0];
decoder.mOutput.RemoveElementAt(0);
decoder.mSizeOfQueue -= 1;
@ -1504,7 +1508,7 @@ MediaFormatReader::SetSharedDecoderManager(SharedDecoderManager* aManager)
bool
MediaFormatReader::VideoIsHardwareAccelerated() const
{
return mVideo.mDecoder && mVideo.mDecoder->IsHardwareAccelerated();
return mVideo.mIsHardwareAccelerated;
}
void

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

@ -203,6 +203,7 @@ private:
, mNumSamplesInput(0)
, mNumSamplesOutput(0)
, mSizeOfQueue(0)
, mIsHardwareAccelerated(false)
, mLastStreamSourceID(UINT32_MAX)
{}
@ -294,6 +295,9 @@ private:
// Used by the MDSM for logging purposes.
Atomic<size_t> mSizeOfQueue;
// Used by the MDSM to determine if video decoding is hardware accelerated.
// This value is updated after a frame is successfully decoded.
Atomic<bool> mIsHardwareAccelerated;
// Sample format monitoring.
uint32_t mLastStreamSourceID;
Maybe<uint32_t> mNextStreamSourceID;