From 1e59442474da4d5a5773ddfb06d6c64e6a6ebb34 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 26 Aug 2015 22:09:40 -0700 Subject: [PATCH] Back out 30a8392db2c2 (bug 1198094) for mQueuedSamples assertion failures --- dom/media/platforms/apple/AppleVDADecoder.cpp | 34 +++++-------------- dom/media/platforms/apple/AppleVDADecoder.h | 5 --- dom/media/platforms/apple/AppleVTDecoder.cpp | 17 +++++----- 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/dom/media/platforms/apple/AppleVDADecoder.cpp b/dom/media/platforms/apple/AppleVDADecoder.cpp index a1ac4590913a..c75105061f0c 100644 --- a/dom/media/platforms/apple/AppleVDADecoder.cpp +++ b/dom/media/platforms/apple/AppleVDADecoder.cpp @@ -44,7 +44,6 @@ AppleVDADecoder::AppleVDADecoder(const VideoInfo& aConfig, , mIsShutDown(false) , mUseSoftwareImages(false) , mIs106(!nsCocoaFeatures::OnLionOrLater()) - , mQueuedSamples(0) , mMonitor("AppleVideoDecoder") , mIsFlushing(false) , mDecoder(nullptr) @@ -214,13 +213,15 @@ PlatformCallback(void* decompressionOutputRefCon, // FIXME: Distinguish between errors and empty flushed frames. if (status != noErr || !image) { NS_WARNING("AppleVDADecoder decoder returned no data"); - image = nullptr; - } else if (infoFlags & kVDADecodeInfo_FrameDropped) { + return; + } + MOZ_ASSERT(CFGetTypeID(image) == CVPixelBufferGetTypeID(), + "AppleVDADecoder returned an unexpected image type"); + + if (infoFlags & kVDADecodeInfo_FrameDropped) + { NS_WARNING(" ...frame dropped..."); - image = nullptr; - } else { - MOZ_ASSERT(image || CFGetTypeID(image) == CVPixelBufferGetTypeID(), - "AppleVDADecoder returned an unexpected image type"); + return; } AppleVDADecoder* decoder = @@ -277,7 +278,6 @@ AppleVDADecoder::DrainReorderedFrames() while (!mReorderQueue.IsEmpty()) { mCallback->Output(mReorderQueue.Pop().get()); } - mQueuedSamples = 0; } void @@ -286,7 +286,6 @@ AppleVDADecoder::ClearReorderedFrames() while (!mReorderQueue.IsEmpty()) { mReorderQueue.Pop(); } - mQueuedSamples = 0; } // Copy and return a decoded frame. @@ -309,19 +308,6 @@ AppleVDADecoder::OutputFrame(CFRefPtr aImage, aFrameRef.is_sync_point ? " keyframe" : "" ); - if (mQueuedSamples > mMaxRefFrames) { - // We had stopped requesting more input because we had received too much at - // the time. We can ask for more once again. - mCallback->InputExhausted(); - } - MOZ_ASSERT(mQueuedSamples); - mQueuedSamples--; - - if (!aImage) { - // Image was dropped by decoder. - return NS_OK; - } - // Where our resulting image will end up. nsRefPtr data; // Bounds. @@ -485,8 +471,6 @@ AppleVDADecoder::SubmitFrame(MediaRawData* aSample) &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - mQueuedSamples++; - OSStatus rv = VDADecoderDecode(mDecoder, 0, block, @@ -510,7 +494,7 @@ AppleVDADecoder::SubmitFrame(MediaRawData* aSample) } // Ask for more data. - if (!mInputIncoming && mQueuedSamples <= mMaxRefFrames) { + if (!mInputIncoming) { LOG("AppleVDADecoder task queue empty; requesting more data"); mCallback->InputExhausted(); } diff --git a/dom/media/platforms/apple/AppleVDADecoder.h b/dom/media/platforms/apple/AppleVDADecoder.h index 09f845f5f67e..441f34c1caad 100644 --- a/dom/media/platforms/apple/AppleVDADecoder.h +++ b/dom/media/platforms/apple/AppleVDADecoder.h @@ -122,11 +122,6 @@ protected: bool mUseSoftwareImages; bool mIs106; - // Number of times a sample was queued via Input(). Will be decreased upon - // the decoder's callback being invoked. - // This is used to calculate how many frames has been buffered by the decoder. - uint32_t mQueuedSamples; - // For wait on mIsFlushing during Shutdown() process. Monitor mMonitor; // Set on reader/decode thread calling Flush() to indicate that output is diff --git a/dom/media/platforms/apple/AppleVTDecoder.cpp b/dom/media/platforms/apple/AppleVTDecoder.cpp index 84e37dc3f162..a33476abf807 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -167,13 +167,14 @@ PlatformCallback(void* decompressionOutputRefCon, // Validate our arguments. if (status != noErr || !image) { NS_WARNING("VideoToolbox decoder returned no data"); - image = nullptr; - } else if (flags & kVTDecodeInfo_FrameDropped) { - NS_WARNING(" ...frame tagged as dropped..."); - } else { - MOZ_ASSERT(CFGetTypeID(image) == CVPixelBufferGetTypeID(), - "VideoToolbox returned an unexpected image type"); + return; } + if (flags & kVTDecodeInfo_FrameDropped) { + NS_WARNING(" ...frame tagged as dropped..."); + } + MOZ_ASSERT(CFGetTypeID(image) == CVPixelBufferGetTypeID(), + "VideoToolbox returned an unexpected image type"); + nsCOMPtr task = NS_NewRunnableMethodWithArgs, AppleVTDecoder::AppleFrameRef>( decoder, &AppleVTDecoder::OutputFrame, image, *frameRef); @@ -241,8 +242,6 @@ AppleVTDecoder::SubmitFrame(MediaRawData* aSample) return NS_ERROR_FAILURE; } - mQueuedSamples++; - VTDecodeFrameFlags decodeFlags = kVTDecodeFrame_EnableAsynchronousDecompression; rv = VTDecompressionSessionDecodeFrame(mSession, @@ -258,7 +257,7 @@ AppleVTDecoder::SubmitFrame(MediaRawData* aSample) } // Ask for more data. - if (!mInputIncoming && mQueuedSamples <= mMaxRefFrames) { + if (!mInputIncoming) { LOG("AppleVTDecoder task queue empty; requesting more data"); mCallback->InputExhausted(); }