Bug 791912 - Fix crash when using libstagefright during video playback shutdown on B2G - r=cpearce

This commit is contained in:
Chris Double 2012-09-27 16:33:43 +12:00
parent 25e059e58e
commit 411020abf7
3 changed files with 21 additions and 0 deletions

View File

@ -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<Image> kungFuDeathGrip;
kungFuDeathGrip = mImageContainer->LockCurrentImage();
mImageContainer->UnlockCurrentImage();
mImageContainer->SetCurrentImage(nullptr);
}
ImageContainer* VideoFrameContainer::GetImageContainer() {
return mImageContainer;
}

View File

@ -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.

View File

@ -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;