Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d23e63be authored by Surajit Podder's avatar Surajit Podder Committed by Steve Kondik
Browse files

libstagefright: Add missing check for software encoder

MediaCodecSource tries to allocate hardware codec for
video recording. If only software encoder is present
for a mime type, it results in a crash, while trying
to access an empty vector

Add change to allocate software encoder if hardware
encoder is not found

Change-Id: I629bfcf9d795559b9cdd46798580ee7900c9a25e
CRs-Fixed: 776726
parent 7daf0353
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -453,8 +453,8 @@ status_t MediaCodecSource::initEncoder() {
                STATS_PROFILE_ALLOCATE_NODE(mIsVideo), mRecorderExtendedStats);

#ifdef ENABLE_AV_ENHANCEMENTS
        if (mIsVideo && (mFlags & OMXCodec::kHardwareCodecsOnly)) {
        Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
        if (mIsVideo && (mFlags & OMXCodec::kHardwareCodecsOnly)) {

            OMXCodec::findMatchingCodecs(
                    outputMIME.c_str(),
@@ -462,7 +462,8 @@ status_t MediaCodecSource::initEncoder() {
                    NULL,  // matchComponentName
                    OMXCodec::kHardwareCodecsOnly,     // flags
                    &matchingCodecs);

        }
        if (matchingCodecs.size() > 0) {
            componentName = matchingCodecs.itemAt(0).mName.string();
            mEncoder = MediaCodec::CreateByComponentName(
                    mCodecLooper, componentName.c_str());