Bug 1325004. Part 2 - let AccurateSeekingState call Push{Audio,Video} instead. r?kikuo
AccurateSeekingState can stop decoding once there is one sample in the queue.
MozReview-Commit-ID: 76C7vX7ua14
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -862,25 +862,25 @@ public:
{
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
MOZ_ASSERT(aAudio);
// Video-only seek doesn't reset audio decoder. There might be pending audio
// requests when AccurateSeekTask::Seek() begins. We will just store the data
// without checking |mDiscontinuity| or calling DropAudioUpToSeekTarget().
if (mSeekJob.mTarget->IsVideoOnly()) {
- mMaster->Push(aAudio);
+ mMaster->PushAudio(aAudio);
return;
}
AdjustFastSeekIfNeeded(aAudio);
if (mSeekJob.mTarget->IsFast()) {
// Non-precise seek; we can stop the seek at the first sample.
- mMaster->Push(aAudio);
+ mMaster->PushAudio(aAudio);
mDoneAudioSeeking = true;
} else {
nsresult rv = DropAudioUpToSeekTarget(aAudio->As<AudioData>());
if (NS_FAILED(rv)) {
mMaster->DecodeError(rv);
return;
}
}
@@ -896,17 +896,17 @@ public:
{
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking, "Seek shouldn't be finished");
MOZ_ASSERT(aVideo);
AdjustFastSeekIfNeeded(aVideo);
if (mSeekJob.mTarget->IsFast()) {
// Non-precise seek. We can stop the seek at the first sample.
- mMaster->Push(aVideo);
+ mMaster->PushVideo(aVideo);
mDoneVideoSeeking = true;
} else {
nsresult rv = DropVideoUpToSeekTarget(aVideo);
if (NS_FAILED(rv)) {
mMaster->DecodeError(rv);
return;
}
}
@@ -943,23 +943,23 @@ public:
return;
}
if (aError == NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
if (aType == MediaData::AUDIO_DATA) {
AudioQueue().Finish();
mDoneAudioSeeking = true;
} else {
- VideoQueue().Finish();
- mDoneVideoSeeking = true;
if (mFirstVideoFrameAfterSeek) {
// Hit the end of stream. Move mFirstVideoFrameAfterSeek into
// mSeekedVideoData so we have something to display after seeking.
- mMaster->Push(mFirstVideoFrameAfterSeek);
+ mMaster->PushVideo(mFirstVideoFrameAfterSeek);
}
+ VideoQueue().Finish();
+ mDoneVideoSeeking = true;
}
MaybeFinishSeek();
return;
}
// This is a decode error, delegate to the generic error path.
mMaster->DecodeError(aError);
}
@@ -1144,17 +1144,17 @@ private:
// The seek target doesn't lie in the audio block just after the last
// audio frames we've seen which were before the seek target. This
// could have been the first audio data we've seen after seek, i.e. the
// seek terminated after the seek target in the audio stream. Just
// abort the audio decode-to-target, the state machine will play
// silence to cover the gap. Typically this happens in poorly muxed
// files.
SWARN("Audio not synced after seek, maybe a poorly muxed file?");
- mMaster->Push(aAudio);
+ mMaster->PushAudio(aAudio);
mDoneAudioSeeking = true;
return NS_OK;
}
// The seek target lies somewhere in this AudioData's frames, strip off
// any frames which lie before the seek target, so we'll begin playback
// exactly at the seek target.
NS_ASSERTION(mSeekJob.mTarget->GetTime().ToMicroseconds() >= aAudio->mTime,
@@ -1190,17 +1190,17 @@ private:
RefPtr<AudioData> data(new AudioData(aAudio->mOffset,
mSeekJob.mTarget->GetTime().ToMicroseconds(),
duration.value(),
frames,
Move(audioData),
channels,
aAudio->mRate));
MOZ_ASSERT(AudioQueue().GetSize() == 0, "Should be the 1st sample after seeking");
- mMaster->Push(data);
+ mMaster->PushAudio(data);
mDoneAudioSeeking = true;
return NS_OK;
}
nsresult DropVideoUpToSeekTarget(MediaData* aSample)
{
RefPtr<VideoData> video(aSample->As<VideoData>());
@@ -1222,17 +1222,17 @@ private:
video->UpdateTimestamp(target);
}
mFirstVideoFrameAfterSeek = nullptr;
SLOG("DropVideoUpToSeekTarget() found video frame [%lld, %lld] containing target=%lld",
video->mTime, video->GetEndTime(), target);
MOZ_ASSERT(VideoQueue().GetSize() == 0, "Should be the 1st sample after seeking");
- mMaster->Push(video);
+ mMaster->PushVideo(video);
mDoneVideoSeeking = true;
}
return NS_OK;
}
void MaybeFinishSeek()
{