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
This commit is contained in:
alwu 2018-11-20 22:42:24 +00:00
Родитель 8a7fef1076
Коммит ce1f4614d0
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -762,8 +762,12 @@ class MediaDecoderStateMachine::LoopingDecodingState
if (ShouldDiscardLoopedAudioData()) { if (ShouldDiscardLoopedAudioData()) {
mMaster->mAudioDataRequest.DisconnectIfExists(); mMaster->mAudioDataRequest.DisconnectIfExists();
DiscardLoopedAudioData(); DiscardLoopedAudioData();
}
if (HasDecodedLastAudioFrame()) {
AudioQueue().Finish(); AudioQueue().Finish();
} }
mAudioDataRequest.DisconnectIfExists();
mAudioSeekRequest.DisconnectIfExists();
DecodingState::Exit(); 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(); media::TimeUnit mAudioLoopingOffset = media::TimeUnit::Zero();
MozPromiseRequestHolder<MediaFormatReader::SeekPromise> mAudioSeekRequest; MozPromiseRequestHolder<MediaFormatReader::SeekPromise> mAudioSeekRequest;
MozPromiseRequestHolder<AudioDataPromise> mAudioDataRequest; MozPromiseRequestHolder<AudioDataPromise> mAudioDataRequest;