diff options
Diffstat (limited to 'media/libstagefright/ACodec.cpp')
-rw-r--r-- | media/libstagefright/ACodec.cpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index e9d10cd..ef21c9a 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() { @@ -1153,7 +1157,7 @@ status_t ACodec::configureCodec( } sp<AMessage> inputFormat = new AMessage(); - sp<AMessage> outputFormat = new AMessage(); + sp<AMessage> outputFormat = mNotify->dup(); // will use this for kWhatOutputFormatChanged mIsEncoder = encoder; @@ -1263,6 +1267,24 @@ status_t ACodec::configureCodec( static_cast<NativeWindowWrapper *>(obj.get())); sp<ANativeWindow> nativeWindow = windowWrapper->getNativeWindow(); + // START of temporary support for automatic FRC - THIS WILL BE REMOVED + int32_t autoFrc; + if (msg->findInt32("auto-frc", &autoFrc)) { + bool enabled = autoFrc; + OMX_CONFIG_BOOLEANTYPE config; + InitOMXParams(&config); + config.bEnabled = (OMX_BOOL)enabled; + status_t temp = mOMX->setConfig( + mNode, (OMX_INDEXTYPE)OMX_IndexConfigAutoFramerateConversion, + &config, sizeof(config)); + if (temp == OK) { + outputFormat->setInt32("auto-frc", enabled); + } else if (enabled) { + ALOGI("codec does not support requested auto-frc (err %d)", temp); + } + } + // END of temporary support for automatic FRC + int32_t tunneled; if (msg->findInt32("feature-tunneled-playback", &tunneled) && tunneled != 0) { @@ -1520,6 +1542,8 @@ status_t ACodec::configureCodec( err = setMinBufferSize(kPortIndexInput, 8192); // XXX } + mBaseOutputFormat = outputFormat; + CHECK_EQ(getPortFormat(kPortIndexInput, inputFormat), (status_t)OK); CHECK_EQ(getPortFormat(kPortIndexOutput, outputFormat), (status_t)OK); mInputFormat = inputFormat; @@ -2216,7 +2240,11 @@ status_t ACodec::setupVideoEncoder(const char *mime, const sp<AMessage> &msg) { video_def->xFramerate = (OMX_U32)(frameRate * 65536.0f); video_def->eCompressionFormat = OMX_VIDEO_CodingUnused; - video_def->eColorFormat = colorFormat; + // this is redundant as it was already set up in setVideoPortFormatType + // FIXME for now skip this only for flexible YUV formats + if (colorFormat != OMX_COLOR_FormatYUV420Flexible) { + video_def->eColorFormat = colorFormat; + } err = mOMX->setParameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); @@ -3505,7 +3533,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> ¬ify) { } void ACodec::sendFormatChange(const sp<AMessage> &reply) { - sp<AMessage> notify = mNotify->dup(); + sp<AMessage> notify = mBaseOutputFormat->dup(); notify->setInt32("what", kWhatOutputFormatChanged); CHECK_EQ(getPortFormat(kPortIndexOutput, notify), (status_t)OK); @@ -3794,6 +3822,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; } @@ -4453,6 +4494,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); } @@ -4599,6 +4647,7 @@ void ACodec::LoadedState::stateEntered() { mCodec->mRepeatFrameDelayUs = -1ll; mCodec->mInputFormat.clear(); mCodec->mOutputFormat.clear(); + mCodec->mBaseOutputFormat.clear(); if (mCodec->mShutdownInProgress) { bool keepComponentAllocated = mCodec->mKeepComponentAllocated; |