From 33223c4f97abb78fa8c92e1b8c817546f15d97e1 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Mon, 3 Nov 2014 17:06:30 -0800 Subject: MediaCodec: Prevent stop() in the UNINITIALIZED state Return INVALID_OPERATION instead. This is a corner case when the decoder is still allocated, occurring after codec error. Bug: 18121124 Change-Id: If87e44dd40db48f63f965b765205f1e733663efd --- media/libstagefright/MediaCodec.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'media') diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index df47bd5..b3c12bf 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -1339,9 +1339,12 @@ void MediaCodec::onMessageReceived(const sp &msg) { uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); - if (!(mFlags & kFlagIsComponentAllocated) && mState != INITIALIZED + if (!((mFlags & kFlagIsComponentAllocated) && targetState == UNINITIALIZED) // See 1 + && mState != INITIALIZED && mState != CONFIGURED && !isExecuting()) { - // We may be in "UNINITIALIZED" state already and + // 1) Permit release to shut down the component if allocated. + // + // 2) We may be in "UNINITIALIZED" state already and // also shutdown the encoder/decoder without the // client being aware of this if media server died while // we were being stopped. The client would assume that -- cgit v1.1