summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/Android.mk5
-rw-r--r--audio/ril_interface.c82
-rw-r--r--audio/ril_interface.h45
3 files changed, 105 insertions, 27 deletions
diff --git a/audio/Android.mk b/audio/Android.mk
index b678403..dcd83f6 100644
--- a/audio/Android.mk
+++ b/audio/Android.mk
@@ -22,9 +22,8 @@ LOCAL_SRC_FILES := audio_hw.c ril_interface.c
LOCAL_C_INCLUDES += \
external/tinyalsa/include \
$(call include-path-for, audio-utils) \
- $(call include-path-for, audio-effects) \
- $(LOCAL_PATH)/../ril/libsecril-client
-LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl libsecril-client
+ $(call include-path-for, audio-effects)
+LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl
LOCAL_MODULE_TAGS := optional
ifeq ($(TARGET_TUNA_AUDIO_FORCE_SAMPLE_RATE),)
diff --git a/audio/ril_interface.c b/audio/ril_interface.c
index 558b157..0f9cb30 100644
--- a/audio/ril_interface.c
+++ b/audio/ril_interface.c
@@ -28,6 +28,18 @@
#define VOLUME_STEPS_DEFAULT "5"
#define VOLUME_STEPS_PROPERTY "ro.config.vc_call_vol_steps"
+/* Function pointers */
+void *(*_ril_open_client)(void);
+int (*_ril_close_client)(void *);
+int (*_ril_connect)(void *);
+int (*_ril_is_connected)(void *);
+int (*_ril_disconnect)(void *);
+int (*_ril_set_call_volume)(void *, enum ril_sound_type, int);
+int (*_ril_set_call_audio_path)(void *, enum ril_audio_path);
+int (*_ril_register_unsolicited_handler)(void *, int, void *);
+int (*_ril_get_wb_amr)(void *, void *);
+int (*_ril_set_mic_mute)(void *, enum ril_mic_mute);
+
/* Audio WB AMR callback */
void (*_audio_set_wb_amr_callback)(void *, int);
void *callback_data = NULL;
@@ -56,17 +68,18 @@ static int ril_set_wb_amr_callback(void *ril_client,
static int ril_connect_if_required(struct ril_handle *ril)
{
- if (isConnected_RILD(ril->client))
+ if (_ril_is_connected(ril->client))
return 0;
- if (Connect_RILD(ril->client) != RIL_CLIENT_ERR_SUCCESS) {
- ALOGE("Connect_RILD() failed");
+ if (_ril_connect(ril->client) != RIL_CLIENT_ERR_SUCCESS) {
+ ALOGE("ril_connect() failed");
return -1;
}
/* get wb amr status to set pcm samplerate depending on
wb amr status when ril is connected. */
- GetWB_AMR(ril->client, (RilOnComplete)ril_set_wb_amr_callback);
+ if(_ril_get_wb_amr)
+ _ril_get_wb_amr(ril->client, ril_set_wb_amr_callback);
return 0;
}
@@ -78,15 +91,45 @@ int ril_open(struct ril_handle *ril)
if (!ril)
return -1;
- ril->client = OpenClient_RILD();
+ ril->handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW);
+
+ if (!ril->handle) {
+ ALOGE("Cannot open '%s'", RIL_CLIENT_LIBPATH);
+ return -1;
+ }
+
+ _ril_open_client = dlsym(ril->handle, "OpenClient_RILD");
+ _ril_close_client = dlsym(ril->handle, "CloseClient_RILD");
+ _ril_connect = dlsym(ril->handle, "Connect_RILD");
+ _ril_is_connected = dlsym(ril->handle, "isConnected_RILD");
+ _ril_disconnect = dlsym(ril->handle, "Disconnect_RILD");
+ _ril_set_call_volume = dlsym(ril->handle, "SetCallVolume");
+ _ril_set_call_audio_path = dlsym(ril->handle, "SetCallAudioPath");
+ _ril_set_mic_mute = dlsym(ril->handle, "SetMute");
+ _ril_register_unsolicited_handler = dlsym(ril->handle,
+ "RegisterUnsolicitedHandler");
+ /* since this function is not supported in all RILs, don't require it */
+ _ril_get_wb_amr = dlsym(ril->handle, "GetWB_AMR");
+
+ if (!_ril_open_client || !_ril_close_client || !_ril_connect ||
+ !_ril_is_connected || !_ril_disconnect || !_ril_set_call_volume ||
+ !_ril_set_call_audio_path || !_ril_register_unsolicited_handler ||
+ !_ril_set_mic_mute) {
+ ALOGE("Cannot get symbols from '%s'", RIL_CLIENT_LIBPATH);
+ dlclose(ril->handle);
+ return -1;
+ }
+
+ ril->client = _ril_open_client();
if (!ril->client) {
- ALOGE("OpenClient_RILD() failed");
+ ALOGE("ril_open_client() failed");
+ dlclose(ril->handle);
return -1;
}
/* register the wideband AMR callback */
- RegisterUnsolicitedHandler(ril->client, RIL_UNSOL_WB_AMR_STATE,
- (RilOnUnsolicited)ril_set_wb_amr_callback);
+ _ril_register_unsolicited_handler(ril->client, RIL_UNSOL_WB_AMR_STATE,
+ ril_set_wb_amr_callback);
property_get(VOLUME_STEPS_PROPERTY, property, VOLUME_STEPS_DEFAULT);
ril->volume_steps_max = atoi(property);
@@ -100,40 +143,41 @@ int ril_open(struct ril_handle *ril)
int ril_close(struct ril_handle *ril)
{
- if (!ril || !ril->client)
+ if (!ril || !ril->handle || !ril->client)
return -1;
- if ((Disconnect_RILD(ril->client) != RIL_CLIENT_ERR_SUCCESS) ||
- (CloseClient_RILD(ril->client) != RIL_CLIENT_ERR_SUCCESS)) {
- ALOGE("Disconnect_RILD() or CloseClient_RILD() failed");
+ if ((_ril_disconnect(ril->client) != RIL_CLIENT_ERR_SUCCESS) ||
+ (_ril_close_client(ril->client) != RIL_CLIENT_ERR_SUCCESS)) {
+ ALOGE("ril_disconnect() or ril_close_client() failed");
return -1;
}
+ dlclose(ril->handle);
return 0;
}
-int ril_set_call_volume(struct ril_handle *ril, enum _SoundType sound_type,
+int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type,
float volume)
{
if (ril_connect_if_required(ril))
return 0;
- return SetCallVolume(ril->client, sound_type,
- (int)(volume * ril->volume_steps_max));
+ return _ril_set_call_volume(ril->client, sound_type,
+ (int)(volume * ril->volume_steps_max));
}
-int ril_set_call_audio_path(struct ril_handle *ril, enum _AudioPath path)
+int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path)
{
if (ril_connect_if_required(ril))
return 0;
- return SetCallAudioPath(ril->client, path);
+ return _ril_set_call_audio_path(ril->client, path);
}
-int ril_set_mic_mute(struct ril_handle *ril, enum _MuteCondition state)
+int ril_set_mic_mute(struct ril_handle *ril, enum ril_mic_mute state)
{
if (ril_connect_if_required(ril))
return 0;
- return SetMute(ril->client, state);
+ return _ril_set_mic_mute(ril->client, state);
}
diff --git a/audio/ril_interface.h b/audio/ril_interface.h
index f82a83d..a3da6e2 100644
--- a/audio/ril_interface.h
+++ b/audio/ril_interface.h
@@ -17,7 +17,16 @@
#ifndef RIL_INTERFACE_H
#define RIL_INTERFACE_H
-#include "secril-client.h"
+#define RIL_CLIENT_LIBPATH "libsecril-client.so"
+
+#define RIL_CLIENT_ERR_SUCCESS 0
+#define RIL_CLIENT_ERR_AGAIN 1
+#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized
+#define RIL_CLIENT_ERR_INVAL 3 // Invalid value
+#define RIL_CLIENT_ERR_CONNECT 4 // Connection error
+#define RIL_CLIENT_ERR_IO 5 // IO error
+#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available
+#define RIL_CLIENT_ERR_UNKNOWN 7
#define RIL_OEM_UNSOL_RESPONSE_BASE 11000 // RIL response base index
#define RIL_UNSOL_WB_AMR_STATE \
@@ -25,17 +34,43 @@
struct ril_handle
{
+ void *handle;
void *client;
int volume_steps_max;
};
+enum ril_sound_type {
+ SOUND_TYPE_VOICE,
+ SOUND_TYPE_SPEAKER,
+ SOUND_TYPE_HEADSET,
+ SOUND_TYPE_BTVOICE
+};
+
+enum ril_audio_path {
+ SOUND_AUDIO_PATH_HANDSET,
+ SOUND_AUDIO_PATH_HEADSET,
+ SOUND_AUDIO_PATH_SPEAKER,
+ SOUND_AUDIO_PATH_BLUETOOTH,
+ SOUND_AUDIO_PATH_BLUETOOTH_NO_NR,
+ SOUND_AUDIO_PATH_HEADPHONE
+};
+
+enum ril_clock_state {
+ SOUND_CLOCK_STOP,
+ SOUND_CLOCK_START
+};
+
+enum ril_mic_mute {
+ MIC_UNMUTE,
+ MIC_MUTE
+};
+
/* Function prototypes */
int ril_open(struct ril_handle *ril);
int ril_close(struct ril_handle *ril);
-int ril_set_call_volume(struct ril_handle *ril, enum _SoundType sound_type,
+int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type,
float volume);
-int ril_set_call_audio_path(struct ril_handle *ril, enum _AudioPath path);
-int ril_set_mic_mute(struct ril_handle *ril, enum _MuteCondition state);
+int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path);
void ril_register_set_wb_amr_callback(void *function, void *data);
-
#endif
+