From 99bf9b18df0a1a1da3c10824790ace5805e5dfc1 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 9 Sep 2016 15:50:37 +1200 Subject: [PATCH] Bug 1301294 - Remove unnecessary nsresult return value from MediaDataDecoder interface. r=jya --- dom/media/MediaFormatReader.cpp | 13 ++---- dom/media/MediaFormatReader.h | 2 +- dom/media/platforms/PlatformDecoderModule.h | 17 +++---- .../platforms/agnostic/BlankDecoderModule.cpp | 15 ++----- dom/media/platforms/agnostic/OpusDecoder.cpp | 15 +++---- dom/media/platforms/agnostic/OpusDecoder.h | 8 ++-- .../platforms/agnostic/TheoraDecoder.cpp | 14 ++---- dom/media/platforms/agnostic/TheoraDecoder.h | 8 ++-- dom/media/platforms/agnostic/VPXDecoder.cpp | 14 ++---- dom/media/platforms/agnostic/VPXDecoder.h | 8 ++-- .../platforms/agnostic/VorbisDecoder.cpp | 14 ++---- dom/media/platforms/agnostic/VorbisDecoder.h | 8 ++-- dom/media/platforms/agnostic/WAVDecoder.cpp | 12 ++--- dom/media/platforms/agnostic/WAVDecoder.h | 8 ++-- .../agnostic/eme/EMEDecoderModule.cpp | 45 ++++++++----------- .../agnostic/gmp/GMPAudioDecoder.cpp | 21 +++------ .../platforms/agnostic/gmp/GMPAudioDecoder.h | 8 ++-- .../agnostic/gmp/GMPVideoDecoder.cpp | 23 +++------- .../platforms/agnostic/gmp/GMPVideoDecoder.h | 8 ++-- .../agnostic/gmp/MediaDataDecoderProxy.cpp | 21 +++------ .../agnostic/gmp/MediaDataDecoderProxy.h | 8 ++-- .../android/MediaCodecDataDecoder.cpp | 25 +++-------- .../platforms/android/MediaCodecDataDecoder.h | 8 ++-- .../platforms/android/RemoteDataDecoder.cpp | 39 +++++++--------- .../platforms/android/RemoteDataDecoder.h | 8 ++-- dom/media/platforms/apple/AppleATDecoder.cpp | 18 +++----- dom/media/platforms/apple/AppleATDecoder.h | 8 ++-- dom/media/platforms/apple/AppleVTDecoder.cpp | 13 ++---- dom/media/platforms/apple/AppleVTDecoder.h | 8 ++-- .../platforms/ffmpeg/FFmpegDataDecoder.cpp | 12 ++--- .../platforms/ffmpeg/FFmpegDataDecoder.h | 8 ++-- .../platforms/gonk/GonkMediaDataDecoder.cpp | 15 +++---- .../platforms/gonk/GonkMediaDataDecoder.h | 8 ++-- dom/media/platforms/omx/OmxDataDecoder.cpp | 16 ++----- dom/media/platforms/omx/OmxDataDecoder.h | 8 ++-- .../platforms/wmf/WMFMediaDataDecoder.cpp | 16 +++---- dom/media/platforms/wmf/WMFMediaDataDecoder.h | 10 ++--- .../platforms/wrappers/FuzzingWrapper.cpp | 24 +++++----- dom/media/platforms/wrappers/FuzzingWrapper.h | 10 ++--- .../platforms/wrappers/H264Converter.cpp | 44 +++++++++--------- dom/media/platforms/wrappers/H264Converter.h | 8 ++-- 41 files changed, 235 insertions(+), 361 deletions(-) diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 3ff6356351a5..2a88ff908528 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -908,18 +908,14 @@ MediaFormatReader::RequestDemuxSamples(TrackType aTrack) } } -bool +void MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack, MediaRawData* aSample) { MOZ_ASSERT(OnTaskQueue()); auto& decoder = GetDecoderData(aTrack); - if (NS_FAILED(decoder.mDecoder->Input(aSample))) { - LOG("Unable to pass frame to decoder"); - return false; - } + decoder.mDecoder->Input(aSample); decoder.mDecodePending = true; - return true; } void @@ -1019,9 +1015,8 @@ MediaFormatReader::HandleDemuxedSamples(TrackType aTrack, if (mDemuxOnly) { ReturnOutput(sample, aTrack); - } else if (!DecodeDemuxedSamples(aTrack, sample)) { - NotifyError(aTrack); - return; + } else { + DecodeDemuxedSamples(aTrack, sample); } decoder.mQueuedSamples.RemoveElementAt(0); diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index f632a18b9272..b793f62efc25 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -133,7 +133,7 @@ private: void HandleDemuxedSamples(TrackType aTrack, AbstractMediaDecoder::AutoNotifyDecoded& aA); // Decode any pending already demuxed samples. - bool DecodeDemuxedSamples(TrackType aTrack, + void DecodeDemuxedSamples(TrackType aTrack, MediaRawData* aSample); struct InternalSeekTarget { diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h index 6f906fc2a4bd..fd79d980ba0d 100644 --- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -210,6 +210,10 @@ public: // TaskQueue passed into the PlatformDecoderModules's Create*Decoder() // function. This may not be necessary for platforms with async APIs // for decoding. +// +// If an error occurs at any point after the Init promise has been +// completed, then Error() must be called on the associated +// MediaDataDecoderCallback. class MediaDataDecoder { protected: virtual ~MediaDataDecoder() {}; @@ -235,7 +239,7 @@ public: virtual RefPtr Init() = 0; // Inserts a sample into the decoder's decode pipeline. - virtual nsresult Input(MediaRawData* aSample) = 0; + virtual void Input(MediaRawData* aSample) = 0; // Causes all samples in the decoding pipeline to be discarded. When // this function returns, the decoder must be ready to accept new input @@ -244,7 +248,7 @@ public: // While the reader calls Flush(), it ignores all output sent to it; // it is safe (but pointless) to send output while Flush is called. // The MediaFormatReader will not call Input() while it's calling Flush(). - virtual nsresult Flush() = 0; + virtual void Flush() = 0; // Causes all complete samples in the pipeline that can be decoded to be // output. If the decoder can't produce samples from the current output, @@ -255,7 +259,7 @@ public: // This function is asynchronous. The MediaDataDecoder must call // MediaDataDecoderCallback::DrainComplete() once all remaining // samples have been output. - virtual nsresult Drain() = 0; + virtual void Drain() = 0; // Cancels all init/input/drain operations, and shuts down the // decoder. The platform decoder should clean up any resources it's using @@ -264,7 +268,7 @@ public: // The reader will delete the decoder once Shutdown() returns. // The MediaDataDecoderCallback *must* not be called after Shutdown() has // returned. - virtual nsresult Shutdown() = 0; + virtual void Shutdown() = 0; // Called from the state machine task queue or main thread. // Decoder needs to decide whether or not hardware accelearation is supported @@ -277,10 +281,7 @@ public: // If audio decoder, aConfig will be a AudioInfo object. // It is not safe to store a reference to this object and the decoder must // make a copy. - virtual nsresult ConfigurationChanged(const TrackInfo& aConfig) - { - return NS_OK; - } + virtual void ConfigurationChanged(const TrackInfo& aConfig) {} // Return the name of the MediaDataDecoder, only used for decoding. // Only return a static const string, as the information may be accessed diff --git a/dom/media/platforms/agnostic/BlankDecoderModule.cpp b/dom/media/platforms/agnostic/BlankDecoderModule.cpp index 0e5024e08676..049c35f8511b 100644 --- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp +++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp @@ -44,11 +44,9 @@ public: return InitPromise::CreateAndResolve(mType, __func__); } - nsresult Shutdown() override { - return NS_OK; - } + void Shutdown() override {} - nsresult Input(MediaRawData* aSample) override + void Input(MediaRawData* aSample) override { RefPtr data = mCreator->Create(media::TimeUnit::FromMicroseconds(aSample->mTime), @@ -56,25 +54,20 @@ public: aSample->mOffset); OutputFrame(data); - - return NS_OK; } - nsresult Flush() override + void Flush() override { mReorderQueue.Clear(); - - return NS_OK; } - nsresult Drain() override + void Drain() override { while (!mReorderQueue.IsEmpty()) { mCallback->Output(mReorderQueue.Pop().get()); } mCallback->DrainComplete(); - return NS_OK; } const char* GetDescriptionName() const override diff --git a/dom/media/platforms/agnostic/OpusDecoder.cpp b/dom/media/platforms/agnostic/OpusDecoder.cpp index 8b2427f0889a..59ad296c8ab9 100644 --- a/dom/media/platforms/agnostic/OpusDecoder.cpp +++ b/dom/media/platforms/agnostic/OpusDecoder.cpp @@ -41,10 +41,9 @@ OpusDataDecoder::~OpusDataDecoder() } } -nsresult +void OpusDataDecoder::Shutdown() { - return NS_OK; } void @@ -138,13 +137,11 @@ OpusDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength) return NS_OK; } -nsresult +void OpusDataDecoder::Input(MediaRawData* aSample) { mTaskQueue->Dispatch(NewRunnableMethod>( this, &OpusDataDecoder::ProcessDecode, aSample)); - - return NS_OK; } void @@ -323,18 +320,17 @@ OpusDataDecoder::ProcessDrain() mCallback->DrainComplete(); } -nsresult +void OpusDataDecoder::Drain() { mTaskQueue->Dispatch(NewRunnableMethod(this, &OpusDataDecoder::ProcessDrain)); - return NS_OK; } -nsresult +void OpusDataDecoder::Flush() { if (!mOpusDecoder) { - return NS_OK; + return; } mIsFlushing = true; nsCOMPtr runnable = NS_NewRunnableFunction([this] () { @@ -347,7 +343,6 @@ OpusDataDecoder::Flush() }); SyncRunnable::DispatchToThread(mTaskQueue, runnable); mIsFlushing = false; - return NS_OK; } /* static */ diff --git a/dom/media/platforms/agnostic/OpusDecoder.h b/dom/media/platforms/agnostic/OpusDecoder.h index 515036ee0632..4e8acb6e1077 100644 --- a/dom/media/platforms/agnostic/OpusDecoder.h +++ b/dom/media/platforms/agnostic/OpusDecoder.h @@ -21,10 +21,10 @@ public: ~OpusDataDecoder(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "opus audio decoder"; diff --git a/dom/media/platforms/agnostic/TheoraDecoder.cpp b/dom/media/platforms/agnostic/TheoraDecoder.cpp index 58e0ed04c756..375db566e4fa 100644 --- a/dom/media/platforms/agnostic/TheoraDecoder.cpp +++ b/dom/media/platforms/agnostic/TheoraDecoder.cpp @@ -58,14 +58,13 @@ TheoraDecoder::~TheoraDecoder() th_info_clear(&mTheoraInfo); } -nsresult +void TheoraDecoder::Shutdown() { if (mTheoraDecoderContext) { th_decode_free(mTheoraDecoderContext); mTheoraDecoderContext = nullptr; } - return NS_OK; } RefPtr @@ -99,7 +98,7 @@ TheoraDecoder::Init() } -nsresult +void TheoraDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -109,7 +108,6 @@ TheoraDecoder::Flush() }); SyncRunnable::DispatchToThread(mTaskQueue, r); mIsFlushing = false; - return NS_OK; } nsresult @@ -207,14 +205,12 @@ TheoraDecoder::ProcessDecode(MediaRawData* aSample) } } -nsresult +void TheoraDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod>( this, &TheoraDecoder::ProcessDecode, aSample)); - - return NS_OK; } void @@ -224,13 +220,11 @@ TheoraDecoder::ProcessDrain() mCallback->DrainComplete(); } -nsresult +void TheoraDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod(this, &TheoraDecoder::ProcessDrain)); - - return NS_OK; } /* static */ diff --git a/dom/media/platforms/agnostic/TheoraDecoder.h b/dom/media/platforms/agnostic/TheoraDecoder.h index c23b4b637af1..33fc0e73b69b 100644 --- a/dom/media/platforms/agnostic/TheoraDecoder.h +++ b/dom/media/platforms/agnostic/TheoraDecoder.h @@ -24,10 +24,10 @@ public: ~TheoraDecoder(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; // Return true if mimetype is a Theora codec static bool IsTheora(const nsACString& aMimeType); diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp index 4b6cfe60291d..e3831cfc59fe 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -49,11 +49,10 @@ VPXDecoder::~VPXDecoder() MOZ_COUNT_DTOR(VPXDecoder); } -nsresult +void VPXDecoder::Shutdown() { vpx_codec_destroy(&mVPX); - return NS_OK; } RefPtr @@ -84,7 +83,7 @@ VPXDecoder::Init() return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__); } -nsresult +void VPXDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -94,7 +93,6 @@ VPXDecoder::Flush() }); SyncRunnable::DispatchToThread(mTaskQueue, r); mIsFlushing = false; - return NS_OK; } int @@ -197,14 +195,12 @@ VPXDecoder::ProcessDecode(MediaRawData* aSample) } } -nsresult +void VPXDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod>( this, &VPXDecoder::ProcessDecode, aSample)); - - return NS_OK; } void @@ -214,13 +210,11 @@ VPXDecoder::ProcessDrain() mCallback->DrainComplete(); } -nsresult +void VPXDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod(this, &VPXDecoder::ProcessDrain)); - - return NS_OK; } /* static */ diff --git a/dom/media/platforms/agnostic/VPXDecoder.h b/dom/media/platforms/agnostic/VPXDecoder.h index 74d8f502fc4f..e8a771b86910 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.h +++ b/dom/media/platforms/agnostic/VPXDecoder.h @@ -25,10 +25,10 @@ public: ~VPXDecoder(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "libvpx video decoder"; diff --git a/dom/media/platforms/agnostic/VorbisDecoder.cpp b/dom/media/platforms/agnostic/VorbisDecoder.cpp index 051d0bf17a8c..995f2624b4f6 100644 --- a/dom/media/platforms/agnostic/VorbisDecoder.cpp +++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp @@ -54,11 +54,9 @@ VorbisDataDecoder::~VorbisDataDecoder() vorbis_comment_clear(&mVorbisComment); } -nsresult +void VorbisDataDecoder::Shutdown() { - //mReader = nullptr; - return NS_OK; } RefPtr @@ -124,14 +122,12 @@ VorbisDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength) return r == 0 ? NS_OK : NS_ERROR_FAILURE; } -nsresult +void VorbisDataDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod>( this, &VorbisDataDecoder::ProcessDecode, aSample)); - - return NS_OK; } void @@ -255,15 +251,14 @@ VorbisDataDecoder::ProcessDrain() mCallback->DrainComplete(); } -nsresult +void VorbisDataDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::ProcessDrain)); - return NS_OK; } -nsresult +void VorbisDataDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -277,7 +272,6 @@ VorbisDataDecoder::Flush() }); SyncRunnable::DispatchToThread(mTaskQueue, r); mIsFlushing = false; - return NS_OK; } /* static */ diff --git a/dom/media/platforms/agnostic/VorbisDecoder.h b/dom/media/platforms/agnostic/VorbisDecoder.h index 22419bea1cd0..0054fd51695d 100644 --- a/dom/media/platforms/agnostic/VorbisDecoder.h +++ b/dom/media/platforms/agnostic/VorbisDecoder.h @@ -25,10 +25,10 @@ public: ~VorbisDataDecoder(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "vorbis audio decoder"; diff --git a/dom/media/platforms/agnostic/WAVDecoder.cpp b/dom/media/platforms/agnostic/WAVDecoder.cpp index 44ee53648b72..0824beb128ed 100644 --- a/dom/media/platforms/agnostic/WAVDecoder.cpp +++ b/dom/media/platforms/agnostic/WAVDecoder.cpp @@ -51,10 +51,9 @@ WaveDataDecoder::WaveDataDecoder(const CreateDecoderParams& aParams) { } -nsresult +void WaveDataDecoder::Shutdown() { - return NS_OK; } RefPtr @@ -63,7 +62,7 @@ WaveDataDecoder::Init() return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__); } -nsresult +void WaveDataDecoder::Input(MediaRawData* aSample) { if (!DoDecode(aSample)) { @@ -71,7 +70,6 @@ WaveDataDecoder::Input(MediaRawData* aSample) } else { mCallback->InputExhausted(); } - return NS_OK; } bool @@ -131,17 +129,15 @@ WaveDataDecoder::DoDecode(MediaRawData* aSample) return true; } -nsresult +void WaveDataDecoder::Drain() { mCallback->DrainComplete(); - return NS_OK; } -nsresult +void WaveDataDecoder::Flush() { - return NS_OK; } /* static */ diff --git a/dom/media/platforms/agnostic/WAVDecoder.h b/dom/media/platforms/agnostic/WAVDecoder.h index 51a826e524ae..680c63db55bf 100644 --- a/dom/media/platforms/agnostic/WAVDecoder.h +++ b/dom/media/platforms/agnostic/WAVDecoder.h @@ -21,10 +21,10 @@ public: static bool IsWave(const nsACString& aMimeType); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "wave audio decoder"; diff --git a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp index 414754870b02..b3903430168a 100644 --- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp @@ -45,14 +45,14 @@ public: return mDecoder->Init(); } - nsresult Input(MediaRawData* aSample) override { + void Input(MediaRawData* aSample) override { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); if (mIsShutdown) { NS_WARNING("EME encrypted sample arrived after shutdown"); - return NS_OK; + return; } if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) { - return NS_OK; + return; } nsAutoPtr writer(aSample->CreateWriter()); @@ -64,7 +64,7 @@ public: mTaskQueue, __func__, this, &EMEDecryptor::Decrypted, &EMEDecryptor::Decrypted)); - return NS_OK; + return; } void Decrypted(const DecryptResult& aDecrypted) { @@ -104,12 +104,11 @@ public: // by gmp-clearkey, decoding will fail. UniquePtr writer(aDecrypted.mSample->CreateWriter()); writer->mCrypto = CryptoSample(); - nsresult rv = mDecoder->Input(aDecrypted.mSample); - Unused << NS_WARN_IF(NS_FAILED(rv)); + mDecoder->Input(aDecrypted.mSample); } } - nsresult Flush() override { + void Flush() override { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(!mIsShutdown); for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) { @@ -117,13 +116,11 @@ public: holder->DisconnectIfExists(); iter.Remove(); } - nsresult rv = mDecoder->Flush(); - Unused << NS_WARN_IF(NS_FAILED(rv)); + mDecoder->Flush(); mSamplesWaitingForKey->Flush(); - return rv; } - nsresult Drain() override { + void Drain() override { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(!mIsShutdown); for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) { @@ -131,23 +128,19 @@ public: holder->DisconnectIfExists(); iter.Remove(); } - nsresult rv = mDecoder->Drain(); - Unused << NS_WARN_IF(NS_FAILED(rv)); - return rv; + mDecoder->Drain(); } - nsresult Shutdown() override { + void Shutdown() override { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(!mIsShutdown); mIsShutdown = true; - nsresult rv = mDecoder->Shutdown(); - Unused << NS_WARN_IF(NS_FAILED(rv)); + mDecoder->Shutdown(); mSamplesWaitingForKey->BreakCycles(); mSamplesWaitingForKey = nullptr; mDecoder = nullptr; mProxy = nullptr; mCallback = nullptr; - return rv; } const char* GetDescriptionName() const override { @@ -178,38 +171,36 @@ public: { } - nsresult Input(MediaRawData* aSample) override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Shutdown() override; private: RefPtr mSamplesWaitingForKey; RefPtr mProxy; }; -nsresult +void EMEMediaDataDecoderProxy::Input(MediaRawData* aSample) { if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) { - return NS_OK; + return; } nsAutoPtr writer(aSample->CreateWriter()); mProxy->GetSessionIdsForKeyId(aSample->mCrypto.mKeyId, writer->mCrypto.mSessionIds); - return MediaDataDecoderProxy::Input(aSample); + MediaDataDecoderProxy::Input(aSample); } -nsresult +void EMEMediaDataDecoderProxy::Shutdown() { - nsresult rv = MediaDataDecoderProxy::Shutdown(); + MediaDataDecoderProxy::Shutdown(); mSamplesWaitingForKey->BreakCycles(); mSamplesWaitingForKey = nullptr; mProxy = nullptr; - - return rv; } EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM) diff --git a/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.cpp b/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.cpp index f6298386c479..c9d8f4fe4a39 100644 --- a/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.cpp +++ b/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.cpp @@ -239,7 +239,7 @@ GMPAudioDecoder::Init() return promise; } -nsresult +void GMPAudioDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(IsOnGMPThread()); @@ -247,7 +247,7 @@ GMPAudioDecoder::Input(MediaRawData* aSample) RefPtr sample(aSample); if (!mGMP) { mCallback->Error(MediaDataDecoderError::FATAL_ERROR); - return NS_ERROR_FAILURE; + return; } mAdapter->SetLastStreamOffset(sample->mOffset); @@ -256,13 +256,10 @@ GMPAudioDecoder::Input(MediaRawData* aSample) nsresult rv = mGMP->Decode(samples); if (NS_FAILED(rv)) { mCallback->Error(MediaDataDecoderError::DECODE_ERROR); - return rv; } - - return NS_OK; } -nsresult +void GMPAudioDecoder::Flush() { MOZ_ASSERT(IsOnGMPThread()); @@ -271,11 +268,9 @@ GMPAudioDecoder::Flush() // Abort the flush. mCallback->FlushComplete(); } - - return NS_OK; } -nsresult +void GMPAudioDecoder::Drain() { MOZ_ASSERT(IsOnGMPThread()); @@ -283,22 +278,18 @@ GMPAudioDecoder::Drain() if (!mGMP || NS_FAILED(mGMP->Drain())) { mCallback->DrainComplete(); } - - return NS_OK; } -nsresult +void GMPAudioDecoder::Shutdown() { mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__); if (!mGMP) { - return NS_ERROR_FAILURE; + return; } // Note this unblocks flush and drain operations waiting for callbacks. mGMP->Close(); mGMP = nullptr; - - return NS_OK; } } // namespace mozilla diff --git a/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h b/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h index 452e685d8096..90e3ebdb6a3e 100644 --- a/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h +++ b/dom/media/platforms/agnostic/gmp/GMPAudioDecoder.h @@ -65,10 +65,10 @@ public: explicit GMPAudioDecoder(const GMPAudioDecoderParams& aParams); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "GMP audio decoder"; diff --git a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp index ceed3a4eef7f..4e36783193bc 100644 --- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp +++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp @@ -313,7 +313,7 @@ GMPVideoDecoder::Init() return promise; } -nsresult +void GMPVideoDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(IsOnGMPThread()); @@ -321,7 +321,7 @@ GMPVideoDecoder::Input(MediaRawData* aSample) RefPtr sample(aSample); if (!mGMP) { mCallback->Error(MediaDataDecoderError::FATAL_ERROR); - return NS_ERROR_FAILURE; + return; } mAdapter->SetLastStreamOffset(sample->mOffset); @@ -329,19 +329,16 @@ GMPVideoDecoder::Input(MediaRawData* aSample) GMPUniquePtr frame = CreateFrame(sample); if (!frame) { mCallback->Error(MediaDataDecoderError::FATAL_ERROR); - return NS_ERROR_FAILURE; + return; } nsTArray info; // No codec specific per-frame info to pass. nsresult rv = mGMP->Decode(Move(frame), false, info, 0); if (NS_FAILED(rv)) { mCallback->Error(MediaDataDecoderError::DECODE_ERROR); - return rv; } - - return NS_OK; } -nsresult +void GMPVideoDecoder::Flush() { MOZ_ASSERT(IsOnGMPThread()); @@ -350,11 +347,9 @@ GMPVideoDecoder::Flush() // Abort the flush. mCallback->FlushComplete(); } - - return NS_OK; } -nsresult +void GMPVideoDecoder::Drain() { MOZ_ASSERT(IsOnGMPThread()); @@ -362,23 +357,19 @@ GMPVideoDecoder::Drain() if (!mGMP || NS_FAILED(mGMP->Drain())) { mCallback->DrainComplete(); } - - return NS_OK; } -nsresult +void GMPVideoDecoder::Shutdown() { mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__); // Note that this *may* be called from the proxy thread also. if (!mGMP) { - return NS_ERROR_FAILURE; + return; } // Note this unblocks flush and drain operations waiting for callbacks. mGMP->Close(); mGMP = nullptr; - - return NS_OK; } } // namespace mozilla diff --git a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h index 9f06629b92c9..0837c3706a96 100644 --- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h +++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h @@ -70,10 +70,10 @@ public: explicit GMPVideoDecoder(const GMPVideoDecoderParams& aParams); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { return "GMP video decoder"; diff --git a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp index 3146225a801f..63cb8ecfce20 100644 --- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp +++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp @@ -38,7 +38,7 @@ MediaDataDecoderProxy::Init() &MediaDataDecoderProxy::InternalInit); } -nsresult +void MediaDataDecoderProxy::Input(MediaRawData* aSample) { MOZ_ASSERT(!IsOnProxyThread()); @@ -46,11 +46,9 @@ MediaDataDecoderProxy::Input(MediaRawData* aSample) nsCOMPtr task(new InputTask(mProxyDecoder, aSample)); mProxyThread->Dispatch(task.forget()); - - return NS_OK; } -nsresult +void MediaDataDecoderProxy::Flush() { MOZ_ASSERT(!IsOnProxyThread()); @@ -61,21 +59,18 @@ MediaDataDecoderProxy::Flush() mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush)); mFlushComplete.WaitUntil(true); - - return NS_OK; } -nsresult +void MediaDataDecoderProxy::Drain() { MOZ_ASSERT(!IsOnProxyThread()); MOZ_ASSERT(!mIsShutdown); mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain)); - return NS_OK; } -nsresult +void MediaDataDecoderProxy::Shutdown() { // Note that this *may* be called from the proxy thread also. @@ -83,11 +78,9 @@ MediaDataDecoderProxy::Shutdown() #if defined(DEBUG) mIsShutdown = true; #endif - nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder, - &MediaDataDecoder::Shutdown), - NS_DISPATCH_SYNC); - NS_ENSURE_SUCCESS(rv, rv); - return NS_OK; + mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder, + &MediaDataDecoder::Shutdown), + NS_DISPATCH_SYNC); } void diff --git a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h index 8aa1252f12aa..261b5acde9bb 100644 --- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h +++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h @@ -140,10 +140,10 @@ public: // asynchronously and responded to via the MediaDataDecoderCallback. // Note: the nsresults returned by the proxied decoder are lost. RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { diff --git a/dom/media/platforms/android/MediaCodecDataDecoder.cpp b/dom/media/platforms/android/MediaCodecDataDecoder.cpp index e01c2e925cd0..93ead17cb667 100644 --- a/dom/media/platforms/android/MediaCodecDataDecoder.cpp +++ b/dom/media/platforms/android/MediaCodecDataDecoder.cpp @@ -89,11 +89,6 @@ public: { } - nsresult Input(MediaRawData* aSample) override - { - return MediaCodecDataDecoder::Input(aSample); - } - nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat, const TimeUnit& aDuration) override { @@ -618,14 +613,12 @@ MediaCodecDataDecoder::ClearQueue() mDurations.clear(); } -nsresult +void MediaCodecDataDecoder::Input(MediaRawData* aSample) { MonitorAutoLock lock(mMonitor); mQueue.push_back(aSample); lock.NotifyAll(); - - return NS_OK; } nsresult @@ -640,39 +633,35 @@ MediaCodecDataDecoder::ResetOutputBuffers() return mDecoder->GetOutputBuffers(ReturnTo(&mOutputBuffers)); } -nsresult +void MediaCodecDataDecoder::Flush() { MonitorAutoLock lock(mMonitor); if (!SetState(ModuleState::kFlushing)) { - return NS_OK; + return; } lock.Notify(); while (mState == ModuleState::kFlushing) { lock.Wait(); } - - return NS_OK; } -nsresult +void MediaCodecDataDecoder::Drain() { MonitorAutoLock lock(mMonitor); if (mState == ModuleState::kDrainDecoder || mState == ModuleState::kDrainQueue) { - return NS_OK; + return; } SetState(ModuleState::kDrainQueue); lock.Notify(); - - return NS_OK; } -nsresult +void MediaCodecDataDecoder::Shutdown() { MonitorAutoLock lock(mMonitor); @@ -694,8 +683,6 @@ MediaCodecDataDecoder::Shutdown() mDecoder->Release(); mDecoder = nullptr; } - - return NS_OK; } } // mozilla diff --git a/dom/media/platforms/android/MediaCodecDataDecoder.h b/dom/media/platforms/android/MediaCodecDataDecoder.h index e2f1fee92144..0db6407bfb67 100644 --- a/dom/media/platforms/android/MediaCodecDataDecoder.h +++ b/dom/media/platforms/android/MediaCodecDataDecoder.h @@ -33,10 +33,10 @@ public: virtual ~MediaCodecDataDecoder(); RefPtr Init() override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; - nsresult Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; + void Input(MediaRawData* aSample) override; const char* GetDescriptionName() const override { return "Android MediaCodec decoder"; diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index 1fb3bc29e89a..cdc1d36cb623 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -216,28 +216,22 @@ public: return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__); } - nsresult Flush() override + void Flush() override { mInputDurations.Clear(); - return RemoteDataDecoder::Flush(); + RemoteDataDecoder::Flush(); } - nsresult Drain() override + void Drain() override { - nsresult res = RemoteDataDecoder::Drain(); - NS_ENSURE_SUCCESS(res, res); - + RemoteDataDecoder::Drain(); mInputDurations.Put(0); - return NS_OK; } - nsresult Input(MediaRawData* aSample) override + void Input(MediaRawData* aSample) override { - nsresult res = RemoteDataDecoder::Input(aSample); - NS_ENSURE_SUCCESS(res, res); - + RemoteDataDecoder::Input(aSample); mInputDurations.Put(aSample->mDuration); - return NS_OK; } private: @@ -432,26 +426,24 @@ RemoteDataDecoder::RemoteDataDecoder(MediaData::Type aType, { } -nsresult +void RemoteDataDecoder::Flush() { mJavaDecoder->Flush(); - return NS_OK; } -nsresult +void RemoteDataDecoder::Drain() { BufferInfo::LocalRef bufferInfo; nsresult rv = BufferInfo::New(&bufferInfo); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS_VOID(rv); bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM); mJavaDecoder->Input(nullptr, bufferInfo); - return NS_OK; } -nsresult +void RemoteDataDecoder::Shutdown() { LOG(""); @@ -464,11 +456,9 @@ RemoteDataDecoder::Shutdown() mJavaCallbacks = nullptr; mFormat = nullptr; - - return NS_OK; } -nsresult +void RemoteDataDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(aSample != nullptr); @@ -485,12 +475,13 @@ RemoteDataDecoder::Input(MediaRawData* aSample) BufferInfo::LocalRef bufferInfo; nsresult rv = BufferInfo::New(&bufferInfo); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + mCallback->Error(MediaDataDecoderError::FATAL_ERROR); + return; + } bufferInfo->Set(0, aSample->Size(), aSample->mTime, 0); mJavaDecoder->Input(bytes, bufferInfo); - - return NS_OK; } } // mozilla diff --git a/dom/media/platforms/android/RemoteDataDecoder.h b/dom/media/platforms/android/RemoteDataDecoder.h index a48a470770b0..b23b75444819 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.h +++ b/dom/media/platforms/android/RemoteDataDecoder.h @@ -31,10 +31,10 @@ public: virtual ~RemoteDataDecoder() {} - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; - nsresult Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; + void Input(MediaRawData* aSample) override; const char* GetDescriptionName() const override { return "android remote decoder"; diff --git a/dom/media/platforms/apple/AppleATDecoder.cpp b/dom/media/platforms/apple/AppleATDecoder.cpp index 0b8a7a320524..0f486787b509 100644 --- a/dom/media/platforms/apple/AppleATDecoder.cpp +++ b/dom/media/platforms/apple/AppleATDecoder.cpp @@ -63,7 +63,7 @@ AppleATDecoder::Init() return InitPromise::CreateAndResolve(TrackType::kAudioTrack, __func__); } -nsresult +void AppleATDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -81,8 +81,6 @@ AppleATDecoder::Input(MediaRawData* aSample) &AppleATDecoder::SubmitSample, RefPtr(aSample)); mTaskQueue->Dispatch(runnable.forget()); - - return NS_OK; } void @@ -96,7 +94,7 @@ AppleATDecoder::ProcessFlush() } } -nsresult +void AppleATDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -106,20 +104,19 @@ AppleATDecoder::Flush() NewRunnableMethod(this, &AppleATDecoder::ProcessFlush); SyncRunnable::DispatchToThread(mTaskQueue, runnable); mIsFlushing = false; - return NS_OK; } -nsresult +void AppleATDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); LOG("Draining AudioToolbox AAC decoder"); mTaskQueue->AwaitIdle(); mCallback->DrainComplete(); - return Flush(); + Flush(); } -nsresult +void AppleATDecoder::Shutdown() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -129,7 +126,7 @@ AppleATDecoder::Shutdown() OSStatus rv = AudioConverterDispose(mConverter); if (rv) { LOG("error %d disposing of AudioConverter", rv); - return NS_ERROR_FAILURE; + return; } mConverter = nullptr; @@ -137,11 +134,10 @@ AppleATDecoder::Shutdown() rv = AudioFileStreamClose(mStream); if (rv) { LOG("error %d disposing of AudioFileStream", rv); - return NS_ERROR_FAILURE; + return; } mStream = nullptr; } - return NS_OK; } struct PassthroughUserData { diff --git a/dom/media/platforms/apple/AppleATDecoder.h b/dom/media/platforms/apple/AppleATDecoder.h index 669ce2961fe9..35b342a53fb1 100644 --- a/dom/media/platforms/apple/AppleATDecoder.h +++ b/dom/media/platforms/apple/AppleATDecoder.h @@ -27,10 +27,10 @@ public: virtual ~AppleATDecoder(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; const char* GetDescriptionName() const override { diff --git a/dom/media/platforms/apple/AppleVTDecoder.cpp b/dom/media/platforms/apple/AppleVTDecoder.cpp index 05f4b7884a70..457ce3ef53c0 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -74,7 +74,7 @@ AppleVTDecoder::Init() return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__); } -nsresult +void AppleVTDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -88,10 +88,9 @@ AppleVTDecoder::Input(MediaRawData* aSample) mTaskQueue->Dispatch(NewRunnableMethod>( this, &AppleVTDecoder::ProcessDecode, aSample)); - return NS_OK; } -nsresult +void AppleVTDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -102,21 +101,18 @@ AppleVTDecoder::Flush() mIsFlushing = false; mSeekTargetThreshold.reset(); - - return NS_OK; } -nsresult +void AppleVTDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr runnable = NewRunnableMethod(this, &AppleVTDecoder::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); - return NS_OK; } -nsresult +void AppleVTDecoder::Shutdown() { MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); @@ -128,7 +124,6 @@ AppleVTDecoder::Shutdown() } else { ProcessShutdown(); } - return NS_OK; } nsresult diff --git a/dom/media/platforms/apple/AppleVTDecoder.h b/dom/media/platforms/apple/AppleVTDecoder.h index 5e0b45029864..8305d4d52386 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.h +++ b/dom/media/platforms/apple/AppleVTDecoder.h @@ -43,10 +43,10 @@ public: }; RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; void SetSeekThreshold(const media::TimeUnit& aTime) override; bool IsHardwareAccelerated(nsACString& aFailureReason) const override diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp index c09f31a4a1be..f566c3c1472c 100644 --- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp @@ -90,7 +90,7 @@ FFmpegDataDecoder::InitDecoder() return NS_OK; } -nsresult +void FFmpegDataDecoder::Shutdown() { if (mTaskQueue) { @@ -100,7 +100,6 @@ FFmpegDataDecoder::Shutdown() } else { ProcessShutdown(); } - return NS_OK; } void @@ -126,15 +125,14 @@ FFmpegDataDecoder::ProcessDecode(MediaRawData* aSample) } } -nsresult +void FFmpegDataDecoder::Input(MediaRawData* aSample) { mTaskQueue->Dispatch(NewRunnableMethod>( this, &FFmpegDataDecoder::ProcessDecode, aSample)); - return NS_OK; } -nsresult +void FFmpegDataDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -143,17 +141,15 @@ FFmpegDataDecoder::Flush() NewRunnableMethod(this, &FFmpegDataDecoder::ProcessFlush); SyncRunnable::DispatchToThread(mTaskQueue, runnable); mIsFlushing = false; - return NS_OK; } -nsresult +void FFmpegDataDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr runnable = NewRunnableMethod(this, &FFmpegDataDecoder::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); - return NS_OK; } void diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h index 9c94fade3b3a..ecd579cefeb9 100644 --- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h @@ -32,10 +32,10 @@ public: static bool Link(); RefPtr Init() override = 0; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; static AVCodec* FindAVCodec(FFmpegLibWrapper* aLib, AVCodecID aCodec); diff --git a/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp b/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp index 41775158856e..9cc05ed7c2a8 100644 --- a/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp +++ b/dom/media/platforms/gonk/GonkMediaDataDecoder.cpp @@ -348,36 +348,33 @@ GonkMediaDataDecoder::Init() return mManager->Init(); } -nsresult +void GonkMediaDataDecoder::Shutdown() { - nsresult rv = mManager->Shutdown(); + mManager->Shutdown(); // Because codec allocated runnable and init promise is at reader TaskQueue, // so manager needs to be destroyed at reader TaskQueue to prevent racing. mManager = nullptr; - return rv; } // Inserts data into the decoder's pipeline. -nsresult +void GonkMediaDataDecoder::Input(MediaRawData* aSample) { mManager->Input(aSample); - return NS_OK; } -nsresult +void GonkMediaDataDecoder::Flush() { - return mManager->Flush(); + mManager->Flush(); } -nsresult +void GonkMediaDataDecoder::Drain() { mManager->Input(nullptr); - return NS_OK; } } // namespace mozilla diff --git a/dom/media/platforms/gonk/GonkMediaDataDecoder.h b/dom/media/platforms/gonk/GonkMediaDataDecoder.h index 37ecaf84af92..a5283e0adf18 100644 --- a/dom/media/platforms/gonk/GonkMediaDataDecoder.h +++ b/dom/media/platforms/gonk/GonkMediaDataDecoder.h @@ -192,13 +192,13 @@ public: RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; + void Input(MediaRawData* aSample) override; - nsresult Flush() override; + void Flush() override; - nsresult Drain() override; + void Drain() override; - nsresult Shutdown() override; + void Shutdown() override; const char* GetDescriptionName() const override { diff --git a/dom/media/platforms/omx/OmxDataDecoder.cpp b/dom/media/platforms/omx/OmxDataDecoder.cpp index fe4b250142f9..1e12c13d6c93 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -175,7 +175,7 @@ OmxDataDecoder::Init() return p; } -nsresult +void OmxDataDecoder::Input(MediaRawData* aSample) { LOG("sample %p", aSample); @@ -195,11 +195,9 @@ OmxDataDecoder::Input(MediaRawData* aSample) } }); mOmxTaskQueue->Dispatch(r.forget()); - - return NS_OK; } -nsresult +void OmxDataDecoder::Flush() { LOG(""); @@ -215,21 +213,17 @@ OmxDataDecoder::Flush() while (mFlushing) { lock.Wait(); } - - return NS_OK; } -nsresult +void OmxDataDecoder::Drain() { LOG(""); mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer)); - - return NS_OK; } -nsresult +void OmxDataDecoder::Shutdown() { LOG(""); @@ -250,8 +244,6 @@ OmxDataDecoder::Shutdown() mOmxTaskQueue->BeginShutdown(); mOmxTaskQueue->AwaitShutdownAndIdle(); - - return NS_OK; } void diff --git a/dom/media/platforms/omx/OmxDataDecoder.h b/dom/media/platforms/omx/OmxDataDecoder.h index af00d435e45b..53700544aa0d 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.h +++ b/dom/media/platforms/omx/OmxDataDecoder.h @@ -66,13 +66,13 @@ public: RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; + void Input(MediaRawData* aSample) override; - nsresult Flush() override; + void Flush() override; - nsresult Drain() override; + void Drain() override; - nsresult Shutdown() override; + void Shutdown() override; const char* GetDescriptionName() const override { diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index 5c561b72e7cb..8b9423c4ae5f 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -72,7 +72,7 @@ SendTelemetry(unsigned long hr) NS_DispatchToMainThread(runnable); } -nsresult +void WMFMediaDataDecoder::Shutdown() { MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); @@ -83,7 +83,6 @@ WMFMediaDataDecoder::Shutdown() ProcessShutdown(); } mIsShutDown = true; - return NS_OK; } void @@ -99,7 +98,7 @@ WMFMediaDataDecoder::ProcessShutdown() } // Inserts data into the decoder's pipeline. -nsresult +void WMFMediaDataDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -111,7 +110,6 @@ WMFMediaDataDecoder::Input(MediaRawData* aSample) &WMFMediaDataDecoder::ProcessDecode, RefPtr(aSample)); mTaskQueue->Dispatch(runnable.forget()); - return NS_OK; } void @@ -168,7 +166,7 @@ WMFMediaDataDecoder::ProcessFlush() } } -nsresult +void WMFMediaDataDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -179,7 +177,6 @@ WMFMediaDataDecoder::Flush() NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush); SyncRunnable::DispatchToThread(mTaskQueue, runnable); mIsFlushing = false; - return NS_OK; } void @@ -194,14 +191,13 @@ WMFMediaDataDecoder::ProcessDrain() mCallback->DrainComplete(); } -nsresult +void WMFMediaDataDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain)); - return NS_OK; } bool @@ -211,7 +207,7 @@ WMFMediaDataDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const { return mMFTManager && mMFTManager->IsHardwareAccelerated(aFailureReason); } -nsresult +void WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); @@ -222,8 +218,6 @@ WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig) &WMFMediaDataDecoder::ProcessConfigurationChanged, aConfig.Clone()); mTaskQueue->Dispatch(runnable.forget()); - return NS_OK; - } void diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.h b/dom/media/platforms/wmf/WMFMediaDataDecoder.h index d415404a799b..664de31a9f75 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h @@ -86,17 +86,17 @@ public: RefPtr Init() override; - nsresult Input(MediaRawData* aSample); + void Input(MediaRawData* aSample); - nsresult Flush() override; + void Flush() override; - nsresult Drain() override; + void Drain() override; - nsresult Shutdown() override; + void Shutdown() override; bool IsHardwareAccelerated(nsACString& aFailureReason) const override; - nsresult ConfigurationChanged(const TrackInfo& aConfig) override; + void ConfigurationChanged(const TrackInfo& aConfig) override; const char* GetDescriptionName() const override { diff --git a/dom/media/platforms/wrappers/FuzzingWrapper.cpp b/dom/media/platforms/wrappers/FuzzingWrapper.cpp index a301d0006aca..0cbaf2741cad 100644 --- a/dom/media/platforms/wrappers/FuzzingWrapper.cpp +++ b/dom/media/platforms/wrappers/FuzzingWrapper.cpp @@ -39,47 +39,45 @@ DecoderFuzzingWrapper::Init() return mDecoder->Init(); } -nsresult +void DecoderFuzzingWrapper::Input(MediaRawData* aData) { DFW_LOGV("aData.mTime=%lld", aData->mTime); MOZ_ASSERT(mDecoder); - return mDecoder->Input(aData); + mDecoder->Input(aData); } -nsresult +void DecoderFuzzingWrapper::Flush() { DFW_LOGV("Calling mDecoder[%p]->Flush()", mDecoder.get()); MOZ_ASSERT(mDecoder); // Flush may output some frames (though unlikely). // Flush may block a bit, it's ok if we output some frames in the meantime. - nsresult result = mDecoder->Flush(); - DFW_LOGV("mDecoder[%p]->Flush() -> result=%u", mDecoder.get(), uint32_t(result)); + mDecoder->Flush(); + DFW_LOGV("mDecoder[%p]->Flush()", mDecoder.get()); // Clear any delayed output we may have. mCallbackWrapper->ClearDelayedOutput(); - return result; } -nsresult +void DecoderFuzzingWrapper::Drain() { DFW_LOGV(""); MOZ_ASSERT(mDecoder); // Note: The decoder should callback DrainComplete(), we'll drain the // delayed output (if any) then. - return mDecoder->Drain(); + mDecoder->Drain(); } -nsresult +void DecoderFuzzingWrapper::Shutdown() { DFW_LOGV(""); MOZ_ASSERT(mDecoder); // Both shutdowns below may block a bit. - nsresult result = mDecoder->Shutdown(); + mDecoder->Shutdown(); mCallbackWrapper->Shutdown(); - return result; } bool @@ -90,12 +88,12 @@ DecoderFuzzingWrapper::IsHardwareAccelerated(nsACString& aFailureReason) const return mDecoder->IsHardwareAccelerated(aFailureReason); } -nsresult +void DecoderFuzzingWrapper::ConfigurationChanged(const TrackInfo& aConfig) { DFW_LOGV(""); MOZ_ASSERT(mDecoder); - return mDecoder->ConfigurationChanged(aConfig); + mDecoder->ConfigurationChanged(aConfig); } diff --git a/dom/media/platforms/wrappers/FuzzingWrapper.h b/dom/media/platforms/wrappers/FuzzingWrapper.h index ab8cfd6703ca..9a012d515c23 100644 --- a/dom/media/platforms/wrappers/FuzzingWrapper.h +++ b/dom/media/platforms/wrappers/FuzzingWrapper.h @@ -103,12 +103,12 @@ public: // MediaDataDecoder implementation. RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; bool IsHardwareAccelerated(nsACString& aFailureReason) const override; - nsresult ConfigurationChanged(const TrackInfo& aConfig) override; + void ConfigurationChanged(const TrackInfo& aConfig) override; const char* GetDescriptionName() const override { return mDecoder->GetDescriptionName(); diff --git a/dom/media/platforms/wrappers/H264Converter.cpp b/dom/media/platforms/wrappers/H264Converter.cpp index aee23bf8a462..b00c50b74cfe 100644 --- a/dom/media/platforms/wrappers/H264Converter.cpp +++ b/dom/media/platforms/wrappers/H264Converter.cpp @@ -49,13 +49,14 @@ H264Converter::Init() TrackType::kVideoTrack, __func__); } -nsresult +void H264Converter::Input(MediaRawData* aSample) { if (!mp4_demuxer::AnnexB::ConvertSampleToAVCC(aSample)) { // We need AVCC content to be able to later parse the SPS. // This is a no-op if the data is already AVCC. - return NS_ERROR_FAILURE; + mCallback->Error(MediaDataDecoderError::DECODE_ERROR); + return; } if (mInitPromiseRequest.Exists()) { @@ -63,12 +64,12 @@ H264Converter::Input(MediaRawData* aSample) if (!aSample->mKeyframe) { // Frames dropped, we need a new one. mCallback->InputExhausted(); - return NS_OK; + return; } mNeedKeyframe = false; } mMediaRawSamples.AppendElement(aSample); - return NS_OK; + return; } nsresult rv; @@ -81,61 +82,62 @@ H264Converter::Input(MediaRawData* aSample) // We are missing the required SPS to create the decoder. // Ignore for the time being, the MediaRawData will be dropped. mCallback->InputExhausted(); - return NS_OK; + return; } } else { rv = CheckForSPSChange(aSample); } - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + mCallback->Error(MediaDataDecoderError::DECODE_ERROR); + return; + } if (mNeedKeyframe && !aSample->mKeyframe) { mCallback->InputExhausted(); - return NS_OK; + return; } if (!mNeedAVCC && !mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample)) { - return NS_ERROR_FAILURE; + mCallback->Error(MediaDataDecoderError::FATAL_ERROR); + return; } mNeedKeyframe = false; aSample->mExtraData = mCurrentConfig.mExtraData; - return mDecoder->Input(aSample); + mDecoder->Input(aSample); } -nsresult +void H264Converter::Flush() { mNeedKeyframe = true; if (mDecoder) { - return mDecoder->Flush(); + mDecoder->Flush(); } - return mLastError; } -nsresult +void H264Converter::Drain() { mNeedKeyframe = true; if (mDecoder) { - return mDecoder->Drain(); + mDecoder->Drain(); + return; } mCallback->DrainComplete(); - return mLastError; } -nsresult +void H264Converter::Shutdown() { if (mDecoder) { - nsresult rv = mDecoder->Shutdown(); + mDecoder->Shutdown(); mInitPromiseRequest.DisconnectIfExists(); mDecoder = nullptr; - return rv; } - return NS_OK; } bool @@ -238,9 +240,7 @@ H264Converter::OnDecoderInitDone(const TrackType aTrackType) } mNeedKeyframe = false; } - if (NS_FAILED(mDecoder->Input(sample))) { - mCallback->Error(MediaDataDecoderError::FATAL_ERROR); - } + mDecoder->Input(sample); } if (!gotInput) { mCallback->InputExhausted(); diff --git a/dom/media/platforms/wrappers/H264Converter.h b/dom/media/platforms/wrappers/H264Converter.h index 77389103de00..1db44ce90eaf 100644 --- a/dom/media/platforms/wrappers/H264Converter.h +++ b/dom/media/platforms/wrappers/H264Converter.h @@ -26,10 +26,10 @@ public: virtual ~H264Converter(); RefPtr Init() override; - nsresult Input(MediaRawData* aSample) override; - nsresult Flush() override; - nsresult Drain() override; - nsresult Shutdown() override; + void Input(MediaRawData* aSample) override; + void Flush() override; + void Drain() override; + void Shutdown() override; bool IsHardwareAccelerated(nsACString& aFailureReason) const override; const char* GetDescriptionName() const override {