From 49b9dcb284a510fdf67e903a95b9d5cdb66ba2e3 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 13 Feb 2017 17:15:07 +0100 Subject: [PATCH] audio: Implement WB_AMR callback correctly Change-Id: Ib2392c8a122d07b40814ca2eeaecf30f9bdb0f99 --- audio/ril_interface.c | 8 +++----- audio/ril_interface.h | 10 +++++++++- audio/voice.c | 22 +++++++++++++--------- audio/voice.h | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/audio/ril_interface.c b/audio/ril_interface.c index e9c7e72..cffbbe6 100644 --- a/audio/ril_interface.c +++ b/audio/ril_interface.c @@ -53,7 +53,7 @@ static int ril_internal_wb_amr_callback(HRilClient client __unused, const void *data, size_t datalen) { - int enable = 0; + int wb_amr_type = 0; if (_wb_amr_data == NULL || _wb_amr_callback == NULL) { return -1; @@ -63,11 +63,9 @@ static int ril_internal_wb_amr_callback(HRilClient client __unused, return -1; } - if (*((int *)data) != 0) { - enable = 1; - } + wb_amr_type = *((int *)data); - _wb_amr_callback(_wb_amr_data, enable); + _wb_amr_callback(_wb_amr_data, wb_amr_type); return 0; } diff --git a/audio/ril_interface.h b/audio/ril_interface.h index 792b15b..11792e3 100644 --- a/audio/ril_interface.h +++ b/audio/ril_interface.h @@ -20,7 +20,15 @@ #include #include -typedef void (*ril_wb_amr_callback)(void *data, int enable); +/** + * @brief The callback to change to wideband which should + * be implemented by the audio HAL. + * + * @param[in] data User data poiner + * @param[in] wb_amr_type 0 = disable WB, 1 = enable WB, + * 2 = WB (and probably NS) + */ +typedef void (*ril_wb_amr_callback)(void *data, int wb_amr_type); struct ril_handle { diff --git a/audio/voice.c b/audio/voice.c index 3ac1e01..ba7b45b 100644 --- a/audio/voice.c +++ b/audio/voice.c @@ -202,7 +202,8 @@ int start_voice_session(struct voice_session *session) ALOGV("%s: Opening voice PCMs", __func__); - if (session->wb_amr) { + /* TODO: Handle wb_amr=2 */ + if (session->wb_amr_type >= 1) { ALOGV("%s: pcm_config wideband", __func__); voice_config = &pcm_config_voicecall_wideband; } else { @@ -341,10 +342,10 @@ bool voice_session_uses_twomic(struct voice_session *session) bool voice_session_uses_wideband(struct voice_session *session) { - return session->wb_amr; + return session->wb_amr_type >= 1; } -static void voice_session_wb_amr_callback(void *data, int enable) +static void voice_session_wb_amr_callback(void *data, int wb_amr_type) { struct audio_device *adev = (struct audio_device *)data; struct voice_session *session = @@ -352,14 +353,17 @@ static void voice_session_wb_amr_callback(void *data, int enable) pthread_mutex_lock(&adev->lock); - if (session->wb_amr != enable) { - session->wb_amr = enable; + if (session->wb_amr_type != wb_amr_type) { + session->wb_amr_type = wb_amr_type; /* reopen the modem PCMs at the new rate */ if (adev->voice.in_call) { - ALOGV("%s: %s wide band voice call", + ALOGV("%s: %s wide band voice call (WB_AMR=%d)", __func__, - enable ? "Enable" : "Disable"); + wb_amr_type > 0 ? "Enable" : "Disable", + wb_amr_type); + + /* TODO Handle wb_amr_type=2 */ stop_voice_call(adev); start_voice_call(adev); @@ -396,9 +400,9 @@ struct voice_session *voice_session_init(struct audio_device *adev) ret = property_get("audio_hal.force_voice_config", voice_config, ""); if (ret > 0) { if ((strncmp(voice_config, "narrow", 6)) == 0) - session->wb_amr = false; + session->wb_amr_type = 0; else if ((strncmp(voice_config, "wide", 4)) == 0) - session->wb_amr = true; + session->wb_amr_type = 1; ALOGV("%s: Forcing voice config: %s", __func__, voice_config); } else { if (RIL_UNSOL_SNDMGR_WB_AMR_REPORT > 0) { diff --git a/audio/voice.h b/audio/voice.h index c89a372..630221f 100644 --- a/audio/voice.h +++ b/audio/voice.h @@ -28,7 +28,7 @@ struct voice_session { struct pcm *pcm_sco_rx; struct pcm *pcm_sco_tx; - bool wb_amr; + int wb_amr_type; bool two_mic_control; bool two_mic_disabled; -- 2.20.1