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

Commit 40b07892 authored by David Lin's avatar David Lin
Browse files

hal: select loudspeaker mic when usb headphone is used for calls



In case an USB headphone is attached, loudspeaker mic should be used
instead of the handset mic.

Bug: 63680197
Bug: 64121918
Test: manual hangout and voice call
Change-Id: Ib7036b98c5331767827131e73d3e041bfbdaf7fe
Signed-off-by: default avatarDavid Lin <dtwlin@google.com>
parent d9653bdb
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -2548,6 +2548,12 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
        } else if (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) {
        } else if (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)) {
            if (audio_extn_usb_is_capture_supported()) {
            if (audio_extn_usb_is_capture_supported()) {
              snd_device = SND_DEVICE_IN_VOICE_USB_HEADSET_MIC;
              snd_device = SND_DEVICE_IN_VOICE_USB_HEADSET_MIC;
            } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode) {
                if (my_data->source_mic_type & SOURCE_DUAL_MIC) {
                    snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC;
                } else {
                    snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
                }
            }
            }
        }
        }
    } else if (source == AUDIO_SOURCE_CAMCORDER) {
    } else if (source == AUDIO_SOURCE_CAMCORDER) {
@@ -2630,8 +2636,12 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
        }
        }
    } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
    } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
               mode == AUDIO_MODE_IN_COMMUNICATION) {
               mode == AUDIO_MODE_IN_COMMUNICATION) {
        if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE))
        if (out_device & (AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_SPEAKER_SAFE) ||
            out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
            (out_device & (AUDIO_DEVICE_OUT_USB_DEVICE | AUDIO_DEVICE_OUT_USB_HEADSET) &&
                !audio_extn_usb_is_capture_supported())) {
            in_device = AUDIO_DEVICE_IN_BACK_MIC;
            in_device = AUDIO_DEVICE_IN_BACK_MIC;
        }
        if (adev->active_input) {
        if (adev->active_input) {
            if (adev->active_input->enable_aec &&
            if (adev->active_input->enable_aec &&
                    adev->active_input->enable_ns) {
                    adev->active_input->enable_ns) {