Bug 1374296: Don't incorrectly reject promise. r=me
MozReview-Commit-ID: 6VZLLlIA3fM
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -192,23 +192,29 @@ H264Converter::Shutdown()
{
mInitPromiseRequest.DisconnectIfExists();
mDecodePromiseRequest.DisconnectIfExists();
mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
mDrainRequest.DisconnectIfExists();
mFlushRequest.DisconnectIfExists();
mFlushPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
mShutdownRequest.DisconnectIfExists();
- mNeedAVCC.reset();
if (mShutdownPromise) {
// We have a shutdown in progress, return that promise instead as we can't
// shutdown a decoder twice.
return mShutdownPromise.forget();
}
+ return ShutdownDecoder();
+}
+
+RefPtr<ShutdownPromise>
+H264Converter::ShutdownDecoder()
+{
+ mNeedAVCC.reset();
if (mDecoder) {
RefPtr<MediaDataDecoder> decoder = mDecoder.forget();
return decoder->Shutdown();
}
return ShutdownPromise::CreateAndResolve(true, __func__);
}
bool
@@ -476,17 +482,17 @@ void H264Converter::FlushThenShutdownDec
mFlushRequest.Complete();
if (!mFlushPromise.IsEmpty()) {
// A Flush is pending, abort the current operation.
mFlushPromise.Resolve(true, __func__);
return;
}
- mShutdownPromise = Shutdown();
+ mShutdownPromise = ShutdownDecoder();
mShutdownPromise
->Then(AbstractThread::GetCurrent()->AsTaskQueue(),
__func__,
[self, sample, this]() {
mShutdownRequest.Complete();
mShutdownPromise = nullptr;
if (!mFlushPromise.IsEmpty()) {
--- a/dom/media/platforms/wrappers/H264Converter.h
+++ b/dom/media/platforms/wrappers/H264Converter.h
@@ -71,16 +71,17 @@ private:
nsresult CheckForSPSChange(MediaRawData* aSample);
void UpdateConfigFromExtraData(MediaByteBuffer* aExtraData);
bool CanRecycleDecoder() const;
void DecodeFirstSample(MediaRawData* aSample);
void DrainThenFlushDecoder(MediaRawData* aPendingSample);
void FlushThenShutdownDecoder(MediaRawData* aPendingSample);
+ RefPtr<ShutdownPromise> ShutdownDecoder();
RefPtr<PlatformDecoderModule> mPDM;
const VideoInfo mOriginalConfig;
VideoInfo mCurrentConfig;
// Current out of band extra data (as found in metadata's VideoInfo).
RefPtr<MediaByteBuffer> mOriginalExtraData;
RefPtr<layers::KnowsCompositor> mKnowsCompositor;
RefPtr<layers::ImageContainer> mImageContainer;