A2DP Offload HAL v2.0 support
Bug: 119490165
Change-Id: I8651a6b322b88fe38900c663eb7c7ad55a4ba517
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index 7c2e4db..43b3da9 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -34,6 +34,7 @@
#ifdef A2DP_OFFLOAD_ENABLED
#define BT_IPC_LIB_NAME "libbthost_if.so"
+#define BTAUDIO_OFFLOAD_LIB_NAME "btaudio_offload_if.so"
// Media format definitions
#define ENC_MEDIA_FMT_AAC 0x00010DA6
@@ -78,6 +79,7 @@
// System properties used for A2DP Offload
#define SYSPROP_A2DP_OFFLOAD_SUPPORTED "ro.bluetooth.a2dp_offload.supported"
#define SYSPROP_A2DP_OFFLOAD_DISABLED "persist.bluetooth.a2dp_offload.disabled"
+#define SYSPROP_BLUETOOTH_AUDIO_HAL_ENABLED "persist.vendor.bluetooth.bluetooth_audio_hal.enabled"
#define SYSPROP_A2DP_CODEC_LATENCIES "vendor.audio.a2dp.codec.latency"
// Default encoder bit width
@@ -676,8 +678,9 @@
static int open_a2dp_output()
{
int ret = 0;
-
ALOGD("%s: Open A2DP output start", __func__);
+ bool hal_v2_enabled =
+ property_get_bool(SYSPROP_BLUETOOTH_AUDIO_HAL_ENABLED, false);
if (a2dp.bt_state != A2DP_STATE_DISCONNECTED) {
ALOGD("%s: Called A2DP open with improper state, Ignoring request state %d",
@@ -686,9 +689,13 @@
}
if (a2dp.bt_lib_handle == NULL) {
- ALOGD("%s: Requesting for Bluetooth IPC lib handle", __func__);
- a2dp.bt_lib_handle = dlopen(BT_IPC_LIB_NAME, RTLD_NOW);
-
+ ALOGD("%s: Requesting for Bluetooth IPC lib handle [%s]", __func__,
+ hal_v2_enabled ? BTAUDIO_OFFLOAD_LIB_NAME : BT_IPC_LIB_NAME);
+ if (hal_v2_enabled) {
+ a2dp.bt_lib_handle = dlopen(BTAUDIO_OFFLOAD_LIB_NAME, RTLD_NOW);
+ } else {
+ a2dp.bt_lib_handle = dlopen(BT_IPC_LIB_NAME, RTLD_NOW);
+ }
if (a2dp.bt_lib_handle == NULL) {
ret = -errno;
ALOGE("%s: DLOPEN failed for %s errno %d strerror %s", __func__,