diff options
author | Lajos Molnar <lajos@google.com> | 2014-10-09 16:32:33 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-10-09 16:45:17 -0700 |
commit | 6e029f0ba9a3b421eb7273a095305f7998e9aa5a (patch) | |
tree | 8a9f301b11382e9126b58423dfd5950f7c190312 | |
parent | af238382e33a027494a53556e6104b7245e7213f (diff) | |
download | frameworks_av-6e029f0ba9a3b421eb7273a095305f7998e9aa5a.zip frameworks_av-6e029f0ba9a3b421eb7273a095305f7998e9aa5a.tar.gz frameworks_av-6e029f0ba9a3b421eb7273a095305f7998e9aa5a.tar.bz2 |
MediaCodec: fix onError and onInputBufferAvailable
- don't call onInputBufferAvailable if we created an input surface
- keep component name alive if an error occurs
Bug: 17934966
Change-Id: I396c6e6cfd9fa589a1a95c6169492089255e6993
-rw-r--r-- | media/libstagefright/MediaCodec.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index b568063..5f55484 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -780,7 +780,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // STOPPING->UNINITIALIZED, instead of the // usual STOPPING->INITIALIZED state. setState(UNINITIALIZED); - + if (mState == RELEASING) { + mComponentName.clear(); + } (new AMessage)->postReply(mReplyID); } break; @@ -1046,7 +1048,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } if (mFlags & kFlagIsAsync) { - onInputBufferAvailable(); + if (!mHaveInputSurface) { + onInputBufferAvailable(); + } } else if (mFlags & kFlagDequeueInputPending) { CHECK(handleDequeueInputBuffer(mDequeueInputReplyID)); @@ -1130,6 +1134,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { } else { CHECK_EQ(mState, RELEASING); setState(UNINITIALIZED); + mComponentName.clear(); } (new AMessage)->postReply(mReplyID); @@ -1339,12 +1344,12 @@ 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 == targetState ? OK : INVALID_OPERATION); - + status_t err = mState == targetState ? OK : INVALID_OPERATION; + response->setInt32("err", err); + if (err == OK && targetState == UNINITIALIZED) { + mComponentName.clear(); + } response->postReply(replyID); break; } @@ -1353,6 +1358,9 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { // It's dead, Jim. Don't expect initiateShutdown to yield // any useful results now... setState(UNINITIALIZED); + if (targetState == UNINITIALIZED) { + mComponentName.clear(); + } (new AMessage)->postReply(replyID); break; } @@ -1745,8 +1753,6 @@ void MediaCodec::setState(State newState) { // return any straggling buffers, e.g. if we got here on an error returnBuffersToCodec(); - 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. |