summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmesh Vats <uvats@codeaurora.org>2016-07-13 10:39:05 -0700
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:09:57 -0600
commitab2b2490da19d8bb39322fff2db2f001050fb0d4 (patch)
tree1a266914c34ed4a1f85f587838f1bee44c08c305
parentf26b3e3890938862a3722f1acabc3855eaa9728c (diff)
downloadandroid_system_bt-ab2b2490da19d8bb39322fff2db2f001050fb0d4.tar.gz
android_system_bt-ab2b2490da19d8bb39322fff2db2f001050fb0d4.tar.bz2
android_system_bt-ab2b2490da19d8bb39322fff2db2f001050fb0d4.zip
Removed compilation dependency on proprietary modules for aptX
This commit takes care of removing compilation dependencies between platform/system/bt and vendor/qcom/prop../bt/hci_qcomm_init/aptX. aptX module in the proprietary projects has been removed Change-Id: Ibab863be20d7792d7eb187cb5c831a7f4972a19b CRs-Fixed: 1036566
-rw-r--r--bta/Android.mk3
-rw-r--r--bta/av/bta_av_main.c2
-rw-r--r--btif/Android.mk2
-rw-r--r--btif/co/bta_av_co.c80
-rw-r--r--btif/include/btif_av_co.h2
-rw-r--r--btif/src/btif_media_task.c211
-rw-r--r--main/Android.mk14
-rw-r--r--stack/Android.mk3
-rw-r--r--stack/a2dp/a2d_aptx.c71
-rw-r--r--stack/include/a2d_api.h3
-rw-r--r--stack/include/a2d_aptx.h127
11 files changed, 418 insertions, 100 deletions
diff --git a/bta/Android.mk b/bta/Android.mk
index 999b1102f..bd1b19db8 100644
--- a/bta/Android.mk
+++ b/bta/Android.mk
@@ -98,9 +98,6 @@ LOCAL_C_INCLUDES+= . \
$(TARGET_OUT_HEADERS)/bt/hci_qcomm_init/aptX \
$(bluetooth_C_INCLUDES)
-LOCAL_MULTILIB := 32
-LOCAL_SHARED_LIBRARIES += libaptXScheduler
-
LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c
index 937e9f2d4..6591c2e59 100644
--- a/bta/av/bta_av_main.c
+++ b/bta/av/bta_av_main.c
@@ -46,7 +46,7 @@
#include "bta_ar_api.h"
#endif
-#include "aptXCaps.h"
+#include "a2d_aptx.h"
/*****************************************************************************
** Constants and types
diff --git a/btif/Android.mk b/btif/Android.mk
index c3608ecf0..b949156fd 100644
--- a/btif/Android.mk
+++ b/btif/Android.mk
@@ -130,8 +130,6 @@ LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-LOCAL_MULTILIB := 32
-LOCAL_SHARED_LIBRARIES += libaptXScheduler
include $(BUILD_STATIC_LIBRARY)
diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c
index 9929fb77f..297ee1925 100644
--- a/btif/co/bta_av_co.c
+++ b/btif/co/bta_av_co.c
@@ -43,8 +43,8 @@
#include "btif_util.h"
#include "osi/include/mutex.h"
-#include "aptXCaps.h"
-#include "aptXScheduler.h"
+#include "bt_utils.h"
+#include "a2d_aptx.h"
/*****************************************************************************
** Constants
@@ -117,23 +117,23 @@ const tA2D_SBC_CIE btif_av_sbc_default_config =
const tA2D_APTX_CIE bta_av_co_aptx_caps =
{
- QTI_APTX_VENDOR_ID,
- QTI_APTX_CODEC_ID_BLUETOOTH,
- QTI_APTX_SAMPLERATE_44100,
- QTI_APTX_CHANNELS_STEREO,
- QTI_APTX_FUTURE_1,
- QTI_APTX_FUTURE_2
+ A2D_APTX_VENDOR_ID,
+ A2D_APTX_CODEC_ID_BLUETOOTH,
+ A2D_APTX_SAMPLERATE_44100,
+ A2D_APTX_CHANNELS_STEREO,
+ A2D_APTX_FUTURE_1,
+ A2D_APTX_FUTURE_2
};
/* Default aptX codec configuration */
const tA2D_APTX_CIE btif_av_aptx_default_config =
{
- QTI_APTX_VENDOR_ID,
- QTI_APTX_CODEC_ID_BLUETOOTH,
- QTI_APTX_SAMPLERATE_44100,
- QTI_APTX_CHANNELS_STEREO,
- QTI_APTX_FUTURE_1,
- QTI_APTX_FUTURE_2
+ A2D_APTX_VENDOR_ID,
+ A2D_APTX_CODEC_ID_BLUETOOTH,
+ A2D_APTX_SAMPLERATE_44100,
+ A2D_APTX_CHANNELS_STEREO,
+ A2D_APTX_FUTURE_1,
+ A2D_APTX_FUTURE_2
};
/*****************************************************************************
@@ -342,10 +342,10 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_
/* Codec is valid */
return TRUE;
- case BTIF_SV_AV_AA_QTI_APTX_INDEX:
+ case BTIF_SV_AV_AA_APTX_INDEX:
APPL_TRACE_DEBUG("%s aptX", __func__);
/* Set up for aptX codec */
- *p_codec_type = NON_A2DP_MEDIA_CT;
+ *p_codec_type = A2D_NON_A2DP_MEDIA_CT;
A2D_BldAptxInfo(AVDT_MEDIA_AUDIO, (tA2D_APTX_CIE *) &bta_av_co_aptx_caps, p_codec_info);
return TRUE;
@@ -661,14 +661,14 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
case BTA_AV_CODEC_SBC:
supported = TRUE;
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
{
UINT16 codecId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->codecId;
UINT32 vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->vendorId;
APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId );
APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId );
- if (codecId == QTI_APTX_CODEC_ID_BLUETOOTH && vendorId == QTI_APTX_VENDOR_ID)
+ if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID)
{
/* aptX */
supported = TRUE;
@@ -694,7 +694,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
for (i = 0 ; i < AVDT_CODEC_SIZE; i++)
APPL_TRACE_DEBUG("%s p_codec_info[%d]: %x", __func__, i, p_codec_info[i]);
- if (codec_type == NON_A2DP_MEDIA_CT)
+ if (codec_type == A2D_NON_A2DP_MEDIA_CT)
memcpy(p_sink->codec_caps, &p_codec_info[3], AVDT_CODEC_SIZE);
else
memcpy(p_sink->codec_caps, p_codec_info, AVDT_CODEC_SIZE);
@@ -911,7 +911,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
}
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
{
UINT16 codecId;
UINT32 vendorId;
@@ -921,7 +921,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId);
APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId);
- if ((codec_type != NON_A2DP_MEDIA_CT) || memcmp(p_codec_info, bta_av_co_cb.codec_cfg->info, 5))
+ if ((codec_type != A2D_NON_A2DP_MEDIA_CT) || memcmp(p_codec_info, bta_av_co_cb.codec_cfg->info, 5))
{
APPL_TRACE_DEBUG("%s recfg_needed", __func__);
recfg_needed = TRUE;
@@ -932,10 +932,10 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
recfg_needed = TRUE;
}
- if (codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
{
APPL_TRACE_DEBUG("%s aptX", __func__);
- bta_av_co_cb.codec_cfg_aptx_setconfig.id = NON_A2DP_MEDIA_CT;
+ bta_av_co_cb.codec_cfg_aptx_setconfig.id = A2D_NON_A2DP_MEDIA_CT;
memcpy(bta_av_co_cb.codec_cfg_aptx_setconfig.info, p_codec_info, AVDT_CODEC_SIZE);
bta_av_co_cb.codec_cfg_setconfig = &bta_av_co_cb.codec_cfg_aptx_setconfig;
}
@@ -1129,7 +1129,7 @@ void * bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, UINT32 *p_len,
/* Set up packet header */
bta_av_sbc_bld_hdr(p_buf, p_buf->layer_specific);
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
/* Retrieve the timestamp information from the media packet */
*p_timestamp = *((UINT32 *) (p_buf + 1));
break;
@@ -1224,7 +1224,7 @@ static BOOLEAN bta_av_co_audio_codec_build_config(const UINT8 *p_codec_caps, UIN
p_codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF]);
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
{
UINT16 codecId;
UINT16 vendorId;
@@ -1233,7 +1233,7 @@ static BOOLEAN bta_av_co_audio_codec_build_config(const UINT8 *p_codec_caps, UIN
APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId);
APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId);
- memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg->info, BTA_AV_CO_APTX_CODEC_LEN+1);
+ memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg->info, A2D_APTX_CODEC_LEN+1);
APPL_TRACE_DEBUG("%s aptX",__func__);
break;
}
@@ -1281,7 +1281,7 @@ static BOOLEAN bta_av_co_audio_codec_cfg_matches_caps(UINT8 codec_id, const UINT
return FALSE;
}
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
{
UINT16 codecId;
UINT32 vendorId;
@@ -1343,7 +1343,7 @@ static BOOLEAN bta_av_co_audio_codec_match(const UINT8 *p_codec_caps, UINT8 code
case BTIF_AV_CODEC_SBC:
return bta_av_co_audio_codec_cfg_matches_caps(bta_av_co_cb.codec_cfg_sbc.id, p_codec_caps, bta_av_co_cb.codec_cfg_sbc.info);
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
{
UINT16 codecId;
UINT32 vendorId;
@@ -1356,7 +1356,7 @@ static BOOLEAN bta_av_co_audio_codec_match(const UINT8 *p_codec_caps, UINT8 code
APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecId);
APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, vendorId);
- if (codecId == QTI_APTX_CODEC_ID_BLUETOOTH && vendorId == QTI_APTX_VENDOR_ID)
+ if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID)
{
/* aptX Classic */
APPL_TRACE_DEBUG("%s aptX", __func__);
@@ -1501,7 +1501,7 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT
* Check for aptX as this is order of priority,
* if supported return true.
*/
- if ((btif_max_av_clients <= 1) && !aptx_scheduler_init())
+ if ((btif_max_av_clients <= 1) && isA2dAptXEnabled)
{
UINT16 codecId;
UINT32 vendorId;
@@ -1509,7 +1509,7 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT
for (index = 0; index < p_peer->num_sup_snks; index++)
{
- if (p_peer->snks[index].codec_type == NON_A2DP_MEDIA_CT)
+ if (p_peer->snks[index].codec_type == A2D_NON_A2DP_MEDIA_CT)
{
aptx_capabilities = &(p_peer->snks[index].codec_caps[0]);
codecId = ((tA2D_APTX_CIE*)aptx_capabilities)->codecId;
@@ -1522,13 +1522,13 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT
APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId);
APPL_TRACE_DEBUG("%s p_peer->snks[index].codec_type = %x", __func__, p_peer->snks[index].codec_type );
- if (codecId == QTI_APTX_CODEC_ID_BLUETOOTH && vendorId == QTI_APTX_VENDOR_ID)
+ if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID)
{
if (p_snk_index)
*p_snk_index = index;
APPL_TRACE_DEBUG("%s aptX", __func__);
- if (bta_av_co_audio_codec_match(p_peer->snks[index].codec_caps, NON_A2DP_MEDIA_CT))
+ if (bta_av_co_audio_codec_match(p_peer->snks[index].codec_caps, A2D_NON_A2DP_MEDIA_CT))
{
#if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE)
if (bta_av_co_audio_sink_has_scmst(&p_peer->snks[index]))
@@ -1678,14 +1678,14 @@ static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UIN
return FALSE;
}
break;
- case NON_A2DP_MEDIA_CT:
+ case A2D_NON_A2DP_MEDIA_CT:
aptx_capabilities = &(((tBTA_AV_CO_SINK*)p_codec_cfg)->codec_caps[0]);
codecId = ((tA2D_APTX_CIE*)(aptx_capabilities))->codecId;
vendorId = ((tA2D_APTX_CIE*)(aptx_capabilities))->vendorId;
APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecId);
APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, vendorId);
- if (codecId == QTI_APTX_CODEC_ID_BLUETOOTH && vendorId == QTI_APTX_VENDOR_ID)
+ if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID)
{
APPL_TRACE_DEBUG("%s tA2D_APTX_CIE aptX", __func__);
if (bta_av_aptx_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_APTX_CIE *)&bta_av_co_aptx_caps))
@@ -1836,7 +1836,7 @@ void bta_av_co_audio_codec_reset(void)
bta_av_co_cb.codec_cfg = &(bta_av_co_cb.codec_cfg_sbc);
/* Reset the Current configuration to aptX */
- bta_av_co_cb.codec_cfg_aptx.id = NON_A2DP_MEDIA_CT;
+ bta_av_co_cb.codec_cfg_aptx.id = A2D_NON_A2DP_MEDIA_CT;
if (A2D_BldAptxInfo(A2D_MEDIA_TYPE_AUDIO, (tA2D_APTX_CIE *)&btif_av_aptx_default_config, bta_av_co_cb.codec_cfg_aptx.info) != A2D_SUCCESS)
APPL_TRACE_ERROR("%s A2D_BldAptxInfo failed", __func__);
@@ -1886,7 +1886,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI
APPL_TRACE_ERROR("bta_av_co_audio_set_codec PCM sample size unsupported");
return FALSE;
}
- new_cfg_aptx.id = NON_A2DP_MEDIA_CT;
+ new_cfg_aptx.id = A2D_NON_A2DP_MEDIA_CT;
aptx_config = btif_av_aptx_default_config;
switch (p_feeding->cfg.pcm.sampling_freq)
{
@@ -1897,14 +1897,14 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI
case 32000:
case 48000:
sbc_config.samp_freq = A2D_SBC_IE_SAMP_FREQ_48;
- aptx_config.sampleRate = QTI_APTX_SAMPLERATE_48000;
+ aptx_config.sampleRate = A2D_APTX_SAMPLERATE_48000;
break;
case 11025:
case 22050:
case 44100:
sbc_config.samp_freq = A2D_SBC_IE_SAMP_FREQ_44;
- aptx_config.sampleRate = QTI_APTX_SAMPLERATE_44100;
+ aptx_config.sampleRate = A2D_APTX_SAMPLERATE_44100;
break;
default:
APPL_TRACE_ERROR("bta_av_co_audio_set_codec PCM sampling frequency unsupported");
@@ -1989,7 +1989,7 @@ BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT
else
memcpy((tA2D_SBC_CIE *) p_config, &btif_av_sbc_default_config, sizeof(tA2D_SBC_CIE));
}
- if (type == NON_A2DP_MEDIA_CT && ((tA2D_APTX_CIE *)p_config)->vendorId == QTI_APTX_VENDOR_ID && ((tA2D_APTX_CIE *)p_config)->codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (type == A2D_NON_A2DP_MEDIA_CT && ((tA2D_APTX_CIE *)p_config)->vendorId == A2D_APTX_VENDOR_ID && ((tA2D_APTX_CIE *)p_config)->codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
{
APPL_TRACE_DEBUG("%s aptX", __func__);
tA2D_APTX_CIE *aptx_config = (tA2D_APTX_CIE *)p_config;
diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h
index c57030ac2..c7107de95 100644
--- a/btif/include/btif_av_co.h
+++ b/btif/include/btif_av_co.h
@@ -34,7 +34,7 @@
enum
{
BTIF_SV_AV_AA_SBC_INDEX = 0,
- BTIF_SV_AV_AA_QTI_APTX_INDEX,
+ BTIF_SV_AV_AA_APTX_INDEX,
BTIF_SV_AV_AA_SBC_SINK_INDEX,
BTIF_SV_AV_AA_SEP_INDEX /* Last index */
};
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 4e93077f2..fbe7bfba7 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -42,6 +42,7 @@
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
+#include <dlfcn.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -50,9 +51,11 @@
#include <hardware/bluetooth.h>
+#include "bt_utils.h"
#include "a2d_api.h"
#include "a2d_int.h"
#include "a2d_sbc.h"
+#include "a2d_aptx.h"
#include "audio_a2dp_hw.h"
#include "bt_target.h"
#include "bta_api.h"
@@ -79,8 +82,6 @@
#if (BTA_AV_INCLUDED == TRUE)
#include "sbc_encoder.h"
-#include "aptXCaps.h"
-#include "aptXScheduler.h"
#endif
#if (BTA_AV_SINK_INCLUDED == TRUE)
@@ -338,7 +339,7 @@ typedef struct
tBTIF_AV_MEDIA_FEEDINGS_STATE media_feeding_state;
SBC_ENC_PARAMS encoder;
UINT16 offset;
- APTX_ENC_PARAMS aptxEncoderParams;
+ A2D_APTX_ENC_PARAMS aptxEncoderParams;
UINT16 as16PcmBuffer[1024];
UINT8 busy_level;
void* av_sm_hdl;
@@ -405,7 +406,7 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg);
BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT8 type);
UINT8 bta_av_get_current_codec();
-static thread_t *aptx_thread;
+static thread_t *aptx_thread = NULL;
#if (BTA_AV_INCLUDED == TRUE)
static void btif_media_send_aa_frame(uint64_t timestamp_us);
@@ -438,6 +439,24 @@ static thread_t *worker_thread;
BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT8 type);
UINT8 bta_av_get_current_codec();
+const char *A2D_APTX_SCHED_LIB_NAME = "libaptXScheduler.so";
+BOOLEAN btif_check_and_init_aptX();
+int (*A2D_aptx_sched_init)(void);
+A2D_AptXThreadFn (*A2D_aptx_sched_start)(void *encoder,
+ A2D_AptXCodecType aptX_codec_type, BOOLEAN use_SCMS_T,
+ UINT16 sample_rate, UINT8 format_bits, UINT8 channel,
+ A2D_AptXReadFn read_fn, A2D_AptXBufferSendFn send_fn,
+ A2D_AptXSetPriorityFn set_priority_fn, BOOLEAN test,
+ BOOLEAN trace);
+BOOLEAN (*A2D_aptx_sched_stop)(void);
+void (*A2D_aptx_sched_deinit)(void);
+UINT8 (*bta_av_aptx_cfg_in_cap)(UINT8 *p_cfg, tA2D_APTX_CIE *p_cap);
+UINT8 (*A2D_ParsAptxInfo)(tA2D_APTX_CIE *p_ie, UINT8 *p_info,
+ BOOLEAN for_caps);
+void *A2dAptXSchedLibHandle = NULL;
+BOOLEAN isA2dAptXEnabled = false;
+
+
/*****************************************************************************
** Misc helper functions
*****************************************************************************/
@@ -821,31 +840,31 @@ static BOOLEAN btif_media_task_is_aptx_configured()
BOOLEAN result = FALSE;
UINT8 codectype = bta_av_get_current_codec();
- if (codectype == NON_A2DP_MEDIA_CT)
+ if (codectype == A2D_NON_A2DP_MEDIA_CT)
{
UINT8* ptr = bta_av_get_current_codecInfo();
if (ptr)
{
tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3];
- if (codecInfo && codecInfo->vendorId == QTI_APTX_VENDOR_ID && codecInfo->codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
result = TRUE;
}
}
return result;
}
-AptX_codec_type btif_media_task_get_aptX_codec_type()
+A2D_AptXCodecType btif_media_task_get_aptX_codec_type()
{
- AptX_codec_type codec = APTX_CODEC_NONE;
+ A2D_AptXCodecType codec = APTX_CODEC_NONE;
UINT8 a2dp_codectype = bta_av_get_current_codec();
- if (a2dp_codectype == NON_A2DP_MEDIA_CT)
+ if (a2dp_codectype == A2D_NON_A2DP_MEDIA_CT)
{
UINT8* ptr = bta_av_get_current_codecInfo();
if (ptr)
{
tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3];
- if (codecInfo && codecInfo->vendorId == QTI_APTX_VENDOR_ID && codecInfo->codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
codec = APTX_CODEC;
}
}
@@ -898,7 +917,7 @@ static void btif_a2dp_encoder_init(void)
UINT8 codectype;
codectype = bta_av_get_current_codec();
- if (NON_A2DP_MEDIA_CT == codectype)
+ if (A2D_NON_A2DP_MEDIA_CT == codectype)
{
UINT8* ptr = bta_av_get_current_codecInfo();
if (ptr)
@@ -908,16 +927,16 @@ static void btif_a2dp_encoder_init(void)
APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecInfo->codecId);
APPL_TRACE_DEBUG("%s vendorId = %x", __func__, codecInfo->vendorId);
- if (codecInfo && codecInfo->vendorId == QTI_APTX_VENDOR_ID
- && codecInfo->codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID
+ && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
{
btif_media_cb.offset = BTIF_MEDIA_AA_APTX_OFFSET;
tA2D_APTX_CIE aptx_config;
ALOGI("%s Selected Codec aptX", __func__);
aptx_config.vendorId = codecInfo->vendorId;
aptx_config.codecId = codecInfo->codecId;
- bta_av_co_audio_get_codec_config((UINT8*)&aptx_config, &minmtu, NON_A2DP_MEDIA_CT);
- msg.CodecType = NON_A2DP_MEDIA_CT;
+ bta_av_co_audio_get_codec_config((UINT8*)&aptx_config, &minmtu, A2D_NON_A2DP_MEDIA_CT);
+ msg.CodecType = A2D_NON_A2DP_MEDIA_CT;
msg.SamplingFreq = aptx_config.sampleRate;
msg.ChannelMode = aptx_config.channelMode;
msg.BluetoothVendorID = aptx_config.vendorId;
@@ -926,7 +945,7 @@ static void btif_a2dp_encoder_init(void)
return;
}
}
- }/* if ( NON_A2DP_MEDIA_CT == codectype) */
+ }/* if ( A2D_NON_A2DP_MEDIA_CT == codectype) */
ALOGI("%s Selected Codec SBC", __func__);
@@ -959,20 +978,20 @@ static void btif_a2dp_encoder_update(void)
UINT8 codectype = 0;
codectype = bta_av_get_current_codec();
- if (codectype == NON_A2DP_MEDIA_CT)
+ if (codectype == A2D_NON_A2DP_MEDIA_CT)
{
UINT8* ptr = bta_av_get_current_codecInfo();
if (ptr)
{
codecInfo = (tA2D_APTX_CIE*) &ptr[3];
- if (codecInfo && codecInfo->vendorId == QTI_APTX_VENDOR_ID && codecInfo->codecId == QTI_APTX_CODEC_ID_BLUETOOTH)
+ if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH)
{
APPL_TRACE_DEBUG("%s aptX", __func__);
tA2D_APTX_CIE aptx_config;
aptx_config.vendorId = codecInfo->vendorId;
aptx_config.codecId = codecInfo->codecId;
- bta_av_co_audio_get_codec_config((UINT8*)&aptx_config, &minmtu, NON_A2DP_MEDIA_CT );
- msg.CodecType = NON_A2DP_MEDIA_CT;
+ bta_av_co_audio_get_codec_config((UINT8*)&aptx_config, &minmtu, A2D_NON_A2DP_MEDIA_CT );
+ msg.CodecType = A2D_NON_A2DP_MEDIA_CT;
msg.BluetoothVendorID = aptx_config.vendorId;
msg.BluetoothCodecID = aptx_config.codecId;
}
@@ -1038,6 +1057,116 @@ bool btif_a2dp_is_media_task_stopped(void)
return true;
}
+// returns true if aptX codec initialization succeeds, false otherwise
+BOOLEAN btif_check_and_init_aptX(void)
+{
+ APPL_TRACE_DEBUG("btif_check_and_init_aptX");
+
+ if (A2dAptXSchedLibHandle == NULL)
+ {
+ A2dAptXSchedLibHandle = dlopen(A2D_APTX_SCHED_LIB_NAME, RTLD_NOW);
+
+ if (!A2dAptXSchedLibHandle)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler library missing");
+ goto error_exit;
+ }
+
+ A2D_aptx_sched_init = (int (*)(void))dlsym(A2dAptXSchedLibHandle,
+ "aptx_scheduler_init");
+ if (!A2D_aptx_sched_init)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler init missing");
+ goto error_exit;
+ }
+
+ A2D_aptx_sched_start = (A2D_AptXThreadFn (*)(void*, A2D_AptXCodecType, BOOLEAN,
+ UINT16, UINT8, UINT8, A2D_AptXReadFn,
+ A2D_AptXBufferSendFn,
+ A2D_AptXSetPriorityFn, BOOLEAN,
+ BOOLEAN))dlsym(A2dAptXSchedLibHandle,
+ "aptx_scheduler_start");
+ if (!A2D_aptx_sched_start)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler start missing");
+ goto error_exit;
+ }
+
+ A2D_aptx_sched_stop = (BOOLEAN (*)(void))dlsym(A2dAptXSchedLibHandle,
+ "aptx_scheduler_stop");
+ if (!A2D_aptx_sched_stop)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler stop missing");
+ goto error_exit;
+ }
+
+ A2D_aptx_sched_deinit = (void (*)(void))dlsym(A2dAptXSchedLibHandle,
+ "aptx_scheduler_deinit");
+ if (!A2D_aptx_sched_deinit)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler deinit missing");
+ goto error_exit;
+ }
+
+ A2D_ParsAptxInfo = (UINT8 (*)(tA2D_APTX_CIE *,
+ UINT8 *,
+ BOOLEAN))dlsym(A2dAptXSchedLibHandle,
+ "A2D_ParsAptxInfo");
+ if (!A2D_ParsAptxInfo)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: parse aptx info missing");
+ goto error_exit;
+ }
+
+ bta_av_aptx_cfg_in_cap = (UINT8 (*)(UINT8 *,
+ tA2D_APTX_CIE *))dlsym(A2dAptXSchedLibHandle,
+ "bta_av_aptx_cfg_in_cap");
+ if (!bta_av_aptx_cfg_in_cap)
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX cfg in cap missing");
+ goto error_exit;
+ }
+
+ if (A2D_aptx_sched_init())
+ {
+ APPL_TRACE_ERROR("btif_check_and_init_aptX: aptX scheduler init failed");
+ goto error_exit;
+ }
+ }
+
+ return true;
+
+ error_exit:;
+ if (A2dAptXSchedLibHandle)
+ {
+ dlclose(A2dAptXSchedLibHandle);
+ A2dAptXSchedLibHandle = NULL;
+ }
+ return false;
+
+}
+
+void btif_aptX_deinit(void)
+{
+ APPL_TRACE_DEBUG("btif_aptX_deinit");
+
+ if (isA2dAptXEnabled && A2dAptXSchedLibHandle)
+ {
+ if (aptx_thread)
+ {
+ A2D_aptx_sched_stop();
+ thread_free(aptx_thread);
+ aptx_thread = NULL;
+ }
+ A2D_aptx_sched_deinit();
+ dlclose(A2dAptXSchedLibHandle);
+ A2dAptXSchedLibHandle = NULL;
+ isA2dAptXEnabled = false;
+ }
+
+ return;
+}
+
bool btif_a2dp_start_media_task(void)
{
if (media_task_running != MEDIA_TASK_STATE_OFF)
@@ -1062,6 +1191,9 @@ bool btif_a2dp_start_media_task(void)
btif_media_thread_handle_cmd,
NULL);
+ // Check if aptX codec is supported
+ isA2dAptXEnabled = btif_check_and_init_aptX();
+
thread_post(worker_thread, btif_media_thread_init, NULL);
APPL_TRACE_IMP("## A2DP MEDIA THREAD STARTED ##");
@@ -1093,6 +1225,9 @@ void btif_a2dp_stop_media_task(void)
thread_post(worker_thread, btif_media_thread_cleanup, NULL);
thread_free(worker_thread);
+ // uninitialize aptX
+ btif_aptX_deinit();
+
worker_thread = NULL;
btif_media_cmd_msg_queue = NULL;
APPL_TRACE_DEBUG("## A2DP MEDIA THREAD STOPPED ##");
@@ -2042,12 +2177,12 @@ static void btif_media_task_enc_init(BT_HDR *p_msg)
btif_media_cb.timestamp = 0;
- if (pInitAudio->CodecType == NON_A2DP_MEDIA_CT)
+ if (pInitAudio->CodecType == A2D_NON_A2DP_MEDIA_CT)
{
APPL_TRACE_EVENT("%s BluetoothVendorID %x, BluetoothCodecID %d", __func__,
pInitAudio->BluetoothVendorID, pInitAudio->BluetoothCodecID);
- if ((pInitAudio->BluetoothVendorID == QTI_APTX_VENDOR_ID)
- && (pInitAudio->BluetoothCodecID == QTI_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */
+ if ((pInitAudio->BluetoothVendorID == A2D_APTX_VENDOR_ID)
+ && (pInitAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */
{
btif_media_cb.aptxEncoderParams.s16SamplingFreq= pInitAudio->SamplingFreq;
btif_media_cb.aptxEncoderParams.s16ChannelMode = pInitAudio->ChannelMode;
@@ -2118,13 +2253,13 @@ static void btif_media_task_enc_update(BT_HDR *p_msg)
pUpdateAudio->MinBitPool);
/* Only update the bitrate and MTU size while timer is running to make sure it has been initialized */
- if (pUpdateAudio->CodecType == NON_A2DP_MEDIA_CT)
+ if (pUpdateAudio->CodecType == A2D_NON_A2DP_MEDIA_CT)
{
APPL_TRACE_EVENT("%s BluetoothVendorID %x, BluetoothCodecID %d", __func__,
pUpdateAudio->BluetoothVendorID, pUpdateAudio->BluetoothCodecID);
- if ((pUpdateAudio->BluetoothVendorID == QTI_APTX_VENDOR_ID)
- && (pUpdateAudio->BluetoothCodecID == QTI_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */
+ if ((pUpdateAudio->BluetoothVendorID == A2D_APTX_VENDOR_ID)
+ && (pUpdateAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */
{
APPL_TRACE_DEBUG("%s aptX ", __func__);
btif_media_cb.TxAaMtuSize = ((BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_OFFSET - sizeof(BT_HDR)) < pUpdateAudio->MinMtuSize) ?
@@ -2382,11 +2517,11 @@ static void btif_media_task_pcm2aptx_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_fee
case 32000:
case 48000:
/* For these sampling_freq the AV connection must be 48000 */
- if (btif_media_cb.aptxEncoderParams.s16SamplingFreq != QTI_APTX_SAMPLERATE_48000)
+ if (btif_media_cb.aptxEncoderParams.s16SamplingFreq != A2D_APTX_SAMPLERATE_48000)
{
/* Reconfiguration needed at 48000 */
APPL_TRACE_DEBUG("%s Reconfiguration needed at 48000", __func__);
- btif_media_cb.aptxEncoderParams.s16SamplingFreq = QTI_APTX_SAMPLERATE_48000;
+ btif_media_cb.aptxEncoderParams.s16SamplingFreq = A2D_APTX_SAMPLERATE_48000;
reconfig_needed = TRUE;
}
break;
@@ -2395,11 +2530,11 @@ static void btif_media_task_pcm2aptx_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_fee
case 22050:
case 44100:
/* For these sampling_freq the AV connection must be 44100 */
- if (btif_media_cb.aptxEncoderParams.s16SamplingFreq != QTI_APTX_SAMPLERATE_44100)
+ if (btif_media_cb.aptxEncoderParams.s16SamplingFreq != A2D_APTX_SAMPLERATE_44100)
{
/* Reconfiguration needed at 44100 */
APPL_TRACE_DEBUG("%s Reconfiguration needed at 44100", __func__);
- btif_media_cb.aptxEncoderParams.s16SamplingFreq = QTI_APTX_SAMPLERATE_44100;
+ btif_media_cb.aptxEncoderParams.s16SamplingFreq = A2D_APTX_SAMPLERATE_44100;
reconfig_needed = TRUE;
}
break;
@@ -2409,10 +2544,10 @@ static void btif_media_task_pcm2aptx_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_fee
}
/* Some AV Headsets do not support Mono => always ask for Stereo */
- if (btif_media_cb.aptxEncoderParams.s16ChannelMode == QTI_APTX_CHANNELS_MONO)
+ if (btif_media_cb.aptxEncoderParams.s16ChannelMode == A2D_APTX_CHANNELS_MONO)
{
APPL_TRACE_DEBUG("%s Reconfiguration needed in Stereo", __func__);
- btif_media_cb.aptxEncoderParams.s16ChannelMode = QTI_APTX_CHANNELS_STEREO;
+ btif_media_cb.aptxEncoderParams.s16ChannelMode = A2D_APTX_CHANNELS_STEREO;
reconfig_needed = TRUE;
}
@@ -2454,7 +2589,7 @@ static void btif_media_task_audio_feeding_init(BT_HDR *p_msg)
UINT8 codectype;
codectype = bta_av_get_current_codec();
- if ( NON_A2DP_MEDIA_CT == codectype)
+ if (A2D_NON_A2DP_MEDIA_CT == codectype)
{
UINT8* ptr = bta_av_get_current_codecInfo();
if (ptr)
@@ -2467,7 +2602,7 @@ static void btif_media_task_audio_feeding_init(BT_HDR *p_msg)
APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, codecInfo->vendorId);
}
- if (codecInfo && codecInfo->vendorId == QTI_APTX_VENDOR_ID && codecInfo->codecId == QTI_APTX_CODEC_ID_BLUETOOTH) /* aptX Classic */
+ if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) /* aptX Classic */
{
APPL_TRACE_DEBUG("%s aptX", __func__);
btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_APTX;
@@ -2854,18 +2989,18 @@ static void btif_media_task_aa_start_tx(void)
/* Reset the media feeding state */
btif_media_task_feeding_state_reset();
- if (btif_media_task_is_aptx_configured()) {
+ if (isA2dAptXEnabled && btif_media_task_is_aptx_configured()) {
#if (BTA_AV_CO_CP_SCMS_T == TRUE)
BOOLEAN use_SCMS_T = true;
#else
BOOLEAN use_SCMS_T = false;
#endif
- AptX_codec_type aptX_codec_type = btif_media_task_get_aptX_codec_type();
+ A2D_AptXCodecType aptX_codec_type = btif_media_task_get_aptX_codec_type();
BOOLEAN test = false;
BOOLEAN trace = false;
- thread_fn aptx_thread_fn = aptx_scheduler_start(btif_media_cb.aptxEncoderParams.encoder,
+ A2D_AptXThreadFn aptx_thread_fn = A2D_aptx_sched_start(btif_media_cb.aptxEncoderParams.encoder,
aptX_codec_type,
use_SCMS_T,
btif_media_cb.media_feeding.cfg.pcm.sampling_freq,
@@ -2913,7 +3048,7 @@ static void btif_media_task_aa_stop_tx(void)
const bool send_ack = alarm_is_scheduled(btif_media_cb.media_alarm);
- if (aptx_scheduler_stop())
+ if (isA2dAptXEnabled && A2D_aptx_sched_stop())
{
thread_free(aptx_thread);
aptx_thread = NULL;
diff --git a/main/Android.mk b/main/Android.mk
index 28118d5e6..25a0358ab 100644
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -53,8 +53,7 @@ LOCAL_C_INCLUDES+= . \
$(LOCAL_PATH)/../utils/include \
$(bluetooth_C_INCLUDES) \
external/tinyxml2 \
- external/zlib \
- $(call include-path-for, audio-utils)
+ external/zlib
LOCAL_SHARED_LIBRARIES := \
libcutils \
@@ -67,17 +66,6 @@ LOCAL_SHARED_LIBRARIES := \
libutils \
libchrome
-LOCAL_MULTILIB := 32
-LOCAL_SHARED_LIBRARIES += libaudioutils
-LOCAL_SHARED_LIBRARIES += libaptXScheduler
-
-ifeq ($(SCMS_T), true)
- $(info "SCMS-T content protection enabled")
-else
- $(info "SCMS-T content protection not enabled")
-endif
-
-
LOCAL_STATIC_LIBRARIES := \
libtinyxml2 \
libbt-qcom_sbc_decoder
diff --git a/stack/Android.mk b/stack/Android.mk
index f19c51b32..4eb9ce822 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -38,6 +38,7 @@ LOCAL_C_INCLUDES:= \
LOCAL_SRC_FILES:= \
./a2dp/a2d_api.c \
./a2dp/a2d_sbc.c \
+ ./a2dp/a2d_aptx.c \
./avrc/avrc_api.c \
./avrc/avrc_sdp.c \
./avrc/avrc_opt.c \
@@ -153,8 +154,6 @@ LOCAL_MODULE := libbt-stack
LOCAL_STATIC_LIBRARIES := libbt-hci
LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_MULTILIB := 32
-LOCAL_SHARED_LIBRARIES += libaptXScheduler
LOCAL_CFLAGS += $(bluetooth_CFLAGS)
LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
diff --git a/stack/a2dp/a2d_aptx.c b/stack/a2dp/a2d_aptx.c
new file mode 100644
index 000000000..af26dd32c
--- /dev/null
+++ b/stack/a2dp/a2d_aptx.c
@@ -0,0 +1,71 @@
+/******************************************************************************
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Utility functions to help build and parse the aptX Codec Information
+ * Element and Media Payload.
+ *
+ ******************************************************************************/
+
+#include "bt_target.h"
+
+#include <string.h>
+#include "bt_utils.h"
+#include "a2d_api.h"
+#include "a2d_int.h"
+#include "a2d_aptx.h"
+#include <utils/Log.h>
+
+/******************************************************************************
+**
+** Function A2D_BldAptxInfo
+**
+******************************************************************************/
+
+UINT8 A2D_BldAptxInfo(UINT8 media_type, tA2D_APTX_CIE *p_ie, UINT8 *p_result)
+{
+ A2D_TRACE_API("A2D_BldAptxInfo - MediaType:%d", media_type);
+
+ UINT8 status = 0;
+ status = A2D_SUCCESS;
+ *p_result++ = A2D_APTX_CODEC_LEN;
+ *p_result++ = media_type;
+ *p_result++ = A2D_NON_A2DP_MEDIA_CT;
+ *p_result++ = (UINT8)(p_ie->vendorId & 0x000000FF);
+ *p_result++ = (UINT8)(p_ie->vendorId & 0x0000FF00)>> 8;
+ *p_result++ = (UINT8)(p_ie->vendorId & 0x00FF0000)>> 16;
+ *p_result++ = (UINT8)(p_ie->vendorId & 0xFF000000)>> 24;
+ *p_result++ = (UINT8)(p_ie->codecId & 0x00FF);
+ *p_result++ = (UINT8)(p_ie->codecId & 0xFF00) >> 8;
+ *p_result++ = p_ie->sampleRate | p_ie->channelMode;
+
+ return status;
+}
diff --git a/stack/include/a2d_api.h b/stack/include/a2d_api.h
index 65da98596..164e64980 100644
--- a/stack/include/a2d_api.h
+++ b/stack/include/a2d_api.h
@@ -85,6 +85,9 @@
#define A2D_BAD_CP_TYPE 0xE0 /* The requested CP Type is not supported. */
#define A2D_BAD_CP_FORMAT 0xE1 /* The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not correct. */
+
+#define A2D_NON_A2DP_MEDIA_CT 0xff /* NON A2DP media codec */
+
typedef UINT8 tA2D_STATUS;
/* the return values from A2D_BitsSet() */
diff --git a/stack/include/a2d_aptx.h b/stack/include/a2d_aptx.h
new file mode 100644
index 000000000..5d61c9c54
--- /dev/null
+++ b/stack/include/a2d_aptx.h
@@ -0,0 +1,127 @@
+/******************************************************************************
+
+ Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * interface to aptX codec
+ *
+ ******************************************************************************/
+#ifndef A2D_APTX_H
+#define A2D_APTX_H
+
+/* aptX codec specific settings*/
+#define A2D_APTX_CODEC_LEN 9
+
+#define A2D_APTX_VENDOR_ID (0x0000004F)
+#define A2D_APTX_CODEC_ID_BLUETOOTH (0x0001)
+#define A2D_APTX_SAMPLERATE_44100 (0x20)
+#define A2D_APTX_SAMPLERATE_48000 (0x10)
+#define A2D_APTX_CHANNELS_STEREO (0x02)
+#define A2D_APTX_CHANNELS_MONO (0x01)
+#define A2D_APTX_FUTURE_1 (0x00)
+#define A2D_APTX_FUTURE_2 (0x00)
+#define A2D_APTX_OTHER_FEATURES_NONE (0x00000000)
+#define A2D_AV_APTX_AUDIO (0x00)
+#define A2D_APTX_CHANNEL (0x0001)
+#define A2D_APTX_SAMPLERATE (0x22)
+
+
+/*****************************************************************************
+** Type Definitions
+*****************************************************************************/
+typedef enum {
+ APTX_CODEC_NONE=0,
+ APTX_CODEC,
+ APTX_CODEC_LL,
+ APTX_CODEC_HD,
+} A2D_AptXCodecType;
+
+typedef void (*A2D_AptXThreadFn)(void *context);
+typedef UINT32 (*A2D_AptXReadFn) (UINT8 ch_id, UINT16 *p_msg_evt, UINT8* p_buf,
+ UINT32 len);
+typedef int (*A2D_AptXBufferSendFn) (UINT8*, int, int);
+typedef void (*A2D_AptXSetPriorityFn)(tHIGH_PRIORITY_TASK task);
+
+typedef struct
+{
+ UINT32 vendorId;
+ UINT16 codecId; /* Codec ID for aptX */
+ UINT8 sampleRate; /* Sampling Frequency */
+ UINT8 channelMode; /* STEREO/DUAL/MONO */
+ UINT8 future1;
+ UINT8 future2;
+} tA2D_APTX_CIE;
+
+
+typedef struct {
+ INT16 s16SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
+ INT16 s16ChannelMode; /* mono, dual, streo or joint streo*/
+ UINT16 u16BitRate;
+ UINT16 *ps16NextPcmBuffer;
+ UINT8 *pu8Packet;
+ UINT8 *pu8NextPacket;
+ UINT16 u16PacketLength;
+ void* encoder;
+} A2D_APTX_ENC_PARAMS;
+
+extern const char* A2D_APTX_SCHED_LIB_NAME;
+extern void *A2dAptXSchedLibHandle;
+extern BOOLEAN isA2dAptXEnabled;
+
+/*****************************************************************************
+** external function declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+extern UINT8 A2D_BldAptxInfo(UINT8 media_type, tA2D_APTX_CIE *p_ie,
+ UINT8 *p_result);
+extern UINT8 (*A2D_ParsAptxInfo)(tA2D_APTX_CIE *p_ie, UINT8 *p_info,
+ BOOLEAN for_caps);
+extern int (*A2D_aptx_sched_init)(void);
+extern A2D_AptXThreadFn (*A2D_aptx_sched_start)(void *encoder,
+ A2D_AptXCodecType aptX_codec_type,
+ BOOLEAN use_SCMS_T, UINT16 sample_rate,
+ UINT8 format_bits, UINT8 channel,
+ A2D_AptXReadFn read_fn,
+ A2D_AptXBufferSendFn send_fn,
+ A2D_AptXSetPriorityFn set_priority_fn,
+ BOOLEAN test, BOOLEAN trace);
+extern BOOLEAN (*A2D_aptx_sched_stop)(void);
+extern void (*A2D_aptx_sched_deinit)(void);
+extern UINT8 (*bta_av_aptx_cfg_in_cap)(UINT8 *p_cfg, tA2D_APTX_CIE *p_cap);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* A2D_APTX_H */