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

Commit 25b344d5 authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Gerrit - the friendly Code Review server
Browse files

hal: Prevent superfluous device tear down on routing change

For playback usecases routing change, audio HAL disables sound device
if existing sound device does not match derived sound device and
enables the derived sound device. It does not check whether existing
sound device is a combination multiple devices and if one of those
devices matches with the derived sound device.
With scenarios like ringtone over speaker-and-bt-a2dp followed by
a2dp playback, we disable and re-enable bt-a2dp. This is unneeded
if a2dp backend is already active. Handle such scenarios by
disabling only devices that do not match the derived sound device.

CRs-Fixed: 2319384
Change-Id: I171fbead85746a2a34632f7580f56ef40505665c
parent e0b9de81
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -1330,7 +1330,8 @@ static void check_usecases_codec_backend(struct audio_device *adev,
    bool switch_device[AUDIO_USECASE_MAX];
    snd_device_t uc_derive_snd_device;
    snd_device_t derive_snd_device[AUDIO_USECASE_MAX];
    int i, num_uc_to_switch = 0;
    snd_device_t split_snd_devices[SND_DEVICE_OUT_END];
    int i, num_uc_to_switch = 0, num_devices = 0;
    int status = 0;
    bool force_restart_session = false;
    /*
@@ -1412,9 +1413,22 @@ static void check_usecases_codec_backend(struct audio_device *adev,
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (switch_device[usecase->id]) {
                /* Check if sound device to be switched can be split and if any
                   of the split devices match with derived sound device */
                platform_split_snd_device(adev->platform, usecase->out_snd_device,
                                          &num_devices, split_snd_devices);
                if (num_devices > 1) {
                    for (i = 0; i < num_devices; i++) {
                        /* Disable devices that do not match with derived sound device */
                        if (split_snd_devices[i] != derive_snd_device[usecase->id]) {
                            disable_snd_device(adev, split_snd_devices[i]);
                        }
                    }
                } else {
                    disable_snd_device(adev, usecase->out_snd_device);
                }
            }
        }

        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);