diff options
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 5f55484..e1c8a41 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -738,6 +738,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { err, actionCode, mState); if (err == DEAD_OBJECT) { mFlags |= kFlagSawMediaServerDie; + mFlags &= ~kFlagIsComponentAllocated; } bool sendErrorResponse = true; @@ -863,6 +864,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { { CHECK_EQ(mState, INITIALIZING); setState(INITIALIZED); + mFlags |= kFlagIsComponentAllocated; CHECK(msg->findString("componentName", &mComponentName)); @@ -1009,6 +1011,16 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mFlags |= kFlagOutputFormatChanged; postActivityNotificationIfPossible(); } + + // Notify mCrypto of video resolution changes + if (mCrypto != NULL) { + int32_t height, width; + if (mOutputFormat->findInt32("height", &height) && + mOutputFormat->findInt32("width", &width)) { + mCrypto->notifyResolution(width, height); + } + } + break; } @@ -1136,6 +1148,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { setState(UNINITIALIZED); mComponentName.clear(); } + mFlags &= ~kFlagIsComponentAllocated; (new AMessage)->postReply(mReplyID); break; @@ -1313,8 +1326,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { CHECK(msg->senderAwaitsResponse(&replyID)); if (mState == FLUSHED) { + setState(STARTED); mCodec->signalResume(); PostReplyWithError(replyID, OK); + break; } else if (mState != CONFIGURED) { PostReplyWithError(replyID, INVALID_OPERATION); break; @@ -1336,9 +1351,13 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { uint32_t replyID; CHECK(msg->senderAwaitsResponse(&replyID)); - if (mState != INITIALIZED + if (!((mFlags & kFlagIsComponentAllocated) && targetState == UNINITIALIZED) // See 1 + && mState != INITIALIZED && mState != CONFIGURED && !isExecuting()) { - // We may be in "UNINITIALIZED" state already without the + // 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 // after stop() returned, it would be safe to call release() |