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

Commit 771d02f0 authored by Ashish Jain's avatar Ashish Jain Committed by Gerrit - the friendly Code Review server
Browse files

policy_hal: Add support to identify direct pcm client.

-Update Direct pcm implementation to identify direct pcm client
as mediaplayer or app based audio track.
-This gives flexibility to disable direct pcm either of these clients.

Change-Id: Ief418a864a6f776c4dea7b2e953df9497cbcb5d0
parent 51eb248c
Loading
Loading
Loading
Loading
+28 −12
Original line number Original line Diff line number Diff line
@@ -1405,17 +1405,34 @@ bool AudioPolicyManagerCustom::isDirectOutput(audio_io_handle_t output) {
    return false;
    return false;
}
}


bool static isDirectPCMEnabled(int bitWidth)
bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
{
{
    bool directPCMEnabled = false;
    bool playerDirectPCM = false; // Output request for Track created by mediaplayer
    bool trackDirectPCM = false;  // Output request for track created by other apps

    // Direct PCM is allowed only if
    // In case of mediaPlayer playback
    // 16 bit direct pcm or 24bit direct PCM property is set and
    // the FLAG requested is DIRECT_PCM ( NuPlayer case) or
    // In case of AudioTracks created by apps
    // track offload is enabled and FLAG requested is FLAG_NONE.

    if (*flags == AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
       if (bitWidth == 24 || bitWidth == 32)
       if (bitWidth == 24 || bitWidth == 32)
        directPCMEnabled =
           playerDirectPCM =
                property_get_bool("audio.offload.pcm.24bit.enable", false);
                property_get_bool("audio.offload.pcm.24bit.enable", false);
       else
       else
        directPCMEnabled =
           playerDirectPCM =
                property_get_bool("audio.offload.pcm.16bit.enable", false);
                property_get_bool("audio.offload.pcm.16bit.enable", false);
       // Reset flag to NONE so that we can still reuse direct pcm criteria check
       // in getOutputforDevice
       *flags = AUDIO_OUTPUT_FLAG_NONE;
    } else if ( *flags == AUDIO_OUTPUT_FLAG_NONE) {
        trackDirectPCM = property_get_bool("audio.offload.track.enable", true);
    }


    return directPCMEnabled;
    ALOGI("%s for Direct PCM",trackDirectPCM || playerDirectPCM?"Check":"Dont check");
    return trackDirectPCM || playerDirectPCM;
}
}


status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *attr,
status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *attr,
@@ -1440,8 +1457,7 @@ status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *at
    }
    }


    if (!offloadDisabled && (offloadInfo == NULL) &&
    if (!offloadDisabled && (offloadInfo == NULL) &&
        isDirectPCMEnabled(bitWidth) &&
        tryForDirectPCM(bitWidth, &flags)) {
        (flags == AUDIO_OUTPUT_FLAG_NONE)) {


        tOffloadInfo.sample_rate  = samplingRate;
        tOffloadInfo.sample_rate  = samplingRate;
        tOffloadInfo.channel_mask = channelMask;
        tOffloadInfo.channel_mask = channelMask;