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

Commit 0ac0903e authored by Alexy Joseph's avatar Alexy Joseph
Browse files

policy_hal: Update offload disabled flags

When disabling offload using
audio.offload.disable, pcm offload and
track offload flags are still checked.
Fix this counter intuitive behavior
by setting audio.offload.disable to
true will disable ALL forms of offload

Also, introduce new flag to disable
compressed offload. Setting
audio.offload.compress.disable to false
disables just compressed offload. PCM
offload and track offload continues to
work

Change-Id: I84bdeb9a899839e39b78fbd5368b634fa80c6a7b
parent bb8dae5c
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -397,6 +397,13 @@ bool AudioPolicyManagerCustom::isOffloadSupported(const audio_offload_info_t& of
        return false;
    }

    // Check if offload has been disabled
    bool offloadDisabled = property_get_bool("audio.offload.disable", false);
    if (offloadDisabled) {
        ALOGI("offload disabled by audio.offload.disable=%d", offloadDisabled);
        return false;
    }

    char propValue[PROPERTY_VALUE_MAX];
    bool pcmOffload = false;
#ifdef PCM_OFFLOAD_ENABLED
@@ -426,13 +433,13 @@ bool AudioPolicyManagerCustom::isOffloadSupported(const audio_offload_info_t& of
    }
#endif
    if (!pcmOffload) {
        // Check if offload has been disabled
        if (property_get("audio.offload.disable", propValue, "0")) {
            if (atoi(propValue) != 0) {
                ALOGV("offload disabled by audio.offload.disable=%s", propValue );

        bool compressedOffloadDisabled = property_get_bool("audio.offload.compress.disable", false);
        if (compressedOffloadDisabled) {
            ALOGI("compressed offload disabled by audio.offload.compress.disable=%d", compressedOffloadDisabled);
            return false;
        }
        }

        //check if it's multi-channel AAC (includes sub formats) and FLAC format
        if ((popcount(offloadInfo.channel_mask) > 2) &&
           (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AAC) ||
@@ -1243,7 +1250,17 @@ status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *at
{
    audio_offload_info_t tOffloadInfo = AUDIO_INFO_INITIALIZER;

    bool pcmOffloadEnabled = property_get_bool("audio.offload.track.enable", false);
    bool offloadDisabled = property_get_bool("audio.offload.disable", false);
    bool pcmOffloadEnabled = false;

    if (offloadDisabled) {
        ALOGI("offload disabled by audio.offload.disable=%d", offloadDisabled);
    }

    //read track offload property only if the global offload switch is off.
    if (!offloadDisabled) {
         pcmOffloadEnabled = property_get_bool("audio.offload.track.enable", false);
    }

    if (offloadInfo == NULL && pcmOffloadEnabled) {
        tOffloadInfo.sample_rate  = samplingRate;
@@ -1255,7 +1272,7 @@ status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *at
            ALOGV("found attribute .. setting usage %d ", attr->usage);
            tOffloadInfo.usage = attr->usage;
        } else {
            ALOGD("%s:: attribute is NULL .. no usage set", __func__);
            ALOGI("%s:: attribute is NULL .. no usage set", __func__);
        }
        offloadInfo = &tOffloadInfo;
    }