diff options
author | Lajos Molnar <lajos@google.com> | 2014-10-21 16:07:52 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-10-21 16:14:11 -0700 |
commit | 30358faf33fb9b638257b017fadb4c5f7352d903 (patch) | |
tree | 9cf39ac9b04a8de88c5b1dbd40d2c8631efc2115 /media/libstagefright/ACodec.cpp | |
parent | 7de5ac1f067ec61f7ea424d5534cfd40987b11fa (diff) | |
download | frameworks_av-30358faf33fb9b638257b017fadb4c5f7352d903.zip frameworks_av-30358faf33fb9b638257b017fadb4c5f7352d903.tar.gz frameworks_av-30358faf33fb9b638257b017fadb4c5f7352d903.tar.bz2 |
stagefright: try to free codec instance if MediaCodec.release hangs
Bug: 18033275
Change-Id: If86cd26566d7b75941976f37829bbec619800778
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r-- | media/libstagefright/ACodec.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 2048808..2f2f9cf 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -498,6 +498,10 @@ void ACodec::initiateShutdown(bool keepComponentAllocated) { sp<AMessage> msg = new AMessage(kWhatShutdown, id()); msg->setInt32("keepComponentAllocated", keepComponentAllocated); msg->post(); + if (!keepComponentAllocated) { + // ensure shutdown completes in 3 seconds + (new AMessage(kWhatReleaseCodecInstance, id()))->post(3000000); + } } void ACodec::signalRequestIDRFrame() { @@ -3797,6 +3801,19 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) { break; } + case ACodec::kWhatReleaseCodecInstance: + { + ALOGI("[%s] forcing the release of codec", + mCodec->mComponentName.c_str()); + status_t err = mCodec->mOMX->freeNode(mCodec->mNode); + ALOGE_IF("[%s] failed to release codec instance: err=%d", + mCodec->mComponentName.c_str(), err); + sp<AMessage> notify = mCodec->mNotify->dup(); + notify->setInt32("what", CodecBase::kWhatShutdownCompleted); + notify->post(); + break; + } + default: return false; } @@ -4456,6 +4473,13 @@ bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) { break; } + case ACodec::kWhatReleaseCodecInstance: + { + // nothing to do, as we have already signaled shutdown + handled = true; + break; + } + default: return BaseState::onMessageReceived(msg); } |