Loading include/media/stagefright/MediaCodec.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -176,6 +176,7 @@ private: kFlagDequeueInputPending = 16, kFlagDequeueInputPending = 16, kFlagDequeueOutputPending = 32, kFlagDequeueOutputPending = 32, kFlagIsSecure = 64, kFlagIsSecure = 64, kFlagSawMediaServerDie = 128, }; }; struct BufferInfo { struct BufferInfo { Loading media/libstagefright/MediaCodec.cpp +28 −26 Original line number Original line Diff line number Diff line Loading @@ -506,6 +506,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { "(omx error 0x%08x, internalError %d)", "(omx error 0x%08x, internalError %d)", omxError, internalError); omxError, internalError); if (omxError == OMX_ErrorResourcesLost && internalError == DEAD_OBJECT) { mFlags |= kFlagSawMediaServerDie; } bool sendErrorReponse = true; bool sendErrorReponse = true; switch (mState) { switch (mState) { Loading Loading @@ -535,8 +540,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { sendErrorReponse = false; sendErrorReponse = false; if (omxError == OMX_ErrorResourcesLost if (mFlags & kFlagSawMediaServerDie) { && internalError == DEAD_OBJECT) { // MediaServer died, there definitely won't // MediaServer died, there definitely won't // be a shutdown complete notification after // be a shutdown complete notification after // all. // all. Loading Loading @@ -999,29 +1003,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } } case kWhatStop: 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: case kWhatRelease: { { State targetState = (msg->what() == kWhatStop) ? INITIALIZED : UNINITIALIZED; uint32_t replyID; uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); CHECK(msg->senderAwaitsResponse(&replyID)); Loading @@ -1033,19 +1019,30 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // after stop() returned, it would be safe to call release() // after stop() returned, it would be safe to call release() // and it should be in this case, no harm to allow a release() // and it should be in this case, no harm to allow a release() // if we're already uninitialized. // if we're already uninitialized. // Similarly stopping a stopped MediaCodec should be benign. sp<AMessage> response = new AMessage; sp<AMessage> response = new AMessage; response->setInt32( response->setInt32( "err", "err", mState == UNINITIALIZED ? OK : INVALID_OPERATION); mState == targetState ? OK : INVALID_OPERATION); response->postReply(replyID); response->postReply(replyID); break; 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; mReplyID = replyID; setState(RELEASING); setState(msg->what() == kWhatStop ? STOPPING : RELEASING); mCodec->initiateShutdown( msg->what() == kWhatStop /* keepComponentAllocated */); mCodec->initiateShutdown(); returnBuffersToCodec(); returnBuffersToCodec(); break; break; } } Loading Loading @@ -1422,6 +1419,11 @@ void MediaCodec::setState(State newState) { if (newState == UNINITIALIZED) { if (newState == UNINITIALIZED) { mComponentName.clear(); 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; mState = newState; Loading Loading
include/media/stagefright/MediaCodec.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -176,6 +176,7 @@ private: kFlagDequeueInputPending = 16, kFlagDequeueInputPending = 16, kFlagDequeueOutputPending = 32, kFlagDequeueOutputPending = 32, kFlagIsSecure = 64, kFlagIsSecure = 64, kFlagSawMediaServerDie = 128, }; }; struct BufferInfo { struct BufferInfo { Loading
media/libstagefright/MediaCodec.cpp +28 −26 Original line number Original line Diff line number Diff line Loading @@ -506,6 +506,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { "(omx error 0x%08x, internalError %d)", "(omx error 0x%08x, internalError %d)", omxError, internalError); omxError, internalError); if (omxError == OMX_ErrorResourcesLost && internalError == DEAD_OBJECT) { mFlags |= kFlagSawMediaServerDie; } bool sendErrorReponse = true; bool sendErrorReponse = true; switch (mState) { switch (mState) { Loading Loading @@ -535,8 +540,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { sendErrorReponse = false; sendErrorReponse = false; if (omxError == OMX_ErrorResourcesLost if (mFlags & kFlagSawMediaServerDie) { && internalError == DEAD_OBJECT) { // MediaServer died, there definitely won't // MediaServer died, there definitely won't // be a shutdown complete notification after // be a shutdown complete notification after // all. // all. Loading Loading @@ -999,29 +1003,11 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } } case kWhatStop: 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: case kWhatRelease: { { State targetState = (msg->what() == kWhatStop) ? INITIALIZED : UNINITIALIZED; uint32_t replyID; uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); CHECK(msg->senderAwaitsResponse(&replyID)); Loading @@ -1033,19 +1019,30 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // after stop() returned, it would be safe to call release() // after stop() returned, it would be safe to call release() // and it should be in this case, no harm to allow a release() // and it should be in this case, no harm to allow a release() // if we're already uninitialized. // if we're already uninitialized. // Similarly stopping a stopped MediaCodec should be benign. sp<AMessage> response = new AMessage; sp<AMessage> response = new AMessage; response->setInt32( response->setInt32( "err", "err", mState == UNINITIALIZED ? OK : INVALID_OPERATION); mState == targetState ? OK : INVALID_OPERATION); response->postReply(replyID); response->postReply(replyID); break; 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; mReplyID = replyID; setState(RELEASING); setState(msg->what() == kWhatStop ? STOPPING : RELEASING); mCodec->initiateShutdown( msg->what() == kWhatStop /* keepComponentAllocated */); mCodec->initiateShutdown(); returnBuffersToCodec(); returnBuffersToCodec(); break; break; } } Loading Loading @@ -1422,6 +1419,11 @@ void MediaCodec::setState(State newState) { if (newState == UNINITIALIZED) { if (newState == UNINITIALIZED) { mComponentName.clear(); 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; mState = newState; Loading