summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MediaCodec.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2013-04-18 13:24:17 -0700
committerAndreas Huber <andih@google.com>2013-04-18 13:24:17 -0700
commit815dd298dc903606181afee3aec23e9cee629e8f (patch)
treed4a31db8e4b1b7ef0d5026a5a9025519e92ab3ce /media/libstagefright/MediaCodec.cpp
parent005bb86bd99077283df1968958d5c514a3bfa16a (diff)
downloadframeworks_av-815dd298dc903606181afee3aec23e9cee629e8f.zip
frameworks_av-815dd298dc903606181afee3aec23e9cee629e8f.tar.gz
frameworks_av-815dd298dc903606181afee3aec23e9cee629e8f.tar.bz2
Make sure MediaCodec::stop() and MediaCodec::release() still return
instead of blocking indefinitely if the mediaserver died while the call is pending. Change-Id: If2789b7fe99634d947ce4a3bb69c04baff5f8b10 related-to-bug: 8397711
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r--media/libstagefright/MediaCodec.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 0d89c0f..e4e95d2 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -534,6 +534,20 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
// the shutdown complete notification.
sendErrorReponse = false;
+
+ if (omxError == OMX_ErrorResourcesLost
+ && internalError == DEAD_OBJECT) {
+ // MediaServer died, there definitely won't
+ // be a shutdown complete notification after
+ // all.
+
+ // note that we're directly going from
+ // STOPPING->UNINITIALIZED, instead of the
+ // usual STOPPING->INITIALIZED state.
+ setState(UNINITIALIZED);
+
+ (new AMessage)->postReply(mReplyID);
+ }
break;
}
@@ -1013,8 +1027,16 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
if (mState != INITIALIZED
&& mState != CONFIGURED && mState != STARTED) {
+ // We may be in "UNINITIALIZED" state already without the
+ // client being aware of this if media server died while
+ // we were being stopped. The client would assume that
+ // after stop() returned, it would be safe to call release()
+ // and it should be in this case, no harm to allow a release()
+ // if we're already uninitialized.
sp<AMessage> response = new AMessage;
- response->setInt32("err", INVALID_OPERATION);
+ response->setInt32(
+ "err",
+ mState == UNINITIALIZED ? OK : INVALID_OPERATION);
response->postReply(replyID);
break;