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

Commit e88c67ff authored by Jiyong Park's avatar Jiyong Park
Browse files

Don't use SDK 31 APIs on APEX

For now, the check is don statically using __ANDROID_APEX__ macro. Soon,
it will be changed to a runtime check using __builtin_available.

Bug: 177365934
Test: m
Change-Id: Id0c23d90b69de3cd5ddfd73de6ebcf7154cb2b1d
parent ba111033
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -260,7 +260,12 @@ media_status_t VideoTrackTranscoder::configureDestinationFormat(
        return AMEDIA_ERROR_INVALID_PARAMETER;
    }

#if !defined(__ANDROID_APEX__)
    // TODO(jiyong): replace this #ifdef with a __builtin_available check.
    AMediaCodec* encoder = AMediaCodec_createEncoderByTypeForClient(destinationMime, mPid, mUid);
#else
    AMediaCodec* encoder = AMediaCodec_createEncoderByType(destinationMime);
#endif
    if (encoder == nullptr) {
        LOG(ERROR) << "Unable to create encoder for type " << destinationMime;
        return AMEDIA_ERROR_UNSUPPORTED;
@@ -290,7 +295,12 @@ media_status_t VideoTrackTranscoder::configureDestinationFormat(
        return AMEDIA_ERROR_INVALID_PARAMETER;
    }

#if !defined(__ANDROID_APEX__)
    // TODO(jiyong): replace this #ifdef with a __builtin_available check.
    mDecoder = AMediaCodec_createDecoderByTypeForClient(sourceMime, mPid, mUid);
#else
    mDecoder = AMediaCodec_createDecoderByType(sourceMime);
#endif
    if (mDecoder == nullptr) {
        LOG(ERROR) << "Unable to create decoder for type " << sourceMime;
        return AMEDIA_ERROR_UNSUPPORTED;
+4 −0
Original line number Diff line number Diff line
@@ -97,8 +97,12 @@ private:
    BlockingQueue<std::function<void()>> mCodecMessageQueue;
    std::shared_ptr<AMediaFormat> mDestinationFormat;
    std::shared_ptr<AMediaFormat> mActualOutputFormat;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
    // These could be unused on older platforms
    pid_t mPid;
    uid_t mUid;
#pragma clang diagnostic pop
};

}  // namespace android