summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2017-02-13 17:15:07 +0100
committerChristopher N. Hesse <raymanfx@gmail.com>2017-02-19 11:46:55 +0000
commit49b9dcb284a510fdf67e903a95b9d5cdb66ba2e3 (patch)
treee7d1622305df4db8f16b3ed372e4a8c908ffdcf7
parent3ac2971b52a6582ed7b1b4cf547587991ef0a001 (diff)
downloadhardware_samsung-49b9dcb284a510fdf67e903a95b9d5cdb66ba2e3.tar.gz
hardware_samsung-49b9dcb284a510fdf67e903a95b9d5cdb66ba2e3.tar.bz2
hardware_samsung-49b9dcb284a510fdf67e903a95b9d5cdb66ba2e3.zip
audio: Implement WB_AMR callback correctly
Change-Id: Ib2392c8a122d07b40814ca2eeaecf30f9bdb0f99
-rw-r--r--audio/ril_interface.c8
-rw-r--r--audio/ril_interface.h10
-rw-r--r--audio/voice.c22
-rw-r--r--audio/voice.h2
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 <samsung_audio.h>
#include <secril-client.h>
-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;