From 1b0c739cdaeafe5ed3571e5bfb2ead0aeccd33e8 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Tue, 28 Jan 2014 21:20:58 -0500 Subject: [PATCH] Bug 963624 - Always release video's media buffer in ReleaseAllPendingVideoBuffersLocked() and same thread. r=doublec, a=1.3+ --- content/media/omx/OmxDecoder.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/content/media/omx/OmxDecoder.cpp b/content/media/omx/OmxDecoder.cpp index 9e0598cbedb8..e8ccbe759a1a 100644 --- a/content/media/omx/OmxDecoder.cpp +++ b/content/media/omx/OmxDecoder.cpp @@ -178,9 +178,18 @@ VideoGraphicBuffer::VideoGraphicBuffer(const android::wp aO VideoGraphicBuffer::~VideoGraphicBuffer() { - if (mMediaBuffer) { + android::sp omxDecoder = mOmxDecoder.promote(); + if (mMediaBuffer && omxDecoder.get()) { + // Post kNotifyPostReleaseVideoBuffer message to OmxDecoder via ALooper. + // The message is delivered to OmxDecoder on ALooper thread. + // MediaBuffer::release() could take a very long time. + // PostReleaseVideoBuffer() prevents long time locking. + omxDecoder->PostReleaseVideoBuffer(mMediaBuffer, mReleaseFenceHandle); + } else if (mMediaBuffer) { + NS_WARNING("OmxDecoder is not present"); mMediaBuffer->release(); } + mMediaBuffer = nullptr; } void @@ -766,7 +775,7 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs, { Mutex::Autolock autoLock(mSeekLock); mIsVideoSeeking = false; - ReleaseAllPendingVideoBuffersLocked(); + PostReleaseVideoBuffer(nullptr, FenceHandle()); } aDoSeek = false; @@ -993,7 +1002,9 @@ void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle& { { Mutex::Autolock autoLock(mPendingVideoBuffersLock); - mPendingVideoBuffers.push(BufferItem(aBuffer, aReleaseFenceHandle)); + if (aBuffer) { + mPendingVideoBuffers.push(BufferItem(aBuffer, aReleaseFenceHandle)); + } } sp notify = -- 2.11.4.GIT