Bug 1195939 - Flush decode queue on Reset() in gmp-clearkey - r=cpearce

This commit is contained in:
Edwin Flores 2015-08-19 15:06:36 -07:00
parent 40cfde0cb6
commit c5d9bab270
2 changed files with 27 additions and 3 deletions

View File

@ -33,6 +33,7 @@ VideoDecoder::VideoDecoder(GMPVideoHost *aHostAPI)
, mMutex(nullptr)
, mNumInputTasks(0)
, mSentExtraData(false)
, mIsFlushing(false)
, mHasShutdown(false)
{
// We drop the ref in DecodingComplete().
@ -140,6 +141,11 @@ VideoDecoder::DecodeTask(GMPVideoEncodedFrame* aInput)
AutoReleaseVideoFrame ensureFrameReleased(aInput);
HRESULT hr;
if (mIsFlushing) {
CK_LOGD("VideoDecoder::DecodeTask rejecting frame: flushing.");
return;
}
{
AutoLock lock(mMutex);
mNumInputTasks--;
@ -343,15 +349,29 @@ VideoDecoder::SampleToVideoFrame(IMFSample* aSample,
return S_OK;
}
void
VideoDecoder::ResetCompleteTask()
{
mIsFlushing = false;
if (mCallback) {
MaybeRunOnMainThread(WrapTask(mCallback,
&GMPVideoDecoderCallback::ResetComplete));
}
}
void
VideoDecoder::Reset()
{
mIsFlushing = true;
if (mDecoder) {
mDecoder->Reset();
}
if (mCallback) {
mCallback->ResetComplete();
}
// Schedule ResetComplete callback to run after existing frames have been
// flushed out of the task queue.
EnsureWorker();
mWorkerThread->Post(WrapTaskRefCounted(this,
&VideoDecoder::ResetCompleteTask));
}
void

View File

@ -60,6 +60,8 @@ private:
void DecodeTask(GMPVideoEncodedFrame* aInputFrame);
void ResetCompleteTask();
void ReturnOutput(IMFSample* aSample,
int32_t aWidth,
int32_t aHeight,
@ -85,6 +87,8 @@ private:
int32_t mNumInputTasks;
bool mSentExtraData;
std::atomic<bool> mIsFlushing;
bool mHasShutdown;
};