Bug 1180935: P1. Do not drain decoders when waiting for data. r=cpearce

We made the design decision that it was preferable to decode as much of what we had, even if that meant we couldn't decode some frames upon resume.
This can cause significant apparent stalls with some YouTube videos where keyframes are up to 4.2s appart (128 frames).
This commit is contained in:
Jean-Yves Avenard 2015-08-12 21:24:48 +10:00
parent 443f548ac2
commit 398014c093

View File

@ -762,8 +762,8 @@ void
MediaFormatReader::NotifyNewOutput(TrackType aTrack, MediaData* aSample) MediaFormatReader::NotifyNewOutput(TrackType aTrack, MediaData* aSample)
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
LOGV("Received new sample time:%lld duration:%lld", LOGV("Received new %s sample time:%lld duration:%lld",
aSample->mTime, aSample->mDuration); TrackTypeToStr(aTrack), aSample->mTime, aSample->mDuration);
auto& decoder = GetDecoderData(aTrack); auto& decoder = GetDecoderData(aTrack);
if (!decoder.mOutputRequested) { if (!decoder.mOutputRequested) {
LOG("MediaFormatReader produced output while flushing, discarding."); LOG("MediaFormatReader produced output while flushing, discarding.");
@ -815,7 +815,6 @@ MediaFormatReader::NotifyWaitingForData(TrackType aTrack)
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack); auto& decoder = GetDecoderData(aTrack);
decoder.mWaitingForData = true; decoder.mWaitingForData = true;
decoder.mNeedDraining = true;
ScheduleUpdate(aTrack); ScheduleUpdate(aTrack);
} }
@ -979,7 +978,7 @@ MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
info->GetID()); info->GetID());
decoder.mNeedDraining = true; decoder.mNeedDraining = true;
decoder.mNextStreamSourceID = Some(info->GetID()); decoder.mNextStreamSourceID = Some(info->GetID());
DrainDecoder(aTrack); ScheduleUpdate(aTrack);
return; return;
} }
@ -1094,6 +1093,12 @@ MediaFormatReader::Update(TrackType aTrack)
return; return;
} }
if (!decoder.HasPromise() && decoder.mWaitingForData) {
// Nothing more we can do at present.
LOGV("Still waiting for data.");
return;
}
// Record number of frames decoded and parsed. Automatically update the // Record number of frames decoded and parsed. Automatically update the
// stats counters using the AutoNotifyDecoded stack-based class. // stats counters using the AutoNotifyDecoded stack-based class.
AbstractMediaDecoder::AutoNotifyDecoded a(mDecoder); AbstractMediaDecoder::AutoNotifyDecoded a(mDecoder);
@ -1138,17 +1143,18 @@ MediaFormatReader::Update(TrackType aTrack)
return; return;
} else if (decoder.mDemuxEOS) { } else if (decoder.mDemuxEOS) {
decoder.RejectPromise(END_OF_STREAM, __func__); decoder.RejectPromise(END_OF_STREAM, __func__);
} else if (decoder.mWaitingForData) {
LOG("Waiting For Data");
decoder.RejectPromise(WAITING_FOR_DATA, __func__);
} }
} else if (decoder.mError && !decoder.mDecoder) { } else if (decoder.mError && !decoder.mDecoder) {
decoder.RejectPromise(DECODE_ERROR, __func__); decoder.RejectPromise(DECODE_ERROR, __func__);
return; return;
} else if (decoder.mWaitingForData) {
LOG("Waiting For Data");
decoder.RejectPromise(WAITING_FOR_DATA, __func__);
return;
} }
} }
if (decoder.mError || decoder.mDemuxEOS || decoder.mWaitingForData) { if (decoder.mNeedDraining) {
DrainDecoder(aTrack); DrainDecoder(aTrack);
return; return;
} }