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

Commit c32eaa53 authored by Wei Jia's avatar Wei Jia Committed by Android (Google) Code Review
Browse files

Merge "ACodec: support low latency config and set paramters"

parents dbfd6388 2670ba0f
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -1780,6 +1780,14 @@ status_t ACodec::configureCodec(
        }
    }

    int32_t lowLatency = 0;
    if (msg->findInt32("low-latency", &lowLatency)) {
        err = setLowLatency(lowLatency);
        if (err != OK) {
            return err;
        }
    }

    int32_t prependSPSPPS = 0;
    if (encoder && mIsVideo
            && msg->findInt32("prepend-sps-pps-to-idr-frames", &prependSPSPPS)
@@ -2348,6 +2356,24 @@ status_t ACodec::configureCodec(
    return err;
}

status_t ACodec::setLowLatency(int32_t lowLatency) {
    if (mIsEncoder) {
        ALOGE("encoder does not support low-latency");
        return BAD_VALUE;
    }

    OMX_CONFIG_BOOLEANTYPE config;
    InitOMXParams(&config);
    config.bEnabled = (OMX_BOOL)(lowLatency != 0);
    status_t err = mOMXNode->setConfig(
            (OMX_INDEXTYPE)OMX_IndexConfigLowLatency,
            &config, sizeof(config));
    if (err != OK) {
        ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err);
    }
    return err;
}

status_t ACodec::setLatency(uint32_t latency) {
    OMX_PARAM_U32TYPE config;
    InitOMXParams(&config);
@@ -7582,6 +7608,14 @@ status_t ACodec::setParameters(const sp<AMessage> &params) {
        }
    }

    int32_t lowLatency = 0;
    if (params->findInt32("low-latency", &lowLatency)) {
        status_t err = setLowLatency(lowLatency);
        if (err != OK) {
            return err;
        }
    }

    int32_t latency = 0;
    if (params->findInt32("latency", &latency) && latency > 0) {
        status_t err = setLatency(latency);
+1 −0
Original line number Diff line number Diff line
@@ -496,6 +496,7 @@ private:
            AudioEncoding encoding = kAudioEncodingPcm16bit);

    status_t setPriority(int32_t priority);
    status_t setLowLatency(int32_t lowLatency);
    status_t setLatency(uint32_t latency);
    status_t getLatency(uint32_t *latency);
    status_t setAudioPresentation(int32_t presentationId, int32_t programId);