From 59486fa48cd55921ed0eddb3c83d7ffb7777ad36 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 6 Feb 2017 09:16:39 +0100 Subject: [PATCH] audio: Add voice call wideband support Change-Id: Idf6725aaaf906109ce973a8109b7c252a997dead --- audio/audio_hw.c | 41 ++++++++++++++++++++++++++++++++++++++--- audio/audio_hw.h | 6 ++++++ audio/voice.c | 5 +++++ audio/voice.h | 1 + 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/audio/audio_hw.c b/audio/audio_hw.c index abec559..d869ae4 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -310,8 +310,11 @@ static const char * const device_table[SND_DEVICE_MAX] = { [SND_DEVICE_OUT_HEADPHONES] = "headphones", [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", [SND_DEVICE_OUT_VOICE_EARPIECE] = "voice-earpiece", + [SND_DEVICE_OUT_VOICE_EARPIECE_WB] = "voice-earpiece-wb", [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", + [SND_DEVICE_OUT_VOICE_SPEAKER_WB] = "voice-speaker-wb", [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", + [SND_DEVICE_OUT_VOICE_HEADPHONES_WB] = "voice-headphones-wb", [SND_DEVICE_OUT_HDMI] = "hdmi", [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", @@ -325,8 +328,11 @@ static const char * const device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", [SND_DEVICE_IN_VOICE_MIC] = "voice-mic", [SND_DEVICE_IN_VOICE_EARPIECE_MIC] = "voice-earpiece-mic", + [SND_DEVICE_IN_VOICE_EARPIECE_MIC_WB] = "voice-earpiece-mic-wb", [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", + [SND_DEVICE_IN_VOICE_SPEAKER_MIC_WB] = "voice-speaker-mic-wb", [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", + [SND_DEVICE_IN_VOICE_HEADSET_MIC_WB] = "voice-headset-mic-wb", [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", @@ -530,13 +536,27 @@ static snd_device_t get_output_snd_device(struct audio_device *adev, audio_devic if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; - } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { - snd_device = SND_DEVICE_OUT_BT_SCO; } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { - snd_device = SND_DEVICE_OUT_EARPIECE; + snd_device = SND_DEVICE_OUT_VOICE_EARPIECE; + } + + if (voice_session_uses_wideband(adev->voice.session)) { + if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || + devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { + snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES_WB; + } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { + snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_WB; + } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { + snd_device = SND_DEVICE_OUT_VOICE_EARPIECE_WB; + } + } + + if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { + snd_device = SND_DEVICE_OUT_BT_SCO; } + if (snd_device != SND_DEVICE_NONE) { goto exit; } @@ -626,6 +646,21 @@ static snd_device_t get_input_snd_device(struct audio_device *adev, audio_device snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; } } + + if (voice_session_uses_wideband(adev->voice.session)) { + if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { + snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC_WB; + } + + if (voice_session_uses_twomic(adev->voice.session)) { + if (out_device & AUDIO_DEVICE_OUT_EARPIECE || + out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { + snd_device = SND_DEVICE_IN_VOICE_EARPIECE_MIC_WB; + } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { + snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC_WB; + } + } + } } else if (source == AUDIO_SOURCE_CAMCORDER) { if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || in_device & AUDIO_DEVICE_IN_BACK_MIC) { diff --git a/audio/audio_hw.h b/audio/audio_hw.h index 74be201..45c3407 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -68,8 +68,11 @@ enum { SND_DEVICE_OUT_HEADPHONES, SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, SND_DEVICE_OUT_VOICE_EARPIECE, + SND_DEVICE_OUT_VOICE_EARPIECE_WB, SND_DEVICE_OUT_VOICE_SPEAKER, + SND_DEVICE_OUT_VOICE_SPEAKER_WB, SND_DEVICE_OUT_VOICE_HEADPHONES, + SND_DEVICE_OUT_VOICE_HEADPHONES_WB, SND_DEVICE_OUT_HDMI, SND_DEVICE_OUT_SPEAKER_AND_HDMI, SND_DEVICE_OUT_BT_SCO, @@ -89,8 +92,11 @@ enum { SND_DEVICE_IN_HEADSET_MIC_AEC, SND_DEVICE_IN_VOICE_MIC, SND_DEVICE_IN_VOICE_EARPIECE_MIC, + SND_DEVICE_IN_VOICE_EARPIECE_MIC_WB, SND_DEVICE_IN_VOICE_SPEAKER_MIC, + SND_DEVICE_IN_VOICE_SPEAKER_MIC_WB, SND_DEVICE_IN_VOICE_HEADSET_MIC, + SND_DEVICE_IN_VOICE_HEADSET_MIC_WB, SND_DEVICE_IN_HDMI_MIC, SND_DEVICE_IN_BT_SCO_MIC, SND_DEVICE_IN_CAMCORDER_MIC, diff --git a/audio/voice.c b/audio/voice.c index e59565a..440329d 100644 --- a/audio/voice.c +++ b/audio/voice.c @@ -253,6 +253,11 @@ bool voice_session_uses_twomic(struct voice_session *session) return session->two_mic_control; } +bool voice_session_uses_wideband(struct voice_session *session) +{ + return session->wb_amr; +} + static void voice_session_wb_amr_callback(void *data, int enable) { struct audio_device *adev = (struct audio_device *)data; diff --git a/audio/voice.h b/audio/voice.h index c63cd26..352e839 100644 --- a/audio/voice.h +++ b/audio/voice.h @@ -41,6 +41,7 @@ void set_voice_session_volume(struct voice_session *session, float volume); void set_voice_session_audio_path(struct voice_session *session); bool voice_session_uses_twomic(struct voice_session *session); +bool voice_session_uses_wideband(struct voice_session *session); struct voice_session *voice_session_init(struct audio_device *adev); void voice_session_deinit(struct voice_session *s); -- 2.20.1