audio: Guard WB_AMR callback
authorChristopher N. Hesse <raymanfx@gmail.com>
Wed, 15 Feb 2017 08:47:20 +0000 (09:47 +0100)
committerChristopher N. Hesse <raymanfx@gmail.com>
Wed, 15 Feb 2017 10:25:45 +0000 (11:25 +0100)
Some devices do not support this; some devices are WiFi only
and obviously do not have it.

Change-Id: I6d245eee447bd87849cbdfd41c0cf73c6af714e6

audio/include/samsung_audio.h
audio/ril_interface.h
audio/voice.c

index 1e84c05f49bce58d942ad236421e5443ccdcc62a..c1504f7219fd33fb8879ec3192686fe0dc52b81c 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <telephony/ril.h>
+
 #ifndef SAMSUNG_AUDIO_H
 #define SAMSUNG_AUDIO_H
 
 #define SOUND_PLAYBACK_VOICE_DEVICE 1
 #define SOUND_CAPTURE_VOICE_DEVICE 1
 
+/* Wideband AMR callback */
+#ifndef RIL_UNSOL_SNDMGR_WB_AMR_REPORT
+#ifdef RIL_UNSOL_WB_AMR_STATE
+#define RIL_UNSOL_SNDMGR_WB_AMR_REPORT RIL_UNSOL_WB_AMR_STATE
+#else
+#define RIL_UNSOL_SNDMGR_WB_AMR_REPORT 0
+#endif
+#endif
+
 /* Unusupported
 #define SOUND_CAPTURE_LOOPBACK_AEC_DEVICE 1
 #define SOUND_CAPTURE_HOTWORD_DEVICE 0
index d68c6b4ef0f9118cd5763d657ca72851b077413a..792b15ba7e6876806f61ea2ae3fe1b0e6db43316 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef RIL_INTERFACE_H
 #define RIL_INTERFACE_H
 
-#include <telephony/ril.h>
+#include <samsung_audio.h>
 #include <secril-client.h>
 
 typedef void (*ril_wb_amr_callback)(void *data, int enable);
index 8d73fd1a04b5d1df943e1f12d05fd1da443d857b..3ac1e014a39d09393d47e610069ddc46e5ebaac9 100644 (file)
@@ -401,17 +401,21 @@ struct voice_session *voice_session_init(struct audio_device *adev)
             session->wb_amr = true;
         ALOGV("%s: Forcing voice config: %s", __func__, voice_config);
     } else {
-        /* register callback for wideband AMR setting */
-        ret = ril_set_wb_amr_callback(&session->ril,
-                                      voice_session_wb_amr_callback,
-                                      (void *)adev);
-        if (ret != 0) {
-            ALOGE("%s: Failed to register WB_AMR callback", __func__);
-            free(session);
-            return NULL;
+        if (RIL_UNSOL_SNDMGR_WB_AMR_REPORT > 0) {
+            /* register callback for wideband AMR setting */
+            ret = ril_set_wb_amr_callback(&session->ril,
+                                          voice_session_wb_amr_callback,
+                                          (void *)adev);
+            if (ret != 0) {
+                ALOGE("%s: Failed to register WB_AMR callback", __func__);
+                free(session);
+                return NULL;
+            }
+
+            ALOGV("%s: Registered WB_AMR callback", __func__);
+        } else {
+            ALOGV("%s: WB_AMR callback not supported", __func__);
         }
-
-        ALOGV("%s: Registered WB_AMR callback", __func__);
     }
 
     return session;