diff options
author | Andreas Huber <andih@google.com> | 2013-04-22 09:19:26 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-04-22 09:19:26 -0700 |
commit | a93686a4ace1e38eb6fa5da8fc97e97a19f4ac5c (patch) | |
tree | cde811c82bd8091477a472b6db99fa87d6410236 | |
parent | b9258b57aa0c86e4741e2c24474bb9d766d17e8e (diff) | |
parent | 4613b7e38b1830535cbf00e962afdfa5fe1308ba (diff) | |
download | frameworks_av-a93686a4ace1e38eb6fa5da8fc97e97a19f4ac5c.zip frameworks_av-a93686a4ace1e38eb6fa5da8fc97e97a19f4ac5c.tar.gz frameworks_av-a93686a4ace1e38eb6fa5da8fc97e97a19f4ac5c.tar.bz2 |
am 4613b7e3: Merge "3rd time\'s the charm, right? Fix another instance where MediaCodec would" into jb-mr2-dev
* commit '4613b7e38b1830535cbf00e962afdfa5fe1308ba':
3rd time's the charm, right? Fix another instance where MediaCodec would
-rw-r--r-- | include/media/stagefright/MediaCodec.h | 1 | ||||
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 54 |
2 files changed, 29 insertions, 26 deletions
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index 35f46dc..a06a8e1 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -176,6 +176,7 @@ private: kFlagDequeueInputPending = 16, kFlagDequeueOutputPending = 32, kFlagIsSecure = 64, + kFlagSawMediaServerDie = 128, }; struct BufferInfo { diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index e4e95d2..ae7bb17 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -506,6 +506,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { "(omx error 0x%08x, internalError %d)", omxError, internalError); + if (omxError == OMX_ErrorResourcesLost + && internalError == DEAD_OBJECT) { + mFlags |= kFlagSawMediaServerDie; + } + bool sendErrorReponse = true; switch (mState) { @@ -535,8 +540,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { sendErrorReponse = false; - if (omxError == OMX_ErrorResourcesLost - && internalError == DEAD_OBJECT) { + if (mFlags & kFlagSawMediaServerDie) { // MediaServer died, there definitely won't // be a shutdown complete notification after // all. @@ -999,29 +1003,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } case kWhatStop: - { - uint32_t replyID; - CHECK(msg->senderAwaitsResponse(&replyID)); - - if (mState != INITIALIZED - && mState != CONFIGURED && mState != STARTED) { - sp<AMessage> response = new AMessage; - response->setInt32("err", INVALID_OPERATION); - - response->postReply(replyID); - break; - } - - mReplyID = replyID; - setState(STOPPING); - - mCodec->initiateShutdown(true /* keepComponentAllocated */); - returnBuffersToCodec(); - break; - } - case kWhatRelease: { + State targetState = + (msg->what() == kWhatStop) ? INITIALIZED : UNINITIALIZED; + uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); @@ -1033,19 +1019,30 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // 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. + // Similarly stopping a stopped MediaCodec should be benign. sp<AMessage> response = new AMessage; response->setInt32( "err", - mState == UNINITIALIZED ? OK : INVALID_OPERATION); + mState == targetState ? OK : INVALID_OPERATION); response->postReply(replyID); break; } + if (mFlags & kFlagSawMediaServerDie) { + // It's dead, Jim. Don't expect initiateShutdown to yield + // any useful results now... + setState(UNINITIALIZED); + (new AMessage)->postReply(replyID); + break; + } + mReplyID = replyID; - setState(RELEASING); + setState(msg->what() == kWhatStop ? STOPPING : RELEASING); + + mCodec->initiateShutdown( + msg->what() == kWhatStop /* keepComponentAllocated */); - mCodec->initiateShutdown(); returnBuffersToCodec(); break; } @@ -1422,6 +1419,11 @@ void MediaCodec::setState(State newState) { if (newState == UNINITIALIZED) { mComponentName.clear(); + + // The component is gone, mediaserver's probably back up already + // but should definitely be back up should we try to instantiate + // another component.. and the cycle continues. + mFlags &= ~kFlagSawMediaServerDie; } mState = newState; |