mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1195939 - Flush decode queue on Reset() in gmp-clearkey - r=cpearce
This commit is contained in:
parent
59622789d0
commit
4fb5963327
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user