From 5d0c759bcabae028a800a1ea62f5ed360e737845 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 20 Jul 2015 15:14:37 -0400 Subject: [PATCH] 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 --- dom/media/MediaFormatReader.cpp | 6 +++++- dom/media/MediaFormatReader.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index bd53a11325dc..0a74b8def798 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -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 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 diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index d0d0a454484f..739d99b8f560 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -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 mSizeOfQueue; + // Used by the MDSM to determine if video decoding is hardware accelerated. + // This value is updated after a frame is successfully decoded. + Atomic mIsHardwareAccelerated; // Sample format monitoring. uint32_t mLastStreamSourceID; Maybe mNextStreamSourceID;