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

Commit 9baad390 authored by juyuchen's avatar juyuchen
Browse files

audio: fix no sound in rigntone case with a2dp and speaker path



In ringtone case, there is no sound when device uses a2dp and speaker but a2dp is suspended.

Bug: 80678966
Test: manual audio test on B1

Change-Id: I45f1466e9f4b4ea3f68892a840f5169838bf3745
Signed-off-by: default avatarjuyuchen <juyuchen@google.com>
parent 5d0261ea
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -1367,6 +1367,9 @@ int select_devices(struct audio_device *adev,
         out_snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP) &&
         out_snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP) &&
        (!audio_extn_a2dp_is_ready())) {
        (!audio_extn_a2dp_is_ready())) {
        ALOGW("%s: A2DP profile is not ready, routing to speaker only", __func__);
        ALOGW("%s: A2DP profile is not ready, routing to speaker only", __func__);
        if (out_snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP)
            out_snd_device = SND_DEVICE_OUT_SPEAKER_SAFE;
        else
            out_snd_device = SND_DEVICE_OUT_SPEAKER;
            out_snd_device = SND_DEVICE_OUT_SPEAKER;
    }
    }


@@ -2026,7 +2029,7 @@ int start_output_stream(struct stream_out *out)


    if (out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) {
    if (out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) {
        if (!audio_extn_a2dp_is_ready()) {
        if (!audio_extn_a2dp_is_ready()) {
            if (out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
            if (out->devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
                a2dp_combo = true;
                a2dp_combo = true;
            } else {
            } else {
                if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) {
                if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) {
@@ -2073,6 +2076,9 @@ int start_output_stream(struct stream_out *out)
            check_a2dp_restore_l(adev, out, false);
            check_a2dp_restore_l(adev, out, false);
        } else {
        } else {
            audio_devices_t dev = out->devices;
            audio_devices_t dev = out->devices;
            if (dev & AUDIO_DEVICE_OUT_SPEAKER_SAFE)
                out->devices = AUDIO_DEVICE_OUT_SPEAKER_SAFE;
            else
                out->devices = AUDIO_DEVICE_OUT_SPEAKER;
                out->devices = AUDIO_DEVICE_OUT_SPEAKER;
            select_devices(adev, out->usecase);
            select_devices(adev, out->usecase);
            out->devices = dev;
            out->devices = dev;
@@ -2545,7 +2551,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
         */
         */
        if (val & AUDIO_DEVICE_OUT_ALL_A2DP) {
        if (val & AUDIO_DEVICE_OUT_ALL_A2DP) {
            if (!audio_extn_a2dp_is_ready()) {
            if (!audio_extn_a2dp_is_ready()) {
                if (val & AUDIO_DEVICE_OUT_SPEAKER) {
                if (val & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
                    //combo usecase just by pass a2dp
                    //combo usecase just by pass a2dp
                    ALOGW("%s: A2DP profile is not ready,routing to speaker only", __func__);
                    ALOGW("%s: A2DP profile is not ready,routing to speaker only", __func__);
                    bypass_a2dp = true;
                    bypass_a2dp = true;
@@ -2625,6 +2631,9 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
                if (!bypass_a2dp) {
                if (!bypass_a2dp) {
                    select_devices(adev, out->usecase);
                    select_devices(adev, out->usecase);
                } else {
                } else {
                    if (new_dev & AUDIO_DEVICE_OUT_SPEAKER_SAFE)
                        out->devices = AUDIO_DEVICE_OUT_SPEAKER_SAFE;
                    else
                        out->devices = AUDIO_DEVICE_OUT_SPEAKER;
                        out->devices = AUDIO_DEVICE_OUT_SPEAKER;
                    select_devices(adev, out->usecase);
                    select_devices(adev, out->usecase);
                    out->devices = new_dev;
                    out->devices = new_dev;
@@ -2953,7 +2962,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,


    if ((out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) &&
    if ((out->devices & AUDIO_DEVICE_OUT_ALL_A2DP) &&
        (audio_extn_a2dp_is_suspended())) {
        (audio_extn_a2dp_is_suspended())) {
        if (!(out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
        if (!(out->devices & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE))) {
            if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) {
            if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) {
                ret = -EIO;
                ret = -EIO;
                goto exit;
                goto exit;