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

Commit d96af8ff authored by Kunlei Zhang's avatar Kunlei Zhang Committed by Zhou Song
Browse files

hal: fix bt sco and a2dp concurrency issues

When sco mic device is already active and
A2dpsuspened=false is received, then route
is switched to A2dp, but sco mic can still
keep active which means the BE is already
active, causing the slimbus configuration of
feedback path for A2dp to be ignored.
To fix this, tear down the input stream to
disable bt sco mic before enabling a2dp path.

Change-Id: I67f1e1ef03febb0bd3736509500195808dc1e53b
parent 7a2f2c06
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -8207,7 +8207,6 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
    int status = 0;
    bool a2dp_reconfig = false;
    struct listnode *node;
    struct audio_usecase *usecase = NULL;
    int controller = -1, stream = -1;

    ALOGD("%s: enter: %s", __func__, kvpairs);
@@ -8240,20 +8239,29 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
        if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){
            adev->bt_sco_on = true;
        } else {
            ALOGD("sco is off, reset sco and route device to handset mic");
            adev->bt_sco_on = false;
            audio_extn_sco_reset_configuration();
        }
    }

    ret = str_parms_get_str(parms, "A2dpSuspended", value, sizeof(value));
    if (ret>=0) {
        if (!strncmp(value, "false", 5) &&
            audio_extn_a2dp_source_is_suspended()) {
            struct audio_usecase *usecase;
            struct listnode *node;
            list_for_each(node, &adev->usecase_list) {
                usecase = node_to_item(node, struct audio_usecase, list);
                if ((usecase->type == PCM_CAPTURE) && usecase->stream.in &&
                    (usecase->stream.in->device & AUDIO_DEVICE_IN_ALL_SCO))
                if (usecase->stream.in && (usecase->type == PCM_CAPTURE) &&
                    ((usecase->stream.in->device & ~AUDIO_DEVICE_BIT_IN) &
                        AUDIO_DEVICE_IN_ALL_SCO)) {
                    ALOGD("a2dp resumed, switch bt sco mic to handset mic");
                    usecase->stream.in->device = AUDIO_DEVICE_IN_BUILTIN_MIC;
                else
                    continue;
                    select_devices(adev, usecase->id);
                }
            }
        }
    }

    status = voice_set_parameters(adev, parms);
    if (status != 0)