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

Commit 43c4a6a8 authored by kunleiz's avatar kunleiz Committed by Gerrit - the friendly Code Review server
Browse files

hal: avoid music output from combo device after ringtone

When headset insert, music output route to headset. Later
ringtone happens, music pauses, and its output device still
is headset. But primary output will change to speaker+headphone
to play ringtone. When ringtone stops, music output from headset
first, then the output device changes to speaker+headphone combo
device. This is due to platform_set_swap_channels function is
called to cause device switch to current primary output device.

Fix by avoid device switch happen when current device is not
stereo speaker or swap flag is false.

CRs-Fixed: 2243778
Change-Id: I363e039ae8621e9bab2827e85c8744b556259320
parent a1a6244b
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -7915,6 +7915,18 @@ int platform_set_swap_channels(struct audio_device *adev, bool swap_channels)
    struct audio_usecase *usecase;
    struct listnode *node;

    //swap channels only for stereo spkr
    struct platform_data *my_data = (struct platform_data *)adev->platform;
    if (my_data) {
        if (!hw_info_is_stereo_spkr(my_data->hw_info)) {
            ALOGV("%s: will not swap due to it is not stereo spkr", __func__);
            return 0;
        }
    } else {
        ALOGE("%s: failed to allocate platform data", __func__);
        return -EINVAL;
    }

    // do not swap channels in audio modes with concurrent capture and playback
    // as this may break the echo reference
    if ((adev->mode == AUDIO_MODE_IN_COMMUNICATION) || (adev->mode == AUDIO_MODE_IN_CALL)) {
@@ -7931,8 +7943,9 @@ int platform_set_swap_channels(struct audio_device *adev, bool swap_channels)
             * to perform device switch to disable the current backend to
             * enable it with new acdb data.
             */
            if (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
                acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]) {
            if (my_data->speaker_lr_swap &&
                (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
                acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE])) {
                const int initial_skpr_gain = ramp_speaker_gain(adev, false /*ramp_up*/, -1);
                select_devices(adev, usecase->id);
                if (initial_skpr_gain != -EINVAL)
+15 −2
Original line number Diff line number Diff line
@@ -7761,6 +7761,18 @@ int platform_set_swap_channels(struct audio_device *adev, bool swap_channels)
    struct audio_usecase *usecase;
    struct listnode *node;

    //swap channels only for stereo spkr
    struct platform_data *my_data = (struct platform_data *)adev->platform;
    if (my_data) {
        if (!hw_info_is_stereo_spkr(my_data->hw_info)) {
            ALOGV("%s: will not swap due to it is not stereo spkr", __func__);
            return 0;
        }
    } else {
        ALOGE("%s: failed to allocate platform data", __func__);
        return -EINVAL;
    }

    // do not swap channels in audio modes with concurrent capture and playback
    // as this may break the echo reference
    if ((adev->mode == AUDIO_MODE_IN_COMMUNICATION) || (adev->mode == AUDIO_MODE_IN_CALL)) {
@@ -7777,8 +7789,9 @@ int platform_set_swap_channels(struct audio_device *adev, bool swap_channels)
             * to perform device switch to disable the current backend to
             * enable it with new acdb data.
             */
            if (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
                acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]) {
            if (my_data->speaker_lr_swap &&
                (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
                acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE])) {
                const int initial_skpr_gain = ramp_speaker_gain(adev, false /*ramp_up*/, -1);
                select_devices(adev, usecase->id);
                if (initial_skpr_gain != -EINVAL)