Bug 1313548: P1. Always resolve waiting promise, when clearing waitforkey. r=gerald

MozReview-Commit-ID: 6xu8Rcn9WMO

--HG--
extra : rebase_source : 54f99f2d4fc6370ee64a6e3dc0bec69f5edc9085
This commit is contained in:
Jean-Yves Avenard 2017-02-23 14:10:12 +01:00
Родитель f6dc8cf256
Коммит 2a41ec036c
2 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -2279,14 +2279,10 @@ MediaFormatReader::Update(TrackType aTrack)
return;
}
if (decoder.mWaitingForKey) {
decoder.mWaitingForKey = false;
if (decoder.HasWaitingPromise() && !decoder.IsWaiting()) {
if (decoder.CancelWaitingForKey()) {
LOGV("No longer waiting for key. Resolving waiting promise");
decoder.mWaitingPromise.Resolve(decoder.mType, __func__);
return;
}
}
if (!needInput) {
LOGV("No need for additional input (pending:%u)",

Просмотреть файл

@ -349,6 +349,7 @@ private:
mDecodeRequest.DisconnectIfExists();
mDrainRequest.DisconnectIfExists();
mDrainState = DrainState::None;
CancelWaitingForKey();
mOutput.Clear();
mNumSamplesInput = 0;
mNumSamplesOutput = 0;
@ -381,6 +382,19 @@ private:
mFlushed = true;
}
bool CancelWaitingForKey()
{
if (!mWaitingForKey) {
return false;
}
mWaitingForKey = false;
if (IsWaiting() || mWaitingPromise.IsEmpty()) {
return false;
}
mWaitingPromise.Resolve(mType, __func__);
return true;
}
// Reset the state of the DecoderData, clearing all queued frames
// (pending demuxed and decoded).
// The track demuxer is *not* reset.
@ -389,11 +403,11 @@ private:
MOZ_ASSERT(mOwner->OnTaskQueue());
mDemuxEOS = false;
mWaitingForData = false;
mWaitingForKey = false;
mQueuedSamples.Clear();
mDecodeRequest.DisconnectIfExists();
mDrainRequest.DisconnectIfExists();
mDrainState = DrainState::None;
CancelWaitingForKey();
mTimeThreshold.reset();
mLastSampleTime.reset();
mOutput.Clear();