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

Commit 6c015b35 authored by Ramjee's avatar Ramjee Committed by Divya Narayanan Poojary
Browse files

audiopolicy: check active direct output before adding DIRECT_PCM flag

When getting new output with DIRECT_PCM flag set, the existing direct
pcm output can be closed and interrupted mutually with the requested one.
Don't add DIRECT_PCM flag if there's an active direct output for track
offload.

Change-Id: I250c9555dff2c17f94b57a14a1722bae00fe9f9b
CRs-Fixed: 986087
parent d04cbc7b
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -1595,10 +1595,21 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice(
        flags = AUDIO_OUTPUT_FLAG_TTS;
        flags = AUDIO_OUTPUT_FLAG_TTS;
    }
    }


    // check if direct output for track offload already exits
    bool is_track_offload_active = false;
    for (size_t i = 0; i < mOutputs.size(); i++) {
        sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
        if (desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
            is_track_offload_active = true;
            ALOGD("Track offload already active");
            break;
        }
    }

    // Do offload magic here
    // Do offload magic here
    if ((flags == AUDIO_OUTPUT_FLAG_NONE) &&
    if ((flags == AUDIO_OUTPUT_FLAG_NONE) &&
        (stream == AUDIO_STREAM_MUSIC) &&
        (stream == AUDIO_STREAM_MUSIC) &&
        (offloadInfo != NULL) &&
        (offloadInfo != NULL) && !is_track_offload_active &&
        ((offloadInfo->usage == AUDIO_USAGE_MEDIA) || (offloadInfo->usage == AUDIO_USAGE_GAME))) {
        ((offloadInfo->usage == AUDIO_USAGE_MEDIA) || (offloadInfo->usage == AUDIO_USAGE_GAME))) {
        flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DIRECT_PCM);
        flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DIRECT_PCM);
        ALOGD("AudioCustomHAL --> Force Direct Flag .. flag (0x%x)", flags);
        ALOGD("AudioCustomHAL --> Force Direct Flag .. flag (0x%x)", flags);