Bug 634747 - Set MediaQueue's to Finished() when we reach end of stream while decoding after seeking and while finding first frame. r=kinetik

This commit is contained in:
Chris Pearce 2014-02-25 18:45:03 +13:00
parent 26cf62ec1a
commit 61d66690f5
3 changed files with 18 additions and 12 deletions

View File

@ -81,6 +81,9 @@ VideoData* MediaDecoderReader::DecodeToFirstVideoData()
bool keyframeSkip = false;
eof = !DecodeVideoFrame(keyframeSkip, 0);
}
if (eof) {
VideoQueue().Finish();
}
VideoData* d = nullptr;
return (d = VideoQueue().PeekFront()) ? d : nullptr;
}
@ -97,6 +100,9 @@ AudioData* MediaDecoderReader::DecodeToFirstAudioData()
}
eof = !DecodeAudioData();
}
if (eof) {
AudioQueue().Finish();
}
AudioData* d = nullptr;
return (d = AudioQueue().PeekFront()) ? d : nullptr;
}
@ -155,11 +161,12 @@ nsresult MediaDecoderReader::DecodeToTarget(int64_t aTarget)
}
}
}
if (VideoQueue().GetSize() == 0) {
if (eof) {
// Hit end of file, we want to display the last frame of the video.
if (video) {
VideoQueue().PushFront(video.forget());
}
VideoQueue().Finish();
break;
}
video = VideoQueue().PeekFront();
@ -198,8 +205,10 @@ nsresult MediaDecoderReader::DecodeToTarget(int64_t aTarget)
}
}
const AudioData* audio = AudioQueue().PeekFront();
if (!audio)
if (!audio || eof) {
AudioQueue().Finish();
break;
}
CheckedInt64 startFrame = UsecsToFrames(audio->mTime, mInfo.mAudio.mRate);
CheckedInt64 targetFrame = UsecsToFrames(aTarget, mInfo.mAudio.mRate);
if (!startFrame.isValid() || !targetFrame.isValid()) {

View File

@ -1799,17 +1799,19 @@ void MediaDecoderStateMachine::DecodeSeek()
}
if (NS_SUCCEEDED(res)) {
AudioData* audio = HasAudio() ? mReader->AudioQueue().PeekFront() : nullptr;
NS_ASSERTION(!audio || (audio->mTime <= seekTime &&
seekTime <= audio->mTime + audio->mDuration),
"Seek target should lie inside the first audio block after seek");
MOZ_ASSERT(!audio ||
(audio->mTime <= seekTime &&
seekTime <= audio->mTime + audio->mDuration) ||
mReader->AudioQueue().IsFinished(),
"Seek target should lie inside the first audio block after seek");
int64_t startTime = (audio && audio->mTime < seekTime) ? audio->mTime : seekTime;
mAudioStartTime = startTime;
mPlayDuration = startTime - mStartTime;
if (HasVideo()) {
VideoData* video = mReader->VideoQueue().PeekFront();
if (video) {
NS_ASSERTION((video->mTime <= seekTime && seekTime <= video->GetEndTime()) ||
mReader->VideoQueue().IsFinished(),
MOZ_ASSERT((video->mTime <= seekTime && seekTime <= video->GetEndTime()) ||
mReader->VideoQueue().IsFinished(),
"Seek target should lie inside the first frame after seek, unless it's the last frame.");
{
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());

View File

@ -15,11 +15,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=495300
<pre id="test">
<script class="testbody" type="text/javascript">
if (!navigator.platform.startsWith("Mac")) {
// not Mac
SimpleTest.expectAssertions(0, 2);
}
var manager = new MediaTestManager;
function filename(uri) {