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

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

policy_hal: Fix check for direct pcm

-mediaplayer now opens a sink with DIRECT_PCM flag for eligible
playback sessions,and if setPlayback rate api is triggered for
mediaplayer object,fall back to deep buffer output should happen.
But as the DIRECT_PCM flag is not removed from the requested flags,
the same direct output gets selected.
-Ensure that DIRECT_PCM flag is removed always if present,
before query for output, otherwise even when no direct output
is required, might end up with one.

Change-Id: Ie27e90851a0de4a6a6c2dc205a8ed9e281663626
parent 05b90f22
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -1335,6 +1335,7 @@ bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
{
    bool playerDirectPCM = false; // Output request for Track created by mediaplayer
    bool trackDirectPCM = false;  // Output request for track created by other apps
    bool offloadDisabled = property_get_bool("audio.offload.disable", false);

    // Direct PCM is allowed only if
    // In case of mediaPlayer playback
@@ -1343,6 +1344,10 @@ bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
    // In case of AudioTracks created by apps
    // track offload is enabled and FLAG requested is FLAG_NONE.

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

    if (*flags == AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
       if (bitWidth == 24 || bitWidth == 32)
           playerDirectPCM =
@@ -1357,8 +1362,10 @@ bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
        trackDirectPCM = property_get_bool("audio.offload.track.enable", true);
    }

    ALOGI("%s for Direct PCM",trackDirectPCM || playerDirectPCM?"Check":"Dont check");
    return trackDirectPCM || playerDirectPCM;
    ALOGI("Direct PCM %s for this request",
       (!offloadDisabled && (trackDirectPCM || playerDirectPCM))?"can be enabled":"is disabled");

    return (!offloadDisabled && (trackDirectPCM || playerDirectPCM));
}

status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *attr,
@@ -1375,15 +1382,11 @@ status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *at
{
    audio_offload_info_t tOffloadInfo = AUDIO_INFO_INITIALIZER;

    bool offloadDisabled = property_get_bool("audio.offload.disable", false);
    uint32_t bitWidth = (audio_bytes_per_sample(format) * 8);

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

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

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