Bug 1283370. Part 1 - remove unnecessary checks for Exists(). r=kaku
1. On{Audio,Video}[Not]Decoded() happens after |return mSeekTaskPromise.Ensure(__func__)|
in Seek(). mSeekTaskPromise is non-empty and Exists() will return true.
2. Is{Audio,Video}SeekComplete() is called indirectly from On{Audio,Video}[Not]Decoded()
where Exists() is guaranteed to be true.
MozReview-Commit-ID: DhaI8se8xPW
--- a/dom/media/NextFrameSeekTask.cpp
+++ b/dom/media/NextFrameSeekTask.cpp
@@ -243,30 +243,28 @@ NextFrameSeekTask::IsAudioSeekComplete()
{
AssertOwnerThread();
SAMPLE_LOG("IsAudioSeekComplete() curTarVal=%d aqFin=%d aqSz=%d req=%d wait=%d",
mSeekJob.Exists(), mIsAudioQueueFinished, !!mSeekedAudioData,
mReader->IsRequestingAudioData(), mReader->IsWaitingAudioData());
// Just make sure that we are not requesting or waiting for audio data. We
// don't really need to get an decoded audio data or get EOS here.
- return
- !HasAudio() ||
- (Exists() && !mReader->IsRequestingAudioData() && !mReader->IsWaitingAudioData());
+ return !HasAudio() ||
+ (!mReader->IsRequestingAudioData() && !mReader->IsWaitingAudioData());
}
bool
NextFrameSeekTask::IsVideoSeekComplete()
{
AssertOwnerThread();
SAMPLE_LOG("IsVideoSeekComplete() curTarVal=%d vqFin=%d vqSz=%d",
mSeekJob.Exists(), mIsVideoQueueFinished, !!mSeekedVideoData);
- return
- !HasVideo() || (Exists() && (mIsVideoQueueFinished || mSeekedVideoData));
+ return !HasVideo() || mIsVideoQueueFinished || mSeekedVideoData;
}
void
NextFrameSeekTask::CheckIfSeekComplete()
{
AssertOwnerThread();
const bool audioSeekComplete = IsAudioSeekComplete();
@@ -289,90 +287,76 @@ NextFrameSeekTask::CheckIfSeekComplete()
}
}
void
NextFrameSeekTask::OnAudioDecoded(MediaData* aAudioSample)
{
AssertOwnerThread();
MOZ_ASSERT(aAudioSample);
+ MOZ_ASSERT(!mSeekTaskPromise.IsEmpty(), "Seek shouldn't be finished");
// The MDSM::mDecodedAudioEndTime will be updated once the whole SeekTask is
// resolved.
SAMPLE_LOG("OnAudioDecoded [%lld,%lld] disc=%d",
aAudioSample->mTime,
aAudioSample->GetEndTime(),
aAudioSample->mDiscontinuity);
- if (!Exists()) {
- // We've received a sample from a previous decode. Discard it.
- return;
- }
-
// We accept any audio data here.
mSeekedAudioData = aAudioSample;
CheckIfSeekComplete();
}
void
NextFrameSeekTask::OnAudioNotDecoded(MediaDecoderReader::NotDecodedReason aReason)
{
AssertOwnerThread();
- SAMPLE_LOG("OnAudioNotDecoded (aReason=%u)", aReason);
+ MOZ_ASSERT(!mSeekTaskPromise.IsEmpty(), "Seek shouldn't be finished");
- if (!Exists()) {
- // We've received a sample from a previous decode. Discard it.
- return;
- }
+ SAMPLE_LOG("OnAudioNotDecoded (aReason=%u)", aReason);
// We don't really handle audio deocde error here. Let MDSM to trigger further
// audio decoding tasks if it needs to play audio, and MDSM will then receive
// the decoding state from MediaDecoderReader.
CheckIfSeekComplete();
}
void
NextFrameSeekTask::OnVideoDecoded(MediaData* aVideoSample)
{
AssertOwnerThread();
MOZ_ASSERT(aVideoSample);
+ MOZ_ASSERT(!mSeekTaskPromise.IsEmpty(), "Seek shouldn't be finished");
// The MDSM::mDecodedVideoEndTime will be updated once the whole SeekTask is
// resolved.
SAMPLE_LOG("OnVideoDecoded [%lld,%lld] disc=%d",
aVideoSample->mTime,
aVideoSample->GetEndTime(),
aVideoSample->mDiscontinuity);
- if (!Exists()) {
- // We've received a sample from a previous decode. Discard it.
- return;
- }
-
if (aVideoSample->mTime > mCurrentTimeBeforeSeek) {
mSeekedVideoData = aVideoSample;
}
CheckIfSeekComplete();
}
void
NextFrameSeekTask::OnVideoNotDecoded(MediaDecoderReader::NotDecodedReason aReason)
{
AssertOwnerThread();
- SAMPLE_LOG("OnVideoNotDecoded (aReason=%u)", aReason);
+ MOZ_ASSERT(!mSeekTaskPromise.IsEmpty(), "Seek shouldn't be finished");
- if (!Exists()) {
- // We've received a sample from a previous decode. Discard it.
- return;
- }
+ SAMPLE_LOG("OnVideoNotDecoded (aReason=%u)", aReason);
if (aReason == MediaDecoderReader::DECODE_ERROR) {
if (mVideoQueue.GetSize() > 0) {
// The video decoding request might be filed by MDSM not the
// NextFrameSeekTask itself. So, the NextFrameSeekTask might has already
// found its target in the VideoQueue but still waits the video decoding
// request (which is filed by the MDSM) to be resolved. In this case, we
// already have the target of this seek task, try to resolve this task.