diff --git a/content/media/VideoFrameContainer.cpp b/content/media/VideoFrameContainer.cpp index 4331941ade39..1dda5b658d8a 100644 --- a/content/media/VideoFrameContainer.cpp +++ b/content/media/VideoFrameContainer.cpp @@ -66,6 +66,19 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize, mPaintTarget = aTargetTime; } +void VideoFrameContainer::ClearCurrentFrame() +{ + MutexAutoLock lock(mMutex); + + // See comment in SetCurrentFrame for the reasoning behind + // using a kungFuDeathGrip here. + nsRefPtr kungFuDeathGrip; + kungFuDeathGrip = mImageContainer->LockCurrentImage(); + mImageContainer->UnlockCurrentImage(); + + mImageContainer->SetCurrentImage(nullptr); +} + ImageContainer* VideoFrameContainer::GetImageContainer() { return mImageContainer; } diff --git a/content/media/VideoFrameContainer.h b/content/media/VideoFrameContainer.h index 69d4d5710d6f..14f3bc06f3b3 100644 --- a/content/media/VideoFrameContainer.h +++ b/content/media/VideoFrameContainer.h @@ -46,6 +46,7 @@ public: // Call on any thread void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage, TimeStamp aTargetTime); + void ClearCurrentFrame(); // Time in seconds by which the last painted video frame was late by. // E.g. if the last painted frame should have been painted at time t, // but was actually painted at t+n, this returns n in seconds. Threadsafe. diff --git a/content/media/omx/nsMediaOmxReader.cpp b/content/media/omx/nsMediaOmxReader.cpp index 140e3967587b..b0f5ce890a03 100644 --- a/content/media/omx/nsMediaOmxReader.cpp +++ b/content/media/omx/nsMediaOmxReader.cpp @@ -98,6 +98,13 @@ nsresult nsMediaOmxReader::ReadMetadata(nsVideoInfo* aInfo, // Resets all state related to decoding, emptying all buffers etc. nsresult nsMediaOmxReader::ResetDecode() { + nsBuiltinDecoderReader::ResetDecode(); + + VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); + if (container) { + container->ClearCurrentFrame(); + } + if (mLastVideoFrame) { delete mLastVideoFrame; mLastVideoFrame = nullptr;