diff options
author | Andreas Huber <andih@google.com> | 2013-04-18 13:24:17 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2013-04-18 13:24:17 -0700 |
commit | 03ddaec84b65157af1dbf022a72de778dc59a63e (patch) | |
tree | 3016a637c6e953cc3dd7a17f46343645a3e0213a /media/libstagefright/MediaCodec.cpp | |
parent | 64595e6727c478d3d80c7babbecdb470398f8c42 (diff) | |
download | frameworks_av-03ddaec84b65157af1dbf022a72de778dc59a63e.zip frameworks_av-03ddaec84b65157af1dbf022a72de778dc59a63e.tar.gz frameworks_av-03ddaec84b65157af1dbf022a72de778dc59a63e.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.cpp | 24 |
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; |