summaryrefslogtreecommitdiff
path: root/android/hal-audio-aptx.c
diff options
context:
space:
mode:
authorAndrzej Kaczmarek <andrzej.kaczmarek@tieto.com>2014-06-02 18:37:50 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-06-06 11:27:45 +0300
commit922a069beca1799ff1012d286ac73039bf7c951d (patch)
tree9872294e9378d0fa8e136e870ebe824c58ce830a /android/hal-audio-aptx.c
parent683aa4bf368c3fcdf2216b2fe280bbd42fdd4699 (diff)
downloadbluez-922a069beca1799ff1012d286ac73039bf7c951d.tar.gz
android/hal-audio-aptx: Load aptX encoder library
This patch adds loading of aptX encoder library which should be provided by user. hal-audio-aptx will try to load 'libbt-aptx.so' so it should be available in search patch, preferably in /system/lib.
Diffstat (limited to 'android/hal-audio-aptx.c')
-rw-r--r--android/hal-audio-aptx.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/android/hal-audio-aptx.c b/android/hal-audio-aptx.c
index fed648bf5..807d82d9d 100644
--- a/android/hal-audio-aptx.c
+++ b/android/hal-audio-aptx.c
@@ -27,6 +27,8 @@
#include "src/shared/util.h"
#include "profiles/audio/a2dp-codecs.h"
+#define APTX_SO_NAME "libbt-aptx.so"
+
struct aptx_data {
a2dp_aptx_t aptx;
@@ -61,15 +63,56 @@ static const a2dp_aptx_t aptx_presets[] = {
},
};
+static void *aptx_handle;
+static int aptx_btencsize;
+static int (*aptx_init)(void *, short);
+static int (*aptx_encode)(void *, void *, void *, void *);
+
static bool aptx_load(void)
{
- /* TODO: load aptX codec library */
- return false;
+ const char * (*aptx_version)(void);
+ const char * (*aptx_build)(void);
+ int (*aptx_sizeofenc)(void);
+
+ aptx_handle = dlopen(APTX_SO_NAME, RTLD_LAZY);
+ if (!aptx_handle) {
+ error("APTX: failed to open library %s (%s)", APTX_SO_NAME,
+ dlerror());
+ return false;
+ }
+
+ aptx_version = dlsym(aptx_handle, "aptxbtenc_version");
+ aptx_build = dlsym(aptx_handle, "aptxbtenc_build");
+
+ if (aptx_version && aptx_build)
+ info("APTX: using library version %s build %s", aptx_version(),
+ aptx_build());
+ else
+ warn("APTX: cannot retrieve library version");
+
+ aptx_sizeofenc = dlsym(aptx_handle, "SizeofAptxbtenc");
+ aptx_init = dlsym(aptx_handle, "aptxbtenc_init");
+ aptx_encode = dlsym(aptx_handle, "aptxbtenc_encodestereo");
+ if (!aptx_sizeofenc || !aptx_init || !aptx_encode) {
+ error("APTX: failed initialize library");
+ dlclose(aptx_handle);
+ aptx_handle = NULL;
+ return false;
+ }
+ aptx_btencsize = aptx_sizeofenc();
+
+ info("APTX: codec library initialized (size=%d)", aptx_btencsize);
+
+ return true;
}
static void aptx_unload(void)
{
- /* TODO: unload aptX codec library */
+ if (!aptx_handle)
+ return;
+
+ dlclose(aptx_handle);
+ aptx_handle = NULL;
}
static int aptx_get_presets(struct audio_preset *preset, size_t *len)