From 6f3e8d4952304da7b176bbd4e8f78b06e002ed90 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 13 Aug 2014 09:56:33 +1200 Subject: [PATCH] Bug 1050064 - Reconfigure WMFAACDecoder on stream change. r=padenot --- content/media/fmp4/wmf/WMFAudioMFTManager.cpp | 34 +++++++++++++++++-- content/media/fmp4/wmf/WMFAudioMFTManager.h | 6 ++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/content/media/fmp4/wmf/WMFAudioMFTManager.cpp b/content/media/fmp4/wmf/WMFAudioMFTManager.cpp index 098b96dedc84..3a9dbdca196d 100644 --- a/content/media/fmp4/wmf/WMFAudioMFTManager.cpp +++ b/content/media/fmp4/wmf/WMFAudioMFTManager.cpp @@ -136,16 +136,44 @@ WMFAudioMFTManager::Input(mp4_demuxer::MP4Sample* aSample) return mDecoder->Input(data, length, aSample->composition_timestamp); } +HRESULT +WMFAudioMFTManager::UpdateOutputType() +{ + HRESULT hr; + + RefPtr type; + hr = mDecoder->GetOutputMediaType(type); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + + hr = type->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &mAudioRate); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + + hr = type->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &mAudioChannels); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + + return S_OK; +} + HRESULT WMFAudioMFTManager::Output(int64_t aStreamOffset, nsAutoPtr& aOutData) { aOutData = nullptr; RefPtr sample; - HRESULT hr = mDecoder->Output(&sample); - if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { - return MF_E_TRANSFORM_NEED_MORE_INPUT; + HRESULT hr; + while (true) { + hr = mDecoder->Output(&sample); + if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { + return hr; + } + if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { + hr = UpdateOutputType(); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + continue; + } + break; } + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); RefPtr buffer; diff --git a/content/media/fmp4/wmf/WMFAudioMFTManager.h b/content/media/fmp4/wmf/WMFAudioMFTManager.h index 9caff24e3c30..04f041d787d4 100644 --- a/content/media/fmp4/wmf/WMFAudioMFTManager.h +++ b/content/media/fmp4/wmf/WMFAudioMFTManager.h @@ -31,12 +31,14 @@ public: nsAutoPtr& aOutput) MOZ_OVERRIDE; private: + HRESULT UpdateOutputType(); + // IMFTransform wrapper that performs the decoding. RefPtr mDecoder; - const uint32_t mAudioChannels; + uint32_t mAudioChannels; const uint32_t mAudioBytesPerSample; - const uint32_t mAudioRate; + uint32_t mAudioRate; nsTArray mUserData; // The offset, in audio frames, at which playback started since the