Bug 1107274 - Don't return EOS from MP4Reader until all frames have been output. r=cpearce

This commit is contained in:
Matt Woodrow 2014-12-04 11:51:30 -08:00
parent bd450995fd
commit a79a317823
2 changed files with 17 additions and 15 deletions

View File

@ -569,7 +569,7 @@ MP4Reader::NeedInput(DecoderData& aDecoder)
// which overrides our "few more samples" threshold.
return
!aDecoder.mError &&
!aDecoder.mEOS &&
!aDecoder.mDemuxEOS &&
aDecoder.mOutputRequested &&
aDecoder.mOutput.IsEmpty() &&
(aDecoder.mInputExhausted ||
@ -583,6 +583,7 @@ MP4Reader::Update(TrackType aTrack)
bool needInput = false;
bool needOutput = false;
bool eos = false;
auto& decoder = GetDecoderData(aTrack);
nsRefPtr<MediaData> output;
{
@ -598,6 +599,7 @@ MP4Reader::Update(TrackType aTrack)
output = decoder.mOutput[0];
decoder.mOutput.RemoveElementAt(0);
}
eos = decoder.mDrainComplete;
}
VLOG("Update(%s) ni=%d no=%d iex=%d or=%d fl=%d",
TrackTypeToStr(aTrack),
@ -614,8 +616,8 @@ MP4Reader::Update(TrackType aTrack)
} else {
{
MonitorAutoLock lock(decoder.mMonitor);
MOZ_ASSERT(!decoder.mEOS);
decoder.mEOS = true;
MOZ_ASSERT(!decoder.mDemuxEOS);
decoder.mDemuxEOS = true;
}
// DrainComplete takes care of reporting EOS upwards
decoder.mDecoder->Drain();
@ -624,6 +626,8 @@ MP4Reader::Update(TrackType aTrack)
if (needOutput) {
if (output) {
ReturnOutput(output, aTrack);
} else if (eos) {
ReturnEOS(aTrack);
}
}
}
@ -727,14 +731,9 @@ void
MP4Reader::DrainComplete(TrackType aTrack)
{
DecoderData& data = GetDecoderData(aTrack);
bool eos;
{
MonitorAutoLock mon(data.mMonitor);
eos = data.mEOS;
}
if (eos) {
ReturnEOS(aTrack);
}
MonitorAutoLock mon(data.mMonitor);
data.mDrainComplete = true;
ScheduleUpdate(aTrack);
}
void
@ -773,7 +772,8 @@ MP4Reader::Flush(TrackType aTrack)
{
MonitorAutoLock mon(data.mMonitor);
data.mIsFlushing = true;
data.mEOS = false;
data.mDemuxEOS = false;
data.mDrainComplete = false;
}
data.mDecoder->Flush();
{
@ -814,7 +814,7 @@ MP4Reader::SkipVideoDemuxToNextKeyFrame(int64_t aTimeThreshold, uint32_t& parsed
RequestSampleCallback::END_OF_STREAM);
{
MonitorAutoLock mon(mVideo.mMonitor);
mVideo.mEOS = true;
mVideo.mDemuxEOS = true;
}
return false;
}

View File

@ -158,7 +158,8 @@ private:
, mIsFlushing(false)
, mOutputRequested(false)
, mUpdateScheduled(false)
, mEOS(false)
, mDemuxEOS(false)
, mDrainComplete(false)
, mDiscontinuity(false)
{
}
@ -187,7 +188,8 @@ private:
bool mIsFlushing;
bool mOutputRequested;
bool mUpdateScheduled;
bool mEOS;
bool mDemuxEOS;
bool mDrainComplete;
bool mDiscontinuity;
};
DecoderData mAudio;