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

Commit 1c15ca03 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: switch to current active device when a2dp suspended"

parents 7a8efc45 407e5aa5
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -10444,9 +10444,11 @@ static void adev_snd_mon_cb(void *cookie, struct str_parms *parms)
int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool restore)
{
    struct audio_usecase *uc_info;
    struct audio_usecase *usecase;
    float left_p;
    float right_p;
    struct listnode devices;
    struct listnode *node;

    uc_info = get_usecase_from_list(adev, out->usecase);
    if (uc_info == NULL) {
@@ -10482,9 +10484,17 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool
        pthread_mutex_lock(&out->latch_lock);
        // mute stream and switch to speaker if suspended
        if (!out->a2dp_muted && !out->standby) {
            ALOGD("%s: selecting speaker and muting stream", __func__);
            assign_devices(&devices, &out->device_list);
            reassign_device_list(&out->device_list, AUDIO_DEVICE_OUT_SPEAKER, "");
            list_for_each(node, &adev->usecase_list) {
                usecase = node_to_item(node, struct audio_usecase, list);
                if ((usecase != uc_info) &&
                        platform_check_backends_match(SND_DEVICE_OUT_SPEAKER,
                                                      usecase->out_snd_device)) {
                    assign_devices(&out->device_list, &usecase->stream.out->device_list);
                    break;
                }
            }
            left_p = out->volume_l;
            right_p = out->volume_r;
            out->a2dp_muted = true;
@@ -10503,6 +10513,8 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool
                usleep(latency * 1000);
            }
            select_devices(adev, out->usecase);
            ALOGD("%s: switched to device:%s and mute stream",
                   __func__, platform_get_snd_device_name(uc_info->out_snd_device));
            if (is_offload_usecase(out->usecase)) {
                if (out->offload_state == OFFLOAD_STATE_PLAYING)
                    compress_resume(out->compr);