diff options
author | Andreas Huber <andih@google.com> | 2012-02-28 15:54:51 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-02-28 15:54:51 -0800 |
commit | c95c2ddcdfc974f42408a377fbe2de51b94a8c94 (patch) | |
tree | 24239ca3f0d24f790b73d92627de057f738f91d5 /media/libstagefright/MediaCodec.cpp | |
parent | a3873833d518e032138cf70188b6f33cd7acec3d (diff) | |
download | frameworks_av-c95c2ddcdfc974f42408a377fbe2de51b94a8c94.zip frameworks_av-c95c2ddcdfc974f42408a377fbe2de51b94a8c94.tar.gz frameworks_av-c95c2ddcdfc974f42408a377fbe2de51b94a8c94.tar.bz2 |
Separate the notion of "stop" from that of "release", i.e.
stop - means transition back to LOADED state and keeping the component
instance allocated.
release - means we get rid of the component completely.
Change-Id: I40ad01ce70821faaad43f57999249904f9144924
Diffstat (limited to 'media/libstagefright/MediaCodec.cpp')
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index e14b1c4..a9e7f36 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -164,6 +164,13 @@ status_t MediaCodec::stop() { return PostAndAwaitResponse(msg, &response); } +status_t MediaCodec::release() { + sp<AMessage> msg = new AMessage(kWhatRelease, id()); + + sp<AMessage> response; + return PostAndAwaitResponse(msg, &response); +} + status_t MediaCodec::queueInputBuffer( size_t index, size_t offset, @@ -422,6 +429,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } case STOPPING: + case RELEASING: { // Ignore the error, assuming we'll still get // the shutdown complete notification. @@ -577,7 +585,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { { /* size_t index = */updateBuffers(kPortIndexInput, msg); - if (mState == FLUSHING || mState == STOPPING) { + if (mState == FLUSHING + || mState == STOPPING + || mState == RELEASING) { returnBuffersToCodecOnPort(kPortIndexInput); break; } @@ -596,7 +606,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { { /* size_t index = */updateBuffers(kPortIndexOutput, msg); - if (mState == FLUSHING || mState == STOPPING) { + if (mState == FLUSHING + || mState == STOPPING + || mState == RELEASING) { returnBuffersToCodecOnPort(kPortIndexOutput); break; } @@ -628,8 +640,12 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { case ACodec::kWhatShutdownCompleted: { - CHECK_EQ(mState, STOPPING); - setState(UNINITIALIZED); + if (mState == STOPPING) { + setState(INITIALIZED); + } else { + CHECK_EQ(mState, RELEASING); + setState(UNINITIALIZED); + } (new AMessage)->postReply(mReplyID); break; @@ -767,6 +783,28 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mReplyID = replyID; setState(STOPPING); + mCodec->initiateShutdown(true /* keepComponentAllocated */); + returnBuffersToCodec(); + break; + } + + case kWhatRelease: + { + 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(RELEASING); + mCodec->initiateShutdown(); returnBuffersToCodec(); break; |