From ce1f4614d02e79b84d1a14af39fccfa685aac170 Mon Sep 17 00:00:00 2001 From: alwu Date: Tue, 20 Nov 2018 22:42:24 +0000 Subject: [PATCH] Bug 1508484 - close audio queue if we already got the last audio frame when leaving 'loopingDecoding' state r=jya When we're going to leave looping state and have got EOS before, we should mark audio queue as ended because we have got all data we need. Differential Revision: https://phabricator.services.mozilla.com/D12373 --HG-- extra : moz-landing-system : lando --- dom/media/MediaDecoderStateMachine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 3f7f090fc87b..d2b498a070d0 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -762,8 +762,12 @@ class MediaDecoderStateMachine::LoopingDecodingState if (ShouldDiscardLoopedAudioData()) { mMaster->mAudioDataRequest.DisconnectIfExists(); DiscardLoopedAudioData(); + } + if (HasDecodedLastAudioFrame()) { AudioQueue().Finish(); } + mAudioDataRequest.DisconnectIfExists(); + mAudioSeekRequest.DisconnectIfExists(); DecodingState::Exit(); } @@ -890,6 +894,14 @@ class MediaDecoderStateMachine::LoopingDecodingState }); } + bool HasDecodedLastAudioFrame() const { + // when we're going to leave looping state and have got EOS before, we should + // mark audio queue as ended because we have got all data we need. + return mAudioDataRequest.Exists() || + mAudioSeekRequest.Exists() || + ShouldDiscardLoopedAudioData(); + } + media::TimeUnit mAudioLoopingOffset = media::TimeUnit::Zero(); MozPromiseRequestHolder mAudioSeekRequest; MozPromiseRequestHolder mAudioDataRequest;