From b1d666f5cb555d135eb69e005e88a03330bbb54c Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Wed, 19 Oct 2011 21:14:13 -0700 Subject: Stagefright: idle OMX after ANW errors This change fixes an issue in Stagefright where the state of an OMXCodec object can get out of sync with the state of the OMX component. In particular, if one of the ANativeWindow functions failed and put the OMXCodec into the ERROR state, this would cause Stagefright to skip doing the Executing -> Idle transition. Without this transition the freeBuffersOnPort call would never be made, and the MediaBuffers would end up being leaked (which would also leak the Gralloc buffers they reference). Bug: 5333695 Change-Id: I85ea0cf92d18e7ef6d35c7d1e2a7b4e2c9745d34 --- media/libstagefright/OMXCodec.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/OMXCodec.cpp') diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 7c34257..1128771 100755 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -3600,11 +3600,24 @@ status_t OMXCodec::stop() { mAsyncCompletion.wait(mLock); } + bool isError = false; switch (mState) { case LOADED: - case ERROR: break; + case ERROR: + { + OMX_STATETYPE state = OMX_StateInvalid; + status_t err = mOMX->getState(mNode, &state); + CHECK_EQ(err, (status_t)OK); + + if (state != OMX_StateExecuting) { + break; + } + // else fall through to the idling code + isError = true; + } + case EXECUTING: { setState(EXECUTING_TO_IDLE); @@ -3639,6 +3652,12 @@ status_t OMXCodec::stop() { mAsyncCompletion.wait(mLock); } + if (isError) { + // We were in the ERROR state coming in, so restore that now + // that we've idled the OMX component. + setState(ERROR); + } + break; } -- cgit v1.1