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

Commit 4de0b451 authored by Hiroaki Hayashi's avatar Hiroaki Hayashi Committed by Eric Laurent
Browse files

Treat AUDIO_SOURCE_DEFAULT as AUDIO_SOURCE_MIC

AUDIO_SOURCE_DEFAULT is translated to AUDIO_SOURCE_MIC in
AudioPolicyManager. That means AUDIO_SOURCE_DEFAULT should behave
as same as AUDIO_SOURCE_MIC.

In this commit, argument for addInputEffects() is translated for
avoid different behavior between AUDIO_SOURCE_DEFAULT and
AUDIO_SOURCE_MIC.
This means same preprocessing effects are applied for both Sources.

Bug: 137898521
Test: Add pre-processing effect for AUDIO_SOURCE_MIC then check if
it works for AUDIO_SOURCE_DEFAULT as well

Change-Id: I3df1bcc7309dc535a721113cc4465b20733b4058
parent 9ce5404e
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -363,12 +363,17 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
        return NO_INIT;
    }

    audio_source_t inputSource = attr->source;
    if (inputSource == AUDIO_SOURCE_DEFAULT) {
        inputSource = AUDIO_SOURCE_MIC;
    }

    // already checked by client, but double-check in case the client wrapper is bypassed
    if ((attr->source < AUDIO_SOURCE_DEFAULT)
            || (attr->source >= AUDIO_SOURCE_CNT
                && attr->source != AUDIO_SOURCE_HOTWORD
                && attr->source != AUDIO_SOURCE_FM_TUNER
                && attr->source != AUDIO_SOURCE_ECHO_REFERENCE)) {
    if ((inputSource < AUDIO_SOURCE_DEFAULT)
            || (inputSource >= AUDIO_SOURCE_CNT
                && inputSource != AUDIO_SOURCE_HOTWORD
                && inputSource != AUDIO_SOURCE_FM_TUNER
                && inputSource != AUDIO_SOURCE_ECHO_REFERENCE)) {
        return BAD_VALUE;
    }

@@ -399,17 +404,17 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
    }

    bool canCaptureOutput = captureAudioOutputAllowed(pid, uid);
    if ((attr->source == AUDIO_SOURCE_VOICE_UPLINK ||
        attr->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
        attr->source == AUDIO_SOURCE_VOICE_CALL ||
        attr->source == AUDIO_SOURCE_ECHO_REFERENCE||
        attr->source == AUDIO_SOURCE_FM_TUNER) &&
    if ((inputSource == AUDIO_SOURCE_VOICE_UPLINK ||
        inputSource == AUDIO_SOURCE_VOICE_DOWNLINK ||
        inputSource == AUDIO_SOURCE_VOICE_CALL ||
        inputSource == AUDIO_SOURCE_ECHO_REFERENCE||
        inputSource == AUDIO_SOURCE_FM_TUNER) &&
        !canCaptureOutput) {
        return PERMISSION_DENIED;
    }

    bool canCaptureHotword = captureHotwordAllowed(opPackageName, pid, uid);
    if ((attr->source == AUDIO_SOURCE_HOTWORD) && !canCaptureHotword) {
    if ((inputSource == AUDIO_SOURCE_HOTWORD) && !canCaptureHotword) {
        return BAD_VALUE;
    }

@@ -474,7 +479,7 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,

    if (audioPolicyEffects != 0) {
        // create audio pre processors according to input source
        status_t status = audioPolicyEffects->addInputEffects(*input, attr->source, session);
        status_t status = audioPolicyEffects->addInputEffects(*input, inputSource, session);
        if (status != NO_ERROR && status != ALREADY_EXISTS) {
            ALOGW("Failed to add effects on input %d", *input);
        }