audio: Dynamic library loading, compilation fixes.
Change-Id: I04d5e7b96611572a7758c610ebdf0fd00e8346aa
diff --git a/libalsa-intf/Android.mk b/libalsa-intf/Android.mk
index cadfa32..23800dd 100644
--- a/libalsa-intf/Android.mk
+++ b/libalsa-intf/Android.mk
@@ -52,12 +52,8 @@
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES:= libc libcutils #libutils #libmedia libhardware_legacy
LOCAL_C_INCLUDES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
-ifeq ($(strip $(TARGET_USES_QCOM_MM_AUDIO)),true)
LOCAL_CFLAGS := -DQC_PROP -DCONFIG_DIR=\"/system/etc/snd_soc_msm/\"
LOCAL_CFLAGS += -DCONFIG_DIR=\"/system/etc/snd_soc_msm/\"
-LOCAL_SHARED_LIBRARIES += libacdbloader
-LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-acdb-util
-endif
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
ifeq ($(TARGET_SIMULATOR),true)
LOCAL_LDLIBS += -ldl
diff --git a/libalsa-intf/alsa_ucm.c b/libalsa-intf/alsa_ucm.c
index 0886d54..cf6b7c0 100644
--- a/libalsa-intf/alsa_ucm.c
+++ b/libalsa-intf/alsa_ucm.c
@@ -62,11 +62,9 @@
#include <linux/ioctl.h>
#include "msm8960_use_cases.h"
#if defined(QC_PROP)
- #include "acdb-loader.h"
-#else
- #define acdb_loader_send_voice_cal(rxacdb_id, txacdb_id) (-EPERM)
- #define acdb_loader_send_audio_cal(acdb_id, capability) (-EPERM)
- #define acdb_loader_send_anc_cal(acdb_id) (-EPERM)
+ static void (*acdb_send_voice_cal)(int, int);
+ static void (*acdb_send_audio_cal)(int, int);
+ static void (*acdb_send_anc_cal)(int);
#endif
#define PARSE_DEBUG 0
@@ -727,8 +725,15 @@
ALOGD("Voice acdb: rx id %d tx id %d",
uc_mgr->current_rx_device,
uc_mgr->current_tx_device);
- acdb_loader_send_voice_cal(uc_mgr->current_rx_device,
- uc_mgr->current_tx_device);
+ if (uc_mgr->acdb_handle) {
+ acdb_send_voice_cal = dlsym(uc_mgr->acdb_handle,"acdb_loader_send_voice_cal");
+ if (acdb_send_voice_cal == NULL) {
+ ALOGE("ucm: dlsym: Error:%s Loading acdb_loader_send_voice_cal", dlerror());
+ } else {
+ acdb_send_voice_cal(uc_mgr->current_rx_device,
+ uc_mgr->current_tx_device);
+ }
+ }
} else {
ALOGV("Voice acdb: Required acdb already pushed \
rx id %d tx id %d", uc_mgr->current_rx_device,
@@ -845,9 +850,15 @@
ALOGD("acdb_id %d cap %d enable %d",
ctrl_list[uc_index].acdb_id,
ctrl_list[uc_index].capability, enable);
- acdb_loader_send_audio_cal(
- ctrl_list[uc_index].acdb_id,
- ctrl_list[uc_index].capability);
+ if (uc_mgr->acdb_handle) {
+ acdb_send_audio_cal = dlsym(uc_mgr->acdb_handle,"acdb_loader_send_audio_cal");
+ if (acdb_send_audio_cal == NULL) {
+ ALOGE("ucm:dlsym:Error:%s Loading acdb_loader_send_audio_cal", dlerror());
+ } else {
+ acdb_send_audio_cal(ctrl_list[uc_index].acdb_id,
+ ctrl_list[uc_index].capability);
+ }
+ }
}
}
if (enable) {
diff --git a/libalsa-intf/msm8960_use_cases.h b/libalsa-intf/msm8960_use_cases.h
index 784aa72..cafca1d 100644
--- a/libalsa-intf/msm8960_use_cases.h
+++ b/libalsa-intf/msm8960_use_cases.h
@@ -172,6 +172,7 @@
int current_rx_device;
card_ctxt_t *card_ctxt_ptr;
pthread_t thr;
+ void *acdb_handle;
};
#define MAX_NUM_CARDS (sizeof(card_list)/sizeof(char *))