system/bt
修訂 | 2c2dcd3b7c10efa5b62c868b44080ddad2d30dd7 (tree) |
---|---|
時間 | 2016-09-22 07:11:05 |
作者 | Umesh Vats <uvats@code...> |
Commiter | Umesh Vats |
aptXHD codec support
Feature support for aptXHD codec negotiation for a2dp streaming
added
Change-Id: Iba694e2547abc8e6161997cd136064fe3a411abc
@@ -172,11 +172,12 @@ static const char* dump_a2dp_ctrl_event(char event) | ||
172 | 172 | static int calc_audiotime(struct a2dp_config cfg, int bytes) |
173 | 173 | { |
174 | 174 | int chan_count = popcount(cfg.channel_flags); |
175 | + int bytes_per_sample = 4; | |
175 | 176 | |
176 | - ASSERTC(cfg.format == AUDIO_FORMAT_PCM_16_BIT, | |
177 | + ASSERTC(cfg.format == AUDIO_FORMAT_PCM_8_24_BIT, | |
177 | 178 | "unsupported sample sz", cfg.format); |
178 | 179 | |
179 | - return bytes*(1000000/(chan_count*2))/cfg.rate; | |
180 | + return (int)(((int64_t)bytes * (1000000 / (chan_count * bytes_per_sample))) / cfg.rate); | |
180 | 181 | } |
181 | 182 | |
182 | 183 | static void ts_error_log(char *tag, int val, int buff_size, struct a2dp_config cfg) |
@@ -1382,7 +1383,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev, | ||
1382 | 1383 | a2dp_stream_common_init(&out->common); |
1383 | 1384 | #endif |
1384 | 1385 | out->common.cfg.channel_flags = AUDIO_STREAM_DEFAULT_CHANNEL_FLAG; |
1385 | - out->common.cfg.format = AUDIO_STREAM_DEFAULT_FORMAT; | |
1386 | + out->common.cfg.format = AUDIO_FORMAT_PCM_8_24_BIT; | |
1386 | 1387 | out->common.cfg.rate = AUDIO_STREAM_DEFAULT_RATE; |
1387 | 1388 | |
1388 | 1389 | /* set output config values */ |
@@ -49,7 +49,9 @@ | ||
49 | 49 | #include "osi/include/osi.h" |
50 | 50 | #include "osi/include/socket_utils/sockets.h" |
51 | 51 | |
52 | - | |
52 | +#ifdef LOG_TAG | |
53 | +#undef LOG_TAG | |
54 | +#endif | |
53 | 55 | #define LOG_TAG "bthost_ipc" |
54 | 56 | #include "osi/include/log.h" |
55 | 57 |
@@ -720,7 +722,6 @@ int a2dp_read_codec_config(struct a2dp_stream_common *common,uint8_t idx) | ||
720 | 722 | int a2dp_get_multicast_status(struct a2dp_stream_common *common, uint8_t *mcast_status, |
721 | 723 | uint8_t *num_dev) |
722 | 724 | { |
723 | - char cmd = A2DP_CTRL_GET_MULTICAST_STATUS; | |
724 | 725 | INFO("%s",__func__); |
725 | 726 | if (a2dp_command(common,A2DP_CTRL_GET_MULTICAST_STATUS) < 0) |
726 | 727 | { |
@@ -977,7 +978,7 @@ int audio_start_stream() | ||
977 | 978 | INFO("control path is disconnected"); |
978 | 979 | break; |
979 | 980 | } |
980 | - INFO("%s: a2dp stream not started,wait 100mse & retry"); | |
981 | + INFO("%s: a2dp stream not started,wait 100mse & retry", __func__); | |
981 | 982 | usleep(100000); |
982 | 983 | } |
983 | 984 | if (audio_stream.state != AUDIO_A2DP_STATE_STARTED) |
@@ -1067,9 +1068,6 @@ void clear_a2dpsuspend_flag() | ||
1067 | 1068 | void * audio_get_codec_config(uint8_t *multicast_status, uint8_t *num_dev, |
1068 | 1069 | audio_format_t *codec_type) |
1069 | 1070 | { |
1070 | - char *p_common_cfg = &audio_stream.codec_cfg[0]; | |
1071 | - int i; | |
1072 | - | |
1073 | 1071 | INFO("%s: state = %s",__func__,dump_a2dp_hal_state(audio_stream.state)); |
1074 | 1072 | |
1075 | 1073 | a2dp_get_multicast_status(&audio_stream, multicast_status,num_dev); |
@@ -154,7 +154,7 @@ typedef struct { | ||
154 | 154 | int (*a2dp_read_audio_config)(struct a2dp_stream_common *common); |
155 | 155 | int (*skt_read)(int fd,void *buf, size_t bytes); |
156 | 156 | int (*skt_write)(int fd,const void *buf, size_t bytes); |
157 | - void (*skt_disconnect)(int fd); | |
157 | + int (*skt_disconnect)(int fd); | |
158 | 158 | int (*a2dp_command)(struct a2dp_stream_common *common,char cmd); |
159 | 159 | int (*audio_stream_open)(void); |
160 | 160 | int (*audio_stream_close)(void); |
@@ -96,7 +96,6 @@ LOCAL_C_INCLUDES+= . \ | ||
96 | 96 | $(LOCAL_PATH)/../udrv/include \ |
97 | 97 | $(LOCAL_PATH)/../vnd/include \ |
98 | 98 | $(LOCAL_PATH)/../utils/include \ |
99 | - $(TARGET_OUT_HEADERS)/bt/hci_qcomm_init/aptX \ | |
100 | 99 | $(bluetooth_C_INCLUDES) |
101 | 100 | |
102 | 101 | LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG |
@@ -38,6 +38,8 @@ | ||
38 | 38 | #include "avdt_api.h" |
39 | 39 | #include "bta_av_int.h" |
40 | 40 | #include "bt_utils.h" |
41 | +#include "a2d_aptx.h" | |
42 | +#include "a2d_aptx_hd.h" | |
41 | 43 | #include "l2cdefs.h" |
42 | 44 | #include "l2c_api.h" |
43 | 45 | #include "osi/include/properties.h" |
@@ -266,20 +268,31 @@ tAVDT_CTRL_CBACK * const bta_av_dt_cback[] = | ||
266 | 268 | static UINT8 bta_av_get_scb_handle(tBTA_AV_SCB *p_scb, UINT8 local_sep) |
267 | 269 | { |
268 | 270 | UINT8 xx =0; |
269 | - const int NON_A2DP = 0xFF; | |
270 | 271 | for (xx = 0; xx<BTA_AV_MAX_SEPS; xx++) |
271 | 272 | { |
272 | 273 | if ((p_scb->seps[xx].tsep == local_sep) && |
273 | 274 | (p_scb->seps[xx].codec_type == p_scb->codec_type)) |
274 | 275 | { |
275 | - if (p_scb->seps[xx].codec_type != NON_A2DP) | |
276 | + if (p_scb->seps[xx].codec_type != A2D_NON_A2DP_MEDIA_CT) | |
276 | 277 | return (p_scb->seps[xx].av_handle); |
277 | 278 | else { |
278 | - UINT8 vendorId = p_scb->cfg.codec_info[BTA_AV_VENDOR_ID_TYPE_IDX]; | |
279 | - UINT8 codecId = p_scb->cfg.codec_info[BTA_AV_CODEC_ID_TYPE_IDX]; | |
280 | - | |
281 | - if (codecId == p_scb->seps[xx].codecId && vendorId == p_scb->seps[xx].vendorId) | |
282 | - return (p_scb->seps[xx].av_handle); | |
279 | + UINT8 losc = p_scb->cfg.codec_info[0]; | |
280 | + if (losc == A2D_APTX_CODEC_LEN) | |
281 | + { | |
282 | + tA2D_APTX_CIE aptx_config; | |
283 | + if (A2D_ParsAptxInfo(&aptx_config, p_scb->cfg.codec_info, FALSE) == A2D_SUCCESS) | |
284 | + if ((aptx_config.codecId == p_scb->seps[xx].codecId) && | |
285 | + (aptx_config.vendorId == p_scb->seps[xx].vendorId)) | |
286 | + return (p_scb->seps[xx].av_handle); | |
287 | + } else if (losc == A2D_APTX_HD_CODEC_LEN) | |
288 | + { | |
289 | + tA2D_APTX_HD_CIE aptx_config; | |
290 | + if (A2D_ParsAptx_hdInfo(&aptx_config, p_scb->cfg.codec_info, FALSE) == A2D_SUCCESS) | |
291 | + if ((aptx_config.codecId == p_scb->seps[xx].codecId) && | |
292 | + (aptx_config.vendorId == p_scb->seps[xx].vendorId)) | |
293 | + return (p_scb->seps[xx].av_handle); | |
294 | + } else | |
295 | + APPL_TRACE_DEBUG("%s: Invalid aptX Losc", __func__) | |
283 | 296 | } |
284 | 297 | } |
285 | 298 | } |
@@ -784,7 +797,6 @@ static void bta_av_a2d_sdp_cback(BOOLEAN found, tA2D_Service *p_service) | ||
784 | 797 | static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb, UINT8 avdt_handle) |
785 | 798 | { |
786 | 799 | int xx; |
787 | - const int NON_A2DP = 0xFF; | |
788 | 800 | APPL_TRACE_DEBUG("bta_av_adjust_seps_idx codec_type: %d", p_scb->codec_type); |
789 | 801 | for(xx=0; xx<BTA_AV_MAX_SEPS; xx++) |
790 | 802 | { |
@@ -793,26 +805,46 @@ static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb, UINT8 avdt_handle) | ||
793 | 805 | if((p_scb->seps[xx].av_handle && p_scb->codec_type == p_scb->seps[xx].codec_type) |
794 | 806 | && (p_scb->seps[xx].av_handle == avdt_handle)) |
795 | 807 | { |
796 | - if (p_scb->seps[xx].codec_type != NON_A2DP) | |
808 | + if (p_scb->seps[xx].codec_type != A2D_NON_A2DP_MEDIA_CT) | |
797 | 809 | { |
798 | 810 | p_scb->sep_idx = xx; |
799 | 811 | p_scb->avdt_handle = p_scb->seps[xx].av_handle; |
800 | 812 | break; |
801 | 813 | } |
802 | 814 | else { |
803 | - UINT8 vendorId = p_scb->cfg.codec_info[BTA_AV_VENDOR_ID_TYPE_IDX]; | |
804 | - UINT8 codecId = p_scb->cfg.codec_info[BTA_AV_CODEC_ID_TYPE_IDX]; | |
805 | - APPL_TRACE_DEBUG("%s vendorId: %x codecId: %x", __func__, p_scb->seps[xx].vendorId, p_scb->seps[xx].codecId); | |
806 | - if (codecId == p_scb->seps[xx].codecId && vendorId == p_scb->seps[xx].vendorId) | |
815 | + UINT8 losc = p_scb->cfg.codec_info[0]; | |
816 | + if (losc == A2D_APTX_CODEC_LEN) | |
807 | 817 | { |
808 | - APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
809 | - APPL_TRACE_DEBUG("%s vendorID: %x codecID: %x", __func__, vendorId, codecId); | |
810 | - p_scb->sep_idx = xx; | |
811 | - p_scb->avdt_handle = p_scb->seps[xx].av_handle; | |
812 | - APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
813 | - APPL_TRACE_DEBUG("%s p_scb->avdt_handle: %d", __func__, p_scb->avdt_handle); | |
814 | - break; | |
815 | - } | |
818 | + tA2D_APTX_CIE aptx_config; | |
819 | + if (A2D_ParsAptxInfo(&aptx_config, p_scb->cfg.codec_info, FALSE) == A2D_SUCCESS) { | |
820 | + APPL_TRACE_DEBUG("%s vendorId: %x codecId: %x", __func__, p_scb->seps[xx].vendorId, p_scb->seps[xx].codecId); | |
821 | + if ((aptx_config.codecId == p_scb->seps[xx].codecId) && | |
822 | + (aptx_config.vendorId == p_scb->seps[xx].vendorId)) { | |
823 | + APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
824 | + p_scb->sep_idx = xx; | |
825 | + p_scb->avdt_handle = p_scb->seps[xx].av_handle; | |
826 | + APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
827 | + APPL_TRACE_DEBUG("%s p_scb->avdt_handle: %d", __func__, p_scb->avdt_handle); | |
828 | + break; | |
829 | + } | |
830 | + } | |
831 | + } else if (losc == A2D_APTX_HD_CODEC_LEN) | |
832 | + { | |
833 | + tA2D_APTX_HD_CIE aptx_config; | |
834 | + if (A2D_ParsAptx_hdInfo(&aptx_config, p_scb->cfg.codec_info, FALSE) == A2D_SUCCESS) { | |
835 | + APPL_TRACE_DEBUG("%s vendorId: %x codecId: %x", __func__, p_scb->seps[xx].vendorId, p_scb->seps[xx].codecId); | |
836 | + if ((aptx_config.codecId == p_scb->seps[xx].codecId) && | |
837 | + (aptx_config.vendorId == p_scb->seps[xx].vendorId)) { | |
838 | + APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
839 | + p_scb->sep_idx = xx; | |
840 | + p_scb->avdt_handle = p_scb->seps[xx].av_handle; | |
841 | + APPL_TRACE_DEBUG("%s p_scb->sep_idx: %d", __func__, p_scb->sep_idx); | |
842 | + APPL_TRACE_DEBUG("%s p_scb->avdt_handle: %d", __func__, p_scb->avdt_handle); | |
843 | + break; | |
844 | + } | |
845 | + } | |
846 | + } else | |
847 | + APPL_TRACE_DEBUG("%s: Invalid aptX Losc", __func__) | |
816 | 848 | } |
817 | 849 | } |
818 | 850 | } |
@@ -1572,14 +1604,14 @@ void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) | ||
1572 | 1604 | } |
1573 | 1605 | /******************************************************************************* |
1574 | 1606 | ** |
1575 | -** Function bta_av_co_audio_get_codec_type | |
1607 | +** Function bta_av_get_codec_type | |
1576 | 1608 | ** |
1577 | -** Description Gets the p_scb->codec_type | |
1609 | +** Description Returns the codec_type from the most recently used scb | |
1578 | 1610 | ** |
1579 | 1611 | ** Returns bta_av_cb.codec_type |
1580 | 1612 | ** |
1581 | 1613 | *******************************************************************************/ |
1582 | -UINT8 bta_av_co_audio_get_codec_type() | |
1614 | +UINT8 bta_av_get_codec_type() | |
1583 | 1615 | { |
1584 | 1616 | APPL_TRACE_DEBUG("%s [bta_av_cb.codec_type] %x", __func__, bta_av_cb.codec_type); |
1585 | 1617 | return bta_av_cb.codec_type; |
@@ -422,8 +422,8 @@ typedef struct | ||
422 | 422 | tBTA_AV_CODEC codec_type; /* codec type */ |
423 | 423 | UINT8 tsep; /* SEP type of local SEP */ |
424 | 424 | tBTA_AV_DATA_CBACK *p_app_data_cback; /* Application callback for media packets */ |
425 | - UINT8 vendorId; /* vendorId type */ | |
426 | - UINT8 codecId; /* codecId type */ | |
425 | + UINT32 vendorId; /* vendorId type */ | |
426 | + UINT16 codecId; /* codecId type */ | |
427 | 427 | } tBTA_AV_SEP; |
428 | 428 | |
429 | 429 |
@@ -34,6 +34,7 @@ | ||
34 | 34 | |
35 | 35 | #include "bt_target.h" |
36 | 36 | #include "osi/include/log.h" |
37 | +#include <cutils/properties.h> | |
37 | 38 | |
38 | 39 | #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) |
39 | 40 | #include "bta_av_co.h" |
@@ -48,6 +49,7 @@ | ||
48 | 49 | #endif |
49 | 50 | |
50 | 51 | #include "a2d_aptx.h" |
52 | +#include "a2d_aptx_hd.h" | |
51 | 53 | |
52 | 54 | /***************************************************************************** |
53 | 55 | ** Constants and types |
@@ -693,16 +695,15 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) | ||
693 | 695 | (*bta_av_a2d_cos.init)(&codec_type, cs.cfg.codec_info, |
694 | 696 | &cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) |
695 | 697 | { |
698 | + UINT8* ptr = cs.cfg.codec_info; | |
699 | + tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
700 | + UINT32 vendorId = codecInfo->vendorId; | |
701 | + UINT16 codecId = codecInfo->codecId; | |
702 | + | |
696 | 703 | if ((*bta_av_a2d_cos.offload)() == TRUE) |
697 | 704 | { |
698 | 705 | if(codec_type == A2D_NON_A2DP_MEDIA_CT) |
699 | 706 | { |
700 | - | |
701 | - UINT8* ptr = cs.cfg.codec_info; | |
702 | - tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
703 | - UINT8 vendorId = codecInfo->vendorId; | |
704 | - UINT8 codecId = codecInfo->codecId; | |
705 | - | |
706 | 707 | if (vendorId == A2D_APTX_VENDOR_ID && |
707 | 708 | codecId == A2D_APTX_CODEC_ID_BLUETOOTH) |
708 | 709 | { |
@@ -723,24 +724,36 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) | ||
723 | 724 | continue; |
724 | 725 | } |
725 | 726 | } |
726 | - } | |
727 | - else if((codec_type == A2D_NON_A2DP_MEDIA_CT) && (A2D_check_and_init_aptX() == false)) | |
728 | - { | |
729 | - index++; | |
730 | - continue; | |
727 | + } else if (codec_type == A2D_NON_A2DP_MEDIA_CT) { | |
728 | + if ((codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
729 | + && (A2D_check_and_init_aptX() == false)) { | |
730 | + APPL_TRACE_WARNING("%s aptX not available ", __func__); | |
731 | + index++; | |
732 | + continue; | |
733 | + | |
734 | + } else { | |
735 | + char value[PROPERTY_VALUE_MAX]; | |
736 | + bool enableAptXHD = false; | |
737 | + if (property_get("persist.bt.enableAptXHD", value, "false") && strcmp(value, "true") == 0) | |
738 | + enableAptXHD = true; | |
739 | + else | |
740 | + APPL_TRACE_WARNING("%s enableAptXHD property is not set", __func__); | |
741 | + | |
742 | + if ((codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_HD_VENDOR_ID) && | |
743 | + ((enableAptXHD == false) || (A2D_check_and_init_aptX_HD() == false))) { | |
744 | + APPL_TRACE_WARNING("%s aptX-HD not available", __func__); | |
745 | + index++; | |
746 | + continue; | |
747 | + } | |
748 | + } | |
731 | 749 | } |
732 | 750 | |
733 | 751 | if(AVDT_CreateStream(&p_scb->seps[index - startIndex].av_handle, &cs) == |
734 | 752 | AVDT_SUCCESS) |
735 | 753 | { |
736 | 754 | if ((profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) && |
737 | - (index == BTIF_SV_AV_AA_APTX_INDEX)) | |
755 | + ((index == BTIF_SV_AV_AA_APTX_INDEX) || (index == BTIF_SV_AV_AA_APTX_HD_INDEX))) | |
738 | 756 | { |
739 | - UINT8* ptr = cs.cfg.codec_info; | |
740 | - tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
741 | - UINT8 vendorId = codecInfo->vendorId; | |
742 | - UINT8 codecId = codecInfo->codecId; | |
743 | - | |
744 | 757 | p_scb->seps[index - startIndex].vendorId = vendorId; |
745 | 758 | p_scb->seps[index - startIndex].codecId = codecId; |
746 | 759 | APPL_TRACE_DEBUG("%s audio[%x] vendorId: %x codecId: %x", __func__, |
@@ -854,8 +867,7 @@ void bta_av_api_deregister(tBTA_AV_DATA *p_data) | ||
854 | 867 | { |
855 | 868 | tBTA_AV_SCB *p_scb = bta_av_hndl_to_scb(p_data->hdr.layer_specific); |
856 | 869 | |
857 | - // de-initialize aptX | |
858 | - A2D_deinit_aptX(); | |
870 | + A2D_close_aptX(); | |
859 | 871 | |
860 | 872 | if(p_scb) |
861 | 873 | { |
@@ -97,12 +97,6 @@ typedef UINT8 tBTA_AV_HNDL; | ||
97 | 97 | /* offset of codec type in codec info byte array */ |
98 | 98 | #define BTA_AV_CODEC_TYPE_IDX AVDT_CODEC_TYPE_INDEX /* 2 */ |
99 | 99 | |
100 | -/* offset of vendorId type in vendorId info byte array */ | |
101 | -#define BTA_AV_VENDOR_ID_TYPE_IDX AVDT_VENDOR_ID_TYPE_INDEX /* 3 */ | |
102 | - | |
103 | -/* offset of codecId type in codecId info byte array */ | |
104 | -#define BTA_AV_CODEC_ID_TYPE_IDX AVDT_CODEC_ID_TYPE_INDEX /* 7 */ | |
105 | - | |
106 | 100 | /* maximum number of streams created: 1 for audio, 1 for video */ |
107 | 101 | #ifndef BTA_AV_NUM_STRS |
108 | 102 | #define BTA_AV_NUM_STRS 2 |
@@ -110,9 +104,9 @@ typedef UINT8 tBTA_AV_HNDL; | ||
110 | 104 | |
111 | 105 | #ifndef BTA_AV_MAX_SEPS |
112 | 106 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
113 | -#define BTA_AV_MAX_SEPS 3 | |
107 | +#define BTA_AV_MAX_SEPS 4 | |
114 | 108 | #else |
115 | -#define BTA_AV_MAX_SEPS 2 | |
109 | +#define BTA_AV_MAX_SEPS 3 | |
116 | 110 | #endif |
117 | 111 | #endif |
118 | 112 |
@@ -142,6 +136,9 @@ typedef UINT8 tBTA_AV_CODEC; | ||
142 | 136 | /* Company ID in BT assigned numbers */ |
143 | 137 | #define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */ |
144 | 138 | |
139 | +/* Offset for codec configuration in codec info */ | |
140 | +#define BTA_AV_CFG_START_IDX 3 | |
141 | + | |
145 | 142 | /* vendor specific codec ID */ |
146 | 143 | #define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */ |
147 | 144 | #define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */ |
@@ -896,6 +893,16 @@ void BTA_AvOffloadStart(tBTA_AV_HNDL hndl); | ||
896 | 893 | *******************************************************************************/ |
897 | 894 | void BTA_AvOffloadStartRsp(tBTA_AV_HNDL hndl, tBTA_AV_STATUS status); |
898 | 895 | |
896 | +/******************************************************************************* | |
897 | +** | |
898 | +** Function bta_av_get_codec_type | |
899 | +** | |
900 | +** Description Returns the codec_type from the most recently used scb | |
901 | +** | |
902 | +** Returns A2D_NON_A2DP_MEDIA_CT or BTIF_AV_CODEC_SBC | |
903 | +** | |
904 | +*******************************************************************************/ | |
905 | +UINT8 bta_av_get_codec_type(); | |
899 | 906 | |
900 | 907 | #ifdef __cplusplus |
901 | 908 | } |
@@ -63,6 +63,7 @@ enum | ||
63 | 63 | { |
64 | 64 | BTIF_SV_AV_AA_SBC_INDEX = 0, |
65 | 65 | BTIF_SV_AV_AA_APTX_INDEX, |
66 | + BTIF_SV_AV_AA_APTX_HD_INDEX, | |
66 | 67 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
67 | 68 | BTIF_SV_AV_AA_AAC_INDEX, |
68 | 69 | #endif |
@@ -114,9 +114,9 @@ btifCommonIncludes := \ | ||
114 | 114 | $(LOCAL_PATH)/../audio_a2dp_hw \ |
115 | 115 | $(LOCAL_PATH)/../utils/include \ |
116 | 116 | $(bluetooth_C_INCLUDES) \ |
117 | - $(TARGET_OUT_HEADERS)/bt/hci_qcomm_init/aptX \ | |
118 | 117 | external/tinyxml2 \ |
119 | - external/zlib | |
118 | + external/zlib \ | |
119 | + $(call include-path-for, audio-utils) | |
120 | 120 | |
121 | 121 | ifneq ($(TARGET_SUPPORTS_WEARABLES),true) |
122 | 122 | btifCommonIncludes += \ |
@@ -39,12 +39,14 @@ | ||
39 | 39 | |
40 | 40 | #include "btif_media.h" |
41 | 41 | #include "sbc_encoder.h" |
42 | +#include "btif_av.h" | |
42 | 43 | #include "btif_av_co.h" |
43 | 44 | #include "btif_util.h" |
44 | 45 | #include "osi/include/mutex.h" |
45 | 46 | |
46 | 47 | #include "bt_utils.h" |
47 | 48 | #include "a2d_aptx.h" |
49 | +#include "a2d_aptx_hd.h" | |
48 | 50 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
49 | 51 | #include "a2d_aac.h" |
50 | 52 | #include "bta_av_aac.h" |
@@ -164,6 +166,31 @@ const tA2D_APTX_CIE btif_av_aptx_default_config = | ||
164 | 166 | A2D_APTX_FUTURE_2 |
165 | 167 | }; |
166 | 168 | |
169 | +const tA2D_APTX_HD_CIE bta_av_co_aptx_hd_caps = | |
170 | +{ | |
171 | + A2D_APTX_HD_VENDOR_ID, | |
172 | + A2D_APTX_HD_CODEC_ID_BLUETOOTH, | |
173 | + A2D_APTX_HD_SAMPLERATE_44100, | |
174 | + A2D_APTX_HD_CHANNELS_STEREO, | |
175 | + A2D_APTX_HD_ACL_SPRINT_RESERVED0, | |
176 | + A2D_APTX_HD_ACL_SPRINT_RESERVED1, | |
177 | + A2D_APTX_HD_ACL_SPRINT_RESERVED2, | |
178 | + A2D_APTX_HD_ACL_SPRINT_RESERVED3 | |
179 | +}; | |
180 | + | |
181 | +/* Default aptX_hd codec configuration */ | |
182 | +const tA2D_APTX_HD_CIE btif_av_aptx_hd_default_config = | |
183 | +{ | |
184 | + A2D_APTX_HD_VENDOR_ID, | |
185 | + A2D_APTX_HD_CODEC_ID_BLUETOOTH, | |
186 | + A2D_APTX_HD_SAMPLERATE_44100, | |
187 | + A2D_APTX_HD_CHANNELS_STEREO, | |
188 | + A2D_APTX_HD_ACL_SPRINT_RESERVED0, | |
189 | + A2D_APTX_HD_ACL_SPRINT_RESERVED1, | |
190 | + A2D_APTX_HD_ACL_SPRINT_RESERVED2, | |
191 | + A2D_APTX_HD_ACL_SPRINT_RESERVED3 | |
192 | +}; | |
193 | + | |
167 | 194 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
168 | 195 | const tA2D_AAC_CIE bta_av_co_aac_caps = |
169 | 196 | { |
@@ -193,7 +220,6 @@ const tA2D_AAC_CIE btif_av_aac_default_config = | ||
193 | 220 | }; |
194 | 221 | #endif |
195 | 222 | |
196 | - | |
197 | 223 | /***************************************************************************** |
198 | 224 | ** Local data |
199 | 225 | *****************************************************************************/ |
@@ -250,6 +276,8 @@ typedef struct | ||
250 | 276 | tBTIF_AV_CODEC_INFO codec_cfg_sbc_setconfig; /* remote peer setconfig preference (SBC) */ |
251 | 277 | tBTIF_AV_CODEC_INFO codec_cfg_aptx; |
252 | 278 | tBTIF_AV_CODEC_INFO codec_cfg_aptx_setconfig; /* remote peer setconfig preference (aptX)*/ |
279 | + tBTIF_AV_CODEC_INFO codec_cfg_aptx_hd; | |
280 | + tBTIF_AV_CODEC_INFO codec_cfg_aptx_hd_setconfig; /* remote peer setconfig preference (aptX HD) */ | |
253 | 281 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
254 | 282 | tBTIF_AV_CODEC_INFO codec_cfg_aac; |
255 | 283 | tBTIF_AV_CODEC_INFO codec_cfg_aac_setconfig; /* remote peer setconfig preference (AAC)*/ |
@@ -268,7 +296,6 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT | ||
268 | 296 | static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg); |
269 | 297 | static BOOLEAN bta_av_co_audio_sink_supports_config(UINT8 codec_type, const UINT8 *p_codec_cfg); |
270 | 298 | static BOOLEAN bta_av_co_audio_peer_src_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT8 *p_src_index); |
271 | -extern UINT8 bta_av_co_audio_get_codec_type(); | |
272 | 299 | #ifdef BTA_AV_SPLIT_A2DP_ENABLED |
273 | 300 | extern BOOLEAN btif_av_is_codec_offload_supported(int codec); |
274 | 301 | #else |
@@ -418,6 +445,14 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_ | ||
418 | 445 | *p_codec_type = A2D_NON_A2DP_MEDIA_CT; |
419 | 446 | A2D_BldAptxInfo(AVDT_MEDIA_AUDIO, (tA2D_APTX_CIE *) &bta_av_co_aptx_caps, p_codec_info); |
420 | 447 | return TRUE; |
448 | + | |
449 | + case BTIF_SV_AV_AA_APTX_HD_INDEX: | |
450 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
451 | + /* Set up for aptX HD codec */ | |
452 | + *p_codec_type = A2D_NON_A2DP_MEDIA_CT; | |
453 | + A2D_BldAptx_hdInfo(AVDT_MEDIA_AUDIO, (tA2D_APTX_HD_CIE *) &bta_av_co_aptx_hd_caps, p_codec_info); | |
454 | + return TRUE; | |
455 | + | |
421 | 456 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
422 | 457 | case BTIF_SV_AV_AA_AAC_INDEX: |
423 | 458 | APPL_TRACE_DEBUG("%s AAC", __func__); |
@@ -739,15 +774,17 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, | ||
739 | 774 | break; |
740 | 775 | case A2D_NON_A2DP_MEDIA_CT: |
741 | 776 | { |
742 | - UINT16 codecId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->codecId; | |
743 | - UINT32 vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->vendorId; | |
777 | + UINT16 codecId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->codecId; | |
778 | + UINT32 vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->vendorId; | |
744 | 779 | APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId ); |
745 | 780 | APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId ); |
746 | 781 | |
747 | - if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
748 | - { | |
782 | + if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) { | |
749 | 783 | /* aptX */ |
750 | 784 | supported = TRUE; |
785 | + } else if (codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_HD_VENDOR_ID) { | |
786 | + /* aptX HD */ | |
787 | + supported = TRUE; | |
751 | 788 | } |
752 | 789 | break; |
753 | 790 | } |
@@ -777,7 +814,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, | ||
777 | 814 | APPL_TRACE_DEBUG("%s p_codec_info[%d]: %x", __func__, i, p_codec_info[i]); |
778 | 815 | |
779 | 816 | if (codec_type == A2D_NON_A2DP_MEDIA_CT) |
780 | - memcpy(p_sink->codec_caps, &p_codec_info[3], AVDT_CODEC_SIZE); | |
817 | + memcpy(p_sink->codec_caps, &p_codec_info[BTA_AV_CFG_START_IDX], AVDT_CODEC_SIZE); | |
781 | 818 | else |
782 | 819 | memcpy(p_sink->codec_caps, p_codec_info, AVDT_CODEC_SIZE); |
783 | 820 |
@@ -998,8 +1035,8 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, | ||
998 | 1035 | { |
999 | 1036 | UINT16 codecId; |
1000 | 1037 | UINT32 vendorId; |
1001 | - codecId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->codecId; | |
1002 | - vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[3]))->vendorId; | |
1038 | + codecId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->codecId; | |
1039 | + vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->vendorId; | |
1003 | 1040 | APPL_TRACE_DEBUG("%s codec_type = %x", __func__, codec_type); |
1004 | 1041 | APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId); |
1005 | 1042 | APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId); |
@@ -1018,12 +1055,16 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, | ||
1018 | 1055 | recfg_needed = TRUE; |
1019 | 1056 | } |
1020 | 1057 | |
1021 | - if ((codecId == A2D_APTX_CODEC_ID_BLUETOOTH) && (vendorId == A2D_APTX_VENDOR_ID)) | |
1022 | - { | |
1058 | + if ((codecId == A2D_APTX_CODEC_ID_BLUETOOTH) && (vendorId == A2D_APTX_VENDOR_ID)) { | |
1023 | 1059 | APPL_TRACE_DEBUG("%s aptX", __func__); |
1024 | 1060 | bta_av_co_cb.codec_cfg_aptx_setconfig.id = A2D_NON_A2DP_MEDIA_CT; |
1025 | 1061 | memcpy(bta_av_co_cb.codec_cfg_aptx_setconfig.info, p_codec_info, AVDT_CODEC_SIZE); |
1026 | 1062 | bta_av_co_cb.codec_cfg_setconfig = &bta_av_co_cb.codec_cfg_aptx_setconfig; |
1063 | + } else if ((codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) && (vendorId == A2D_APTX_HD_VENDOR_ID)) { | |
1064 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
1065 | + bta_av_co_cb.codec_cfg_aptx_hd_setconfig.id = A2D_NON_A2DP_MEDIA_CT; | |
1066 | + memcpy(bta_av_co_cb.codec_cfg_aptx_hd_setconfig.info, p_codec_info, AVDT_CODEC_SIZE); | |
1067 | + bta_av_co_cb.codec_cfg_setconfig = &bta_av_co_cb.codec_cfg_aptx_hd_setconfig; | |
1027 | 1068 | } |
1028 | 1069 | break; |
1029 | 1070 | } |
@@ -1160,14 +1201,21 @@ void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, | ||
1160 | 1201 | UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr) |
1161 | 1202 | { |
1162 | 1203 | UNUSED(hndl); |
1163 | - UNUSED(codec_type); | |
1164 | - UNUSED(p_codec_info); | |
1165 | - UNUSED(p_no_rtp_hdr); | |
1166 | 1204 | |
1167 | 1205 | FUNC_TRACE(); |
1168 | 1206 | |
1169 | 1207 | APPL_TRACE_DEBUG("bta_av_co_audio_start"); |
1170 | 1208 | |
1209 | + if (codec_type == A2D_NON_A2DP_MEDIA_CT) { | |
1210 | + UINT16 codecId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->codecId; | |
1211 | + UINT32 vendorId = ((tA2D_APTX_CIE*)(&p_codec_info[BTA_AV_CFG_START_IDX]))->vendorId; | |
1212 | + | |
1213 | + // for aptX, we only add RTP hdr along with CP | |
1214 | + if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) { | |
1215 | + if (!bta_av_co_cb.cp.active) | |
1216 | + *p_no_rtp_hdr = TRUE; | |
1217 | + } | |
1218 | + } | |
1171 | 1219 | } |
1172 | 1220 | |
1173 | 1221 | /******************************************************************************* |
@@ -1336,10 +1384,15 @@ static BOOLEAN bta_av_co_audio_codec_build_config(const UINT8 *p_codec_caps, UIN | ||
1336 | 1384 | APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId); |
1337 | 1385 | APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId); |
1338 | 1386 | |
1339 | - memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg->info, A2D_APTX_CODEC_LEN+1); | |
1340 | - APPL_TRACE_DEBUG("%s aptX",__func__); | |
1387 | + if ((codecId == A2D_APTX_CODEC_ID_BLUETOOTH) && (vendorId == A2D_APTX_VENDOR_ID)) { | |
1388 | + memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg->info, A2D_APTX_CODEC_LEN+1); | |
1389 | + APPL_TRACE_DEBUG("%s aptX",__func__); | |
1390 | + } else if ((codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) && (vendorId == A2D_APTX_HD_VENDOR_ID)) { | |
1391 | + memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg->info, A2D_APTX_HD_CODEC_LEN+1); | |
1392 | + APPL_TRACE_DEBUG("%s aptX HD",__func__); | |
1393 | + } | |
1341 | 1394 | break; |
1342 | - } | |
1395 | + } | |
1343 | 1396 | |
1344 | 1397 | default: |
1345 | 1398 | APPL_TRACE_ERROR("bta_av_co_audio_codec_build_config: unsupported codec id %d", bta_av_co_cb.codec_cfg->id); |
@@ -1495,19 +1548,23 @@ static BOOLEAN bta_av_co_audio_codec_match(const UINT8 *p_codec_caps, UINT8 code | ||
1495 | 1548 | APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecId); |
1496 | 1549 | APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, vendorId); |
1497 | 1550 | |
1498 | - if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
1499 | - { | |
1551 | + if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) { | |
1500 | 1552 | /* aptX Classic */ |
1501 | 1553 | APPL_TRACE_DEBUG("%s aptX", __func__); |
1502 | 1554 | return bta_av_co_audio_codec_cfg_matches_caps(bta_av_co_cb.codec_cfg_aptx.id, p_codec_caps, bta_av_co_cb.codec_cfg_aptx.info); |
1503 | 1555 | break; |
1556 | + } else if (codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_HD_VENDOR_ID) { | |
1557 | + /* aptX HD */ | |
1558 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
1559 | + return bta_av_co_audio_codec_cfg_matches_caps(bta_av_co_cb.codec_cfg_aptx_hd.id, p_codec_caps, bta_av_co_cb.codec_cfg_aptx_hd.info); | |
1560 | + break; | |
1504 | 1561 | } else { |
1505 | - APPL_TRACE_ERROR("%s incorrect aptX vendor and codec ID combination (codec ID: %d)", __func__, codecId); | |
1506 | - APPL_TRACE_ERROR("%s incorrect aptX vendor (%x) and codec ID combination ", __func__, vendorId); | |
1562 | + APPL_TRACE_ERROR("%s incorrect codecId (%d)", __func__, codecId); | |
1563 | + APPL_TRACE_ERROR("%s incorrect vendorId (%x)", __func__, vendorId); | |
1507 | 1564 | break; |
1508 | 1565 | } |
1509 | 1566 | } |
1510 | - default: | |
1567 | + default: | |
1511 | 1568 | 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); |
1512 | 1569 | break; |
1513 | 1570 | } |
@@ -1636,51 +1693,89 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT | ||
1636 | 1693 | /* Configure the codec type to look for */ |
1637 | 1694 | codec_type = bta_av_co_cb.codec_cfg->id; |
1638 | 1695 | |
1639 | -/* Check for aptX as this is order of priority. | |
1640 | - * Check for aptX-HD, then aptX-LL before aptX Classic as | |
1696 | +/* Check for aptX HD before aptX Classic as | |
1641 | 1697 | * this is order of priority, if supported return true. |
1698 | + * multicast is not supported for aptX | |
1642 | 1699 | */ |
1643 | - if ((!bt_split_a2dp_enabled && isA2dAptXEnabled && (btif_max_av_clients <= 1)) || | |
1700 | + if ((!bt_split_a2dp_enabled && isA2dAptXEnabled && (btif_av_is_multicast_supported() == FALSE)) || | |
1644 | 1701 | (bt_split_a2dp_enabled && btif_av_is_codec_offload_supported(APTX))) |
1645 | 1702 | { |
1646 | - UINT16 codecId; | |
1647 | - UINT32 vendorId; | |
1648 | - UINT8* aptx_capabilities; | |
1649 | - | |
1650 | - for (index = 0; index < p_peer->num_sup_snks; index++) | |
1651 | - { | |
1652 | - if (p_peer->snks[index].codec_type == A2D_NON_A2DP_MEDIA_CT) | |
1653 | - { | |
1654 | - aptx_capabilities = &(p_peer->snks[index].codec_caps[0]); | |
1655 | - codecId = ((tA2D_APTX_CIE*)aptx_capabilities)->codecId; | |
1656 | - vendorId = ((tA2D_APTX_CIE*)aptx_capabilities)->vendorId; | |
1657 | - int i = 0; | |
1658 | - for ( i = 0 ; i < AVDT_CODEC_SIZE; i++) { | |
1659 | - APPL_TRACE_DEBUG("%s codec_caps[%d]: %x", __func__, i, p_peer->snks[index].codec_caps[i]); | |
1660 | - } | |
1661 | - APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId); | |
1662 | - APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId); | |
1663 | - APPL_TRACE_DEBUG("%s p_peer->snks[index].codec_type = %x", __func__, p_peer->snks[index].codec_type ); | |
1664 | - | |
1665 | - if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
1666 | - { | |
1667 | - if (p_snk_index) | |
1703 | + UINT16 codecId; | |
1704 | + UINT32 vendorId; | |
1705 | + UINT8* aptx_capabilities; | |
1706 | + | |
1707 | + if (isA2dAptXHdEnabled) { | |
1708 | + for (index = 0; index < p_peer->num_sup_snks; index++) | |
1709 | + { | |
1710 | + if (p_peer->snks[index].codec_type == A2D_NON_A2DP_MEDIA_CT) | |
1711 | + { | |
1712 | + aptx_capabilities = &(p_peer->snks[index].codec_caps[0]); | |
1713 | + codecId = ((tA2D_APTX_HD_CIE*)aptx_capabilities)->codecId; | |
1714 | + vendorId = ((tA2D_APTX_HD_CIE*)aptx_capabilities)->vendorId; | |
1715 | + int i = 0; | |
1716 | + for ( i = 0 ; i < AVDT_CODEC_SIZE; i++) { | |
1717 | + APPL_TRACE_DEBUG("%s codec_caps[%d]: %x", __func__, i, p_peer->snks[index].codec_caps[i]); | |
1718 | + } | |
1719 | + APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId); | |
1720 | + APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId); | |
1721 | + APPL_TRACE_DEBUG("%s p_peer->snks[index].codec_type = %x", __func__, p_peer->snks[index].codec_type ); | |
1722 | + | |
1723 | + if (codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_HD_VENDOR_ID ) | |
1724 | + { | |
1725 | + if (p_snk_index) | |
1726 | + *p_snk_index = index; | |
1727 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
1728 | + | |
1729 | + if (bta_av_co_audio_codec_match(p_peer->snks[index].codec_caps, A2D_NON_A2DP_MEDIA_CT)) | |
1730 | + { | |
1731 | + #if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE) | |
1732 | + if (bta_av_co_audio_sink_has_scmst(&p_peer->snks[index])) | |
1733 | + #endif | |
1734 | + { | |
1735 | + bta_av_co_cb.current_codec_id = bta_av_co_cb.codec_cfg_aptx_hd.id; | |
1736 | + bta_av_co_cb.codec_cfg = &bta_av_co_cb.codec_cfg_aptx_hd; | |
1737 | + return TRUE; | |
1738 | + } | |
1739 | + } | |
1740 | + } | |
1741 | + } | |
1742 | + } | |
1743 | + } | |
1744 | + | |
1745 | + for (index = 0; index < p_peer->num_sup_snks; index++) | |
1746 | + { | |
1747 | + if (p_peer->snks[index].codec_type == A2D_NON_A2DP_MEDIA_CT) | |
1748 | + { | |
1749 | + aptx_capabilities = &(p_peer->snks[index].codec_caps[0]); | |
1750 | + codecId = ((tA2D_APTX_CIE*)aptx_capabilities)->codecId; | |
1751 | + vendorId = ((tA2D_APTX_CIE*)aptx_capabilities)->vendorId; | |
1752 | + int i = 0; | |
1753 | + for ( i = 0 ; i < AVDT_CODEC_SIZE; i++) { | |
1754 | + APPL_TRACE_DEBUG("%s codec_caps[%d]: %x", __func__, i, p_peer->snks[index].codec_caps[i]); | |
1755 | + } | |
1756 | + APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecId); | |
1757 | + APPL_TRACE_DEBUG("%s vendorId = %x", __func__, vendorId); | |
1758 | + APPL_TRACE_DEBUG("%s p_peer->snks[index].codec_type = %x", __func__, p_peer->snks[index].codec_type ); | |
1759 | + | |
1760 | + if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
1761 | + { | |
1762 | + if (p_snk_index) | |
1668 | 1763 | *p_snk_index = index; |
1669 | - APPL_TRACE_DEBUG("%s aptX", __func__); | |
1764 | + APPL_TRACE_DEBUG("%s aptX", __func__); | |
1670 | 1765 | |
1671 | - if (bta_av_co_audio_codec_match(p_peer->snks[index].codec_caps, A2D_NON_A2DP_MEDIA_CT)) | |
1672 | - { | |
1766 | + if (bta_av_co_audio_codec_match(p_peer->snks[index].codec_caps, A2D_NON_A2DP_MEDIA_CT)) | |
1767 | + { | |
1673 | 1768 | #if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE) |
1674 | - if (bta_av_co_audio_sink_has_scmst(&p_peer->snks[index])) | |
1769 | + if (bta_av_co_audio_sink_has_scmst(&p_peer->snks[index])) | |
1675 | 1770 | #endif |
1676 | - { | |
1677 | - bta_av_co_cb.current_codec_id = bta_av_co_cb.codec_cfg_aptx.id; | |
1678 | - bta_av_co_cb.codec_cfg = &bta_av_co_cb.codec_cfg_aptx; | |
1679 | - return TRUE; | |
1680 | - } | |
1681 | - } | |
1771 | + { | |
1772 | + bta_av_co_cb.current_codec_id = bta_av_co_cb.codec_cfg_aptx.id; | |
1773 | + bta_av_co_cb.codec_cfg = &bta_av_co_cb.codec_cfg_aptx; | |
1774 | + return TRUE; | |
1775 | + } | |
1776 | + } | |
1682 | 1777 | } |
1683 | - } | |
1778 | + } | |
1684 | 1779 | } |
1685 | 1780 | } else |
1686 | 1781 | APPL_TRACE_DEBUG("%s aptX is disabled", __func__); |
@@ -1879,11 +1974,16 @@ static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UIN | ||
1879 | 1974 | APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecId); |
1880 | 1975 | APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, vendorId); |
1881 | 1976 | |
1882 | - if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) | |
1883 | - { | |
1977 | + if (codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_HD_VENDOR_ID) { | |
1978 | + APPL_TRACE_DEBUG("%s tA2D_APTX_CIE aptX HD", __func__); | |
1979 | + if (a2d_av_aptx_hd_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_APTX_HD_CIE *)&bta_av_co_aptx_hd_caps)) { | |
1980 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
1981 | + return FALSE; | |
1982 | + } | |
1983 | + break; | |
1984 | + } else if (codecId == A2D_APTX_CODEC_ID_BLUETOOTH && vendorId == A2D_APTX_VENDOR_ID) { | |
1884 | 1985 | APPL_TRACE_DEBUG("%s tA2D_APTX_CIE aptX", __func__); |
1885 | - if (a2d_av_aptx_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_APTX_CIE *)&bta_av_co_aptx_caps)) | |
1886 | - { | |
1986 | + if (a2d_av_aptx_cfg_in_cap((UINT8 *)p_codec_cfg, (tA2D_APTX_CIE *)&bta_av_co_aptx_caps)) { | |
1887 | 1987 | APPL_TRACE_DEBUG("%s aptX", __func__); |
1888 | 1988 | return FALSE; |
1889 | 1989 | } |
@@ -1962,9 +2062,9 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status) | ||
1962 | 2062 | /* Check if this sink supports SCMS */ |
1963 | 2063 | cp_active = bta_av_co_audio_sink_has_scmst(p_sink); |
1964 | 2064 | #endif |
1965 | - APPL_TRACE_DEBUG("%s %x", __func__, bta_av_co_cb.current_codec_id); | |
2065 | + APPL_TRACE_DEBUG("%s current_codec_id: %x", __func__, bta_av_co_cb.current_codec_id); | |
1966 | 2066 | APPL_TRACE_DEBUG("%s p_scb_codec_type: %x", __func__, p_scb_codec_type); |
1967 | - p_scb_codec_type = bta_av_co_audio_get_codec_type(); | |
2067 | + p_scb_codec_type = bta_av_get_codec_type(); | |
1968 | 2068 | APPL_TRACE_DEBUG("%s p_scb_codec_type: %x", __func__, p_scb_codec_type); |
1969 | 2069 | /* Check if this is a new configuration (new sink or new config) */ |
1970 | 2070 | if ((p_sink != p_peer->p_snk) || |
@@ -2042,6 +2142,11 @@ void bta_av_co_audio_codec_reset(void) | ||
2042 | 2142 | 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) |
2043 | 2143 | APPL_TRACE_ERROR("%s A2D_BldAptxInfo failed", __func__); |
2044 | 2144 | |
2145 | + /* Reset the Current configuration to aptX HD */ | |
2146 | + bta_av_co_cb.codec_cfg_aptx_hd.id = A2D_NON_A2DP_MEDIA_CT; | |
2147 | + if (A2D_BldAptx_hdInfo(A2D_MEDIA_TYPE_AUDIO, (tA2D_APTX_HD_CIE *)&btif_av_aptx_hd_default_config, bta_av_co_cb.codec_cfg_aptx_hd.info) != A2D_SUCCESS) | |
2148 | + APPL_TRACE_ERROR("%s A2D_BldAptx_hdInfo failed", __func__); | |
2149 | + | |
2045 | 2150 | mutex_global_unlock(); |
2046 | 2151 | } |
2047 | 2152 |
@@ -2062,6 +2167,8 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2062 | 2167 | tBTIF_AV_CODEC_INFO new_cfg_sbc; |
2063 | 2168 | tA2D_APTX_CIE aptx_config; |
2064 | 2169 | tBTIF_AV_CODEC_INFO new_cfg_aptx; |
2170 | + tA2D_APTX_HD_CIE aptx_hd_config; | |
2171 | + tBTIF_AV_CODEC_INFO new_cfg_aptx_hd; | |
2065 | 2172 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2066 | 2173 | tA2D_AAC_CIE aac_config; |
2067 | 2174 | tBTIF_AV_CODEC_INFO new_cfg_aac; |
@@ -2087,13 +2194,16 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2087 | 2194 | return FALSE; |
2088 | 2195 | } |
2089 | 2196 | if ((p_feeding->cfg.pcm.bit_per_sample != 8) && |
2090 | - (p_feeding->cfg.pcm.bit_per_sample != 16)) | |
2197 | + (p_feeding->cfg.pcm.bit_per_sample != 16) && | |
2198 | + (p_feeding->cfg.pcm.bit_per_sample != 32)) | |
2091 | 2199 | { |
2092 | 2200 | APPL_TRACE_ERROR("bta_av_co_audio_set_codec PCM sample size unsupported"); |
2093 | 2201 | return FALSE; |
2094 | 2202 | } |
2095 | 2203 | new_cfg_aptx.id = A2D_NON_A2DP_MEDIA_CT; |
2096 | 2204 | aptx_config = btif_av_aptx_default_config; |
2205 | + new_cfg_aptx_hd.id = A2D_NON_A2DP_MEDIA_CT; | |
2206 | + aptx_hd_config = btif_av_aptx_hd_default_config; | |
2097 | 2207 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2098 | 2208 | new_cfg_aac.id = BTIF_AV_CODEC_M24; |
2099 | 2209 | aac_config = btif_av_aac_default_config; |
@@ -2108,6 +2218,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2108 | 2218 | case 48000: |
2109 | 2219 | sbc_config.samp_freq = A2D_SBC_IE_SAMP_FREQ_48; |
2110 | 2220 | aptx_config.sampleRate = A2D_APTX_SAMPLERATE_48000; |
2221 | + aptx_hd_config.sampleRate = A2D_APTX_HD_SAMPLERATE_48000; | |
2111 | 2222 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2112 | 2223 | aac_config.samp_freq = A2D_AAC_IE_SAMP_FREQ_48000; |
2113 | 2224 | #endif |
@@ -2118,6 +2229,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2118 | 2229 | case 44100: |
2119 | 2230 | sbc_config.samp_freq = A2D_SBC_IE_SAMP_FREQ_44; |
2120 | 2231 | aptx_config.sampleRate = A2D_APTX_SAMPLERATE_44100; |
2232 | + aptx_hd_config.sampleRate = A2D_APTX_HD_SAMPLERATE_44100; | |
2121 | 2233 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2122 | 2234 | aac_config.samp_freq = A2D_AAC_IE_SAMP_FREQ_44100; |
2123 | 2235 | #endif |
@@ -2138,6 +2250,11 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2138 | 2250 | APPL_TRACE_ERROR("%s A2D_BldAptxInfo failed", __func__); |
2139 | 2251 | return FALSE; |
2140 | 2252 | } |
2253 | + if (A2D_BldAptx_hdInfo(A2D_MEDIA_TYPE_AUDIO, &aptx_hd_config, new_cfg_aptx_hd.info) != A2D_SUCCESS) | |
2254 | + { | |
2255 | + APPL_TRACE_ERROR("%s A2D_BldAptx_hdInfo failed", __func__); | |
2256 | + return FALSE; | |
2257 | + } | |
2141 | 2258 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2142 | 2259 | if (A2D_BldAacInfo(A2D_MEDIA_TYPE_AUDIO, &aac_config, new_cfg_aac.info) != A2D_SUCCESS) |
2143 | 2260 | { |
@@ -2158,6 +2275,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2158 | 2275 | bta_av_co_cb.codec_cfg_sbc = new_cfg_sbc; |
2159 | 2276 | bta_av_co_cb.codec_cfg = &bta_av_co_cb.codec_cfg_sbc; |
2160 | 2277 | bta_av_co_cb.codec_cfg_aptx= new_cfg_aptx; |
2278 | + bta_av_co_cb.codec_cfg_aptx_hd = new_cfg_aptx_hd; | |
2161 | 2279 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
2162 | 2280 | bta_av_co_cb.codec_cfg_aac = new_cfg_aac; |
2163 | 2281 | #endif |
@@ -2169,9 +2287,11 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
2169 | 2287 | |
2170 | 2288 | UINT8 bta_av_select_codec(UINT8 hdl) |
2171 | 2289 | { |
2172 | - // Some circumstances - bta_av_co functions are called before codec clock is initialised | |
2173 | 2290 | if (NULL == bta_av_co_cb.codec_cfg) |
2174 | 2291 | { |
2292 | + // Some circumstances - bta_av_co functions are called before | |
2293 | + // codec clock is initialised | |
2294 | + APPL_TRACE_ERROR("%s hdl = %d, no codec configured", __func__, hdl); | |
2175 | 2295 | return BTIF_AV_CODEC_NONE; |
2176 | 2296 | } |
2177 | 2297 | else |
@@ -2194,7 +2314,7 @@ UINT8 bta_av_select_codec(UINT8 hdl) | ||
2194 | 2314 | } |
2195 | 2315 | } |
2196 | 2316 | |
2197 | -UINT8 bta_av_get_current_codec() | |
2317 | +UINT8 bta_av_co_get_current_codec() | |
2198 | 2318 | { |
2199 | 2319 | // Some circumstances - bta_av_co functions are called before codec clock is initialised |
2200 | 2320 | if (NULL == bta_av_co_cb.codec_cfg) |
@@ -2203,7 +2323,7 @@ UINT8 bta_av_get_current_codec() | ||
2203 | 2323 | return bta_av_co_cb.codec_cfg->id; |
2204 | 2324 | } |
2205 | 2325 | |
2206 | -UINT8* bta_av_get_current_codecInfo() | |
2326 | +UINT8* bta_av_co_get_current_codecInfo() | |
2207 | 2327 | { |
2208 | 2328 | // We assume that the configuration block is always valid when this is called. |
2209 | 2329 | return &bta_av_co_cb.codec_cfg->info[0]; |
@@ -2244,15 +2364,20 @@ BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT | ||
2244 | 2364 | result = TRUE; |
2245 | 2365 | else |
2246 | 2366 | memcpy((tA2D_SBC_CIE *) p_config, &btif_av_sbc_default_config, sizeof(tA2D_SBC_CIE)); |
2247 | - } | |
2248 | - 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) | |
2249 | - { | |
2367 | + } else 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) { | |
2250 | 2368 | APPL_TRACE_DEBUG("%s aptX", __func__); |
2251 | 2369 | tA2D_APTX_CIE *aptx_config = (tA2D_APTX_CIE *)p_config; |
2252 | 2370 | if (A2D_ParsAptxInfo(aptx_config, bta_av_co_cb.codec_cfg_aptx.info, FALSE) == A2D_SUCCESS) |
2253 | 2371 | result = TRUE; |
2254 | 2372 | else |
2255 | 2373 | memcpy((tA2D_APTX_CIE *) p_config, &btif_av_aptx_default_config, sizeof(tA2D_APTX_CIE)); |
2374 | + } else if (type == A2D_NON_A2DP_MEDIA_CT && ((tA2D_APTX_HD_CIE *)p_config)->vendorId == A2D_APTX_HD_VENDOR_ID && ((tA2D_APTX_HD_CIE *)p_config)->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) { | |
2375 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
2376 | + tA2D_APTX_HD_CIE *aptx_hd_config = (tA2D_APTX_HD_CIE *)p_config; | |
2377 | + if (A2D_ParsAptx_hdInfo(aptx_hd_config, bta_av_co_cb.codec_cfg_aptx_hd.info, FALSE) == A2D_SUCCESS) | |
2378 | + result = TRUE; | |
2379 | + else | |
2380 | + memcpy((tA2D_APTX_HD_CIE *) p_config, &btif_av_aptx_hd_default_config, sizeof(tA2D_APTX_HD_CIE)); | |
2256 | 2381 | } else { |
2257 | 2382 | APPL_TRACE_DEBUG("%s vendorId: %d codecId: %d\n", __func__, ((tA2D_APTX_CIE *)p_config)->vendorId, ((tA2D_APTX_CIE *)p_config)->codecId); |
2258 | 2383 | } |
@@ -257,4 +257,26 @@ void btif_av_get_peer_addr(bt_bdaddr_t *peer_bda); | ||
257 | 257 | #define btif_av_get_peer_addr(peer_bda) (0) |
258 | 258 | #endif |
259 | 259 | |
260 | +/******************************************************************************* | |
261 | +** | |
262 | +** Function btif_av_get_multicast_state | |
263 | +** | |
264 | +** Description Check if A2DP multicast is enabled | |
265 | +** | |
266 | +** Returns TRUE if a2dp multicast is enabled | |
267 | +** | |
268 | +*******************************************************************************/ | |
269 | +BOOLEAN btif_av_get_multicast_state(); | |
270 | + | |
271 | +/******************************************************************************* | |
272 | +** | |
273 | +** Function btif_av_is_multicast_supported | |
274 | +** | |
275 | +** Description Check if A2DP multicast is supported | |
276 | +** | |
277 | +** Returns TRUE if a2dp multicast is supported | |
278 | +** | |
279 | +*******************************************************************************/ | |
280 | +BOOLEAN btif_av_is_multicast_supported(); | |
281 | + | |
260 | 282 | #endif /* BTIF_AV_H */ |
@@ -111,25 +111,25 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI | ||
111 | 111 | |
112 | 112 | /******************************************************************************* |
113 | 113 | ** |
114 | - ** Function bta_av_get_current_codec | |
114 | + ** Function bta_av_co_get_current_codec | |
115 | 115 | ** |
116 | 116 | ** Description Get the current codec type. |
117 | 117 | ** |
118 | 118 | ** Returns Codec Type Value |
119 | 119 | ** |
120 | 120 | *******************************************************************************/ |
121 | -UINT8 bta_av_get_current_codec(); | |
121 | +UINT8 bta_av_co_get_current_codec(); | |
122 | 122 | |
123 | 123 | /******************************************************************************* |
124 | 124 | ** |
125 | - ** Function bta_av_get_current_codecInfo | |
125 | + ** Function bta_av_co_get_current_codecInfo | |
126 | 126 | ** |
127 | 127 | ** Description Get the current codec Info. |
128 | 128 | ** |
129 | 129 | ** Returns Returns pointer to Info |
130 | 130 | ** |
131 | 131 | *******************************************************************************/ |
132 | -UINT8* bta_av_get_current_codecInfo(); | |
132 | +UINT8* bta_av_co_get_current_codecInfo(); | |
133 | 133 | |
134 | 134 | /******************************************************************************* |
135 | 135 | ** |
@@ -227,15 +227,4 @@ BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max); | ||
227 | 227 | *******************************************************************************/ |
228 | 228 | UINT8 bta_av_select_codec(tBTA_AV_HNDL hdl); |
229 | 229 | |
230 | -/******************************************************************************* | |
231 | - ** | |
232 | - ** Function bta_av_get_current_codec | |
233 | - ** | |
234 | - ** Description Get current codec id selected for streaming. | |
235 | - ** | |
236 | - ** Returns Return current codec id | |
237 | - ** | |
238 | - *******************************************************************************/ | |
239 | -UINT8 bta_av_get_current_codec(void); | |
240 | - | |
241 | 230 | #endif |
@@ -62,8 +62,7 @@ | ||
62 | 62 | #define BTIF_MEDIA_TRSCD_OFF 0 |
63 | 63 | #define BTIF_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */ |
64 | 64 | #define BTIF_MEDIA_TRSCD_PCM_2_APTX 2 |
65 | - | |
66 | -extern int btif_max_av_clients; /* maximum number of AV clients supported */ | |
65 | +#define BTIF_MEDIA_TRSCD_PCM_2_APTX_HD 3 | |
67 | 66 | |
68 | 67 | /******************************************************************************* |
69 | 68 | ** Data types |
@@ -82,8 +81,8 @@ typedef struct | ||
82 | 81 | UINT8 AllocationMethod; /* loudness or SNR*/ |
83 | 82 | UINT16 MtuSize; /* peer mtu size */ |
84 | 83 | UINT8 CodecType; /* SBC or Non-A2DP */ |
85 | - UINT8 BluetoothVendorID; /* Bluetooth Vendor ID */ | |
86 | - UINT8 BluetoothCodecID; /* Bluetooth Codec ID */ | |
84 | + UINT32 BluetoothVendorID; /* Bluetooth Vendor ID */ | |
85 | + UINT16 BluetoothCodecID; /* Bluetooth Codec ID */ | |
87 | 86 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
88 | 87 | UINT8 ObjectType; |
89 | 88 | UINT32 bit_rate; |
@@ -100,8 +99,8 @@ typedef struct | ||
100 | 99 | UINT8 MaxBitPool; /* Maximum peer bitpool */ |
101 | 100 | UINT8 MinBitPool; /* Minimum peer bitpool */ |
102 | 101 | UINT8 CodecType; /* SBC or Non-A2DP */ |
103 | - UINT8 BluetoothVendorID; /* Bluetooth Vendor ID */ | |
104 | - UINT8 BluetoothCodecID; /* Bluetooth Codec ID */ | |
102 | + UINT32 BluetoothVendorID; /* Bluetooth Vendor ID */ | |
103 | + UINT16 BluetoothCodecID; /* Bluetooth Codec ID */ | |
105 | 104 | } tBTIF_MEDIA_UPDATE_AUDIO; |
106 | 105 | |
107 | 106 | /* tBTIF_MEDIA_INIT_AUDIO_FEEDING msg structure */ |
@@ -3493,6 +3493,19 @@ BOOLEAN btif_av_get_ongoing_multicast() | ||
3493 | 3493 | |
3494 | 3494 | /****************************************************************************** |
3495 | 3495 | ** |
3496 | +** Function btif_av_is_multicast_supported | |
3497 | +** | |
3498 | +** Description Returns TRUE if multicast is supported | |
3499 | +** | |
3500 | +** Returns BOOLEAN | |
3501 | +******************************************************************************/ | |
3502 | +BOOLEAN btif_av_is_multicast_supported() | |
3503 | +{ | |
3504 | + return is_multicast_supported; | |
3505 | +} | |
3506 | + | |
3507 | +/****************************************************************************** | |
3508 | +** | |
3496 | 3509 | ** Function btif_av_is_offload_supported |
3497 | 3510 | ** |
3498 | 3511 | ** Description Returns split mode status |
@@ -42,11 +42,14 @@ | ||
42 | 42 | #include <pthread.h> |
43 | 43 | #include <stdint.h> |
44 | 44 | #include <stdio.h> |
45 | +#include <dlfcn.h> | |
45 | 46 | #include <string.h> |
46 | 47 | #include <sys/stat.h> |
47 | 48 | #include <sys/time.h> |
48 | 49 | #include <sys/types.h> |
49 | 50 | #include <unistd.h> |
51 | +#include <audio_utils/primitives.h> | |
52 | +#include <audio_utils/format.h> | |
50 | 53 | |
51 | 54 | #include <hardware/bluetooth.h> |
52 | 55 |
@@ -61,6 +64,7 @@ | ||
61 | 64 | #include "a2d_int.h" |
62 | 65 | #include "a2d_sbc.h" |
63 | 66 | #include "a2d_aptx.h" |
67 | +#include "a2d_aptx_hd.h" | |
64 | 68 | #include "a2d_aac.h" |
65 | 69 | #include "audio_a2dp_hw.h" |
66 | 70 | #include "bt_target.h" |
@@ -193,8 +197,10 @@ enum { | ||
193 | 197 | |
194 | 198 | #if (BTA_AV_CO_CP_SCMS_T == TRUE) |
195 | 199 | #define BTIF_MEDIA_AA_APTX_OFFSET (AVDT_MEDIA_OFFSET + 1) |
200 | +#define BTIF_MEDIA_AA_APTX_HD_OFFSET (AVDT_MEDIA_OFFSET + 1) | |
196 | 201 | #else |
197 | 202 | #define BTIF_MEDIA_AA_APTX_OFFSET (AVDT_MEDIA_OFFSET - AVDT_MEDIA_HDR_SIZE) //no RTP header for aptX classic |
203 | +#define BTIF_MEDIA_AA_APTX_HD_OFFSET (AVDT_MEDIA_OFFSET) //there is an RTP header for aptX HD, but no CP byte | |
198 | 204 | #endif |
199 | 205 | /* Define the bitrate step when trying to match bitpool value */ |
200 | 206 | #ifndef BTIF_MEDIA_BITRATE_STEP |
@@ -372,7 +378,9 @@ typedef struct | ||
372 | 378 | SBC_ENC_PARAMS encoder; |
373 | 379 | UINT16 offset; |
374 | 380 | A2D_APTX_ENC_PARAMS aptxEncoderParams; |
381 | + A2D_APTX_HD_ENC_PARAMS aptxhdEncoderParams; | |
375 | 382 | UINT16 as16PcmBuffer[1024]; |
383 | + UINT32 as32PcmBuffer[1024]; | |
376 | 384 | UINT8 busy_level; |
377 | 385 | void* av_sm_hdl; |
378 | 386 | UINT8 a2dp_cmd_pending; /* we can have max one command pending */ |
@@ -446,7 +454,6 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg); | ||
446 | 454 | #endif |
447 | 455 | |
448 | 456 | BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT8 type); |
449 | -UINT8 bta_av_get_current_codec(); | |
450 | 457 | static thread_t *aptx_thread = NULL; |
451 | 458 | |
452 | 459 | #if (BTA_AV_INCLUDED == TRUE) |
@@ -518,7 +525,6 @@ static fixed_queue_t *btif_media_cmd_msg_queue; | ||
518 | 525 | static thread_t *worker_thread; |
519 | 526 | |
520 | 527 | BOOLEAN bta_av_co_audio_get_codec_config(UINT8 *p_config, UINT16 *p_minmtu, UINT8 type); |
521 | -UINT8 bta_av_get_current_codec(); | |
522 | 528 | |
523 | 529 | extern BOOLEAN bt_split_a2dp_enabled; |
524 | 530 | extern int btif_max_av_clients; |
@@ -895,7 +901,7 @@ static void btif_recv_ctrl_data(void) | ||
895 | 901 | } |
896 | 902 | else //get playing device hdl |
897 | 903 | { |
898 | - codec_id = bta_av_get_current_codec(); | |
904 | + codec_id = bta_av_co_get_current_codec(); | |
899 | 905 | } |
900 | 906 | |
901 | 907 | a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS); |
@@ -918,7 +924,7 @@ static void btif_recv_ctrl_data(void) | ||
918 | 924 | else if (codec_id == A2D_NON_A2DP_MEDIA_CT) //this is changed to non-a2dp VS codec |
919 | 925 | { |
920 | 926 | //ADD APTX support |
921 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
927 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
922 | 928 | int j; |
923 | 929 | UINT8 *p_ptr = ptr; |
924 | 930 | for(j=0; j< (int)sizeof(tA2D_APTX_CIE);j++) |
@@ -928,8 +934,8 @@ static void btif_recv_ctrl_data(void) | ||
928 | 934 | if (ptr) |
929 | 935 | { |
930 | 936 | tA2D_APTX_CIE* codecInfo = 0; |
931 | - codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
932 | - if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID | |
937 | + codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
938 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID | |
933 | 939 | && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) |
934 | 940 | { |
935 | 941 | tA2D_APTX_CIE aptx_config; |
@@ -1075,15 +1081,16 @@ static void btif_a2dp_data_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event) | ||
1075 | 1081 | static BOOLEAN btif_media_task_is_aptx_configured() |
1076 | 1082 | { |
1077 | 1083 | BOOLEAN result = FALSE; |
1078 | - UINT8 codectype = bta_av_get_current_codec(); | |
1079 | - | |
1080 | - if (codectype == A2D_NON_A2DP_MEDIA_CT) | |
1081 | - { | |
1082 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
1083 | - if (ptr) | |
1084 | - { | |
1085 | - tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
1086 | - if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) | |
1084 | + UINT8 codectype = bta_av_co_get_current_codec(); | |
1085 | + | |
1086 | + if (codectype == A2D_NON_A2DP_MEDIA_CT) { | |
1087 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
1088 | + if (ptr) { | |
1089 | + tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
1090 | + if ((codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) | |
1091 | + || (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH)) | |
1092 | + APPL_TRACE_DEBUG("%s codecId %d", __func__, codecInfo->codecId); | |
1093 | + APPL_TRACE_DEBUG("%s vendorId %x", __func__, codecInfo->vendorId); | |
1087 | 1094 | result = TRUE; |
1088 | 1095 | } |
1089 | 1096 | } |
@@ -1093,16 +1100,16 @@ static BOOLEAN btif_media_task_is_aptx_configured() | ||
1093 | 1100 | A2D_AptXCodecType btif_media_task_get_aptX_codec_type() |
1094 | 1101 | { |
1095 | 1102 | A2D_AptXCodecType codec = APTX_CODEC_NONE; |
1096 | - UINT8 a2dp_codectype = bta_av_get_current_codec(); | |
1103 | + UINT8 a2dp_codectype = bta_av_co_get_current_codec(); | |
1097 | 1104 | |
1098 | - if (a2dp_codectype == A2D_NON_A2DP_MEDIA_CT) | |
1099 | - { | |
1100 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
1101 | - if (ptr) | |
1102 | - { | |
1103 | - tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
1105 | + if (a2dp_codectype == A2D_NON_A2DP_MEDIA_CT) { | |
1106 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
1107 | + if (ptr) { | |
1108 | + tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
1104 | 1109 | if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) |
1105 | 1110 | codec = APTX_CODEC; |
1111 | + else if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) | |
1112 | + codec = APTX_HD_CODEC; | |
1106 | 1113 | } |
1107 | 1114 | } |
1108 | 1115 | return codec; |
@@ -1156,13 +1163,11 @@ static void btif_a2dp_encoder_init(tBTA_AV_HNDL hdl) | ||
1156 | 1163 | |
1157 | 1164 | UINT8 codectype; |
1158 | 1165 | codectype = bta_av_select_codec(hdl); |
1159 | - if (A2D_NON_A2DP_MEDIA_CT == codectype) | |
1160 | - { | |
1161 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
1162 | - if (ptr) | |
1163 | - { | |
1166 | + if (A2D_NON_A2DP_MEDIA_CT == codectype) { | |
1167 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
1168 | + if (ptr) { | |
1164 | 1169 | //tA2D_APTX_CIE starts on 4th byte |
1165 | - codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
1170 | + codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
1166 | 1171 | APPL_TRACE_DEBUG("%s codecId = %d", __func__, codecInfo->codecId); |
1167 | 1172 | APPL_TRACE_DEBUG("%s vendorId = %x", __func__, codecInfo->vendorId); |
1168 | 1173 |
@@ -1184,6 +1189,25 @@ static void btif_a2dp_encoder_init(tBTA_AV_HNDL hdl) | ||
1184 | 1189 | btif_media_task_enc_init_req(&msg); |
1185 | 1190 | return; |
1186 | 1191 | } |
1192 | + | |
1193 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID | |
1194 | + && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) | |
1195 | + { | |
1196 | + btif_media_cb.offset = BTIF_MEDIA_AA_APTX_HD_OFFSET; | |
1197 | + tA2D_APTX_HD_CIE aptx_hd_config; | |
1198 | + ALOGI("%s Selected Codec aptX HD", __func__); | |
1199 | + aptx_hd_config.vendorId = codecInfo->vendorId; | |
1200 | + aptx_hd_config.codecId = codecInfo->codecId; | |
1201 | + bta_av_co_audio_get_codec_config((UINT8*)&aptx_hd_config, &minmtu, A2D_NON_A2DP_MEDIA_CT); | |
1202 | + msg.CodecType = A2D_NON_A2DP_MEDIA_CT; | |
1203 | + msg.SamplingFreq = aptx_hd_config.sampleRate; | |
1204 | + msg.MtuSize = minmtu; | |
1205 | + msg.ChannelMode = aptx_hd_config.channelMode; | |
1206 | + msg.BluetoothVendorID = aptx_hd_config.vendorId; | |
1207 | + msg.BluetoothCodecID = aptx_hd_config.codecId; | |
1208 | + btif_media_task_enc_init_req(&msg); | |
1209 | + return; | |
1210 | + } | |
1187 | 1211 | } |
1188 | 1212 | }/* if ( A2D_NON_A2DP_MEDIA_CT == codectype) */ |
1189 | 1213 |
@@ -1236,13 +1260,13 @@ static void btif_a2dp_encoder_update(void) | ||
1236 | 1260 | APPL_TRACE_DEBUG("btif_a2dp_encoder_update"); |
1237 | 1261 | |
1238 | 1262 | UINT8 codectype = 0; |
1239 | - codectype = bta_av_get_current_codec(); | |
1263 | + codectype = bta_av_co_get_current_codec(); | |
1240 | 1264 | if (codectype == A2D_NON_A2DP_MEDIA_CT) |
1241 | 1265 | { |
1242 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
1266 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
1243 | 1267 | if (ptr) |
1244 | 1268 | { |
1245 | - codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
1269 | + codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
1246 | 1270 | if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) |
1247 | 1271 | { |
1248 | 1272 | APPL_TRACE_DEBUG("%s aptX", __func__); |
@@ -1254,6 +1278,18 @@ static void btif_a2dp_encoder_update(void) | ||
1254 | 1278 | msg.BluetoothVendorID = aptx_config.vendorId; |
1255 | 1279 | msg.BluetoothCodecID = aptx_config.codecId; |
1256 | 1280 | } |
1281 | + | |
1282 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) | |
1283 | + { | |
1284 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
1285 | + tA2D_APTX_HD_CIE aptx_hd_config; | |
1286 | + aptx_hd_config.vendorId = codecInfo->vendorId; | |
1287 | + aptx_hd_config.codecId = codecInfo->codecId; | |
1288 | + bta_av_co_audio_get_codec_config((UINT8*)&aptx_hd_config, &minmtu, A2D_NON_A2DP_MEDIA_CT ); | |
1289 | + msg.CodecType = A2D_NON_A2DP_MEDIA_CT; | |
1290 | + msg.BluetoothVendorID = aptx_hd_config.vendorId; | |
1291 | + msg.BluetoothCodecID = aptx_hd_config.codecId; | |
1292 | + } | |
1257 | 1293 | } /* if (ptr) */ |
1258 | 1294 | } |
1259 | 1295 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
@@ -1445,13 +1481,17 @@ tBTIF_STATUS btif_a2dp_setup_codec(tBTA_AV_HNDL hdl) | ||
1445 | 1481 | /* for now hardcode 48 khz 16 bit stereo PCM format */ |
1446 | 1482 | media_feeding.cfg.pcm.sampling_freq = 48000; |
1447 | 1483 | #else |
1448 | - /* for now hardcode 44.1 khz 16 bit stereo PCM format */ | |
1484 | + /* for now hardcode 44.1 khz 32 bit stereo PCM format */ | |
1449 | 1485 | media_feeding.cfg.pcm.sampling_freq = BTIF_A2DP_SRC_SAMPLING_RATE; |
1450 | 1486 | #endif |
1451 | 1487 | media_feeding.cfg.pcm.bit_per_sample = BTIF_A2DP_SRC_BIT_DEPTH; |
1452 | 1488 | media_feeding.cfg.pcm.num_channel = BTIF_A2DP_SRC_NUM_CHANNELS; |
1453 | 1489 | media_feeding.format = BTIF_AV_CODEC_PCM; |
1454 | 1490 | |
1491 | + /* 32 bits for AUDIO_FORMAT_PCM_8_24_BIT, all codecs affected. */ | |
1492 | + APPL_TRACE_EVENT("%s bit_per_sample %d", __func__, media_feeding.cfg.pcm.bit_per_sample); | |
1493 | + APPL_TRACE_EVENT("%s sampling_freq %d", __func__, media_feeding.cfg.pcm.sampling_freq); | |
1494 | + | |
1455 | 1495 | if (bta_av_co_audio_set_codec(&media_feeding, &status)) |
1456 | 1496 | { |
1457 | 1497 | tBTIF_MEDIA_INIT_AUDIO_FEEDING mfeed; |
@@ -1559,7 +1599,7 @@ void btif_a2dp_on_open(void) | ||
1559 | 1599 | *******************************************************************************/ |
1560 | 1600 | BOOLEAN btif_media_task_clear_track(void) |
1561 | 1601 | { |
1562 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
1602 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
1563 | 1603 | |
1564 | 1604 | p_buf->event = BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK; |
1565 | 1605 | if (btif_media_cmd_msg_queue != NULL) |
@@ -2006,7 +2046,7 @@ static void btif_media_thread_cleanup(UNUSED_ATTR void *context) { | ||
2006 | 2046 | *******************************************************************************/ |
2007 | 2047 | BOOLEAN btif_media_task_send_cmd_evt(UINT16 Evt) |
2008 | 2048 | { |
2009 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
2049 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
2010 | 2050 | |
2011 | 2051 | p_buf->event = Evt; |
2012 | 2052 |
@@ -2339,7 +2379,7 @@ BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p | ||
2339 | 2379 | *******************************************************************************/ |
2340 | 2380 | BOOLEAN btif_media_task_start_aa_req(void) |
2341 | 2381 | { |
2342 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
2382 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
2343 | 2383 | |
2344 | 2384 | p_buf->event = BTIF_MEDIA_START_AA_TX; |
2345 | 2385 |
@@ -2359,7 +2399,7 @@ BOOLEAN btif_media_task_start_aa_req(void) | ||
2359 | 2399 | *******************************************************************************/ |
2360 | 2400 | BOOLEAN btif_media_task_stop_aa_req(void) |
2361 | 2401 | { |
2362 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
2402 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
2363 | 2403 | |
2364 | 2404 | p_buf->event = BTIF_MEDIA_STOP_AA_TX; |
2365 | 2405 |
@@ -2392,7 +2432,7 @@ BOOLEAN btif_media_task_aa_rx_flush_req(void) | ||
2392 | 2432 | if (fixed_queue_is_empty(btif_media_cb.RxSbcQ)) /* Que is already empty */ |
2393 | 2433 | return TRUE; |
2394 | 2434 | |
2395 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
2435 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
2396 | 2436 | p_buf->event = BTIF_MEDIA_FLUSH_AA_RX; |
2397 | 2437 | |
2398 | 2438 | if (btif_media_cmd_msg_queue != NULL) |
@@ -2411,7 +2451,7 @@ BOOLEAN btif_media_task_aa_rx_flush_req(void) | ||
2411 | 2451 | *******************************************************************************/ |
2412 | 2452 | BOOLEAN btif_media_task_aa_tx_flush_req(void) |
2413 | 2453 | { |
2414 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
2454 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
2415 | 2455 | |
2416 | 2456 | p_buf->event = BTIF_MEDIA_FLUSH_AA_TX; |
2417 | 2457 |
@@ -2497,8 +2537,7 @@ static void btif_media_task_enc_init(BT_HDR *p_msg) | ||
2497 | 2537 | APPL_TRACE_EVENT("%s BluetoothVendorID %x, BluetoothCodecID %d", __func__, |
2498 | 2538 | pInitAudio->BluetoothVendorID, pInitAudio->BluetoothCodecID); |
2499 | 2539 | if ((pInitAudio->BluetoothVendorID == A2D_APTX_VENDOR_ID) |
2500 | - && (pInitAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */ | |
2501 | - { | |
2540 | + && (pInitAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) { | |
2502 | 2541 | btif_media_cb.aptxEncoderParams.s16SamplingFreq= pInitAudio->SamplingFreq; |
2503 | 2542 | btif_media_cb.aptxEncoderParams.s16ChannelMode = pInitAudio->ChannelMode; |
2504 | 2543 | btif_media_cb.aptxEncoderParams.u16PacketLength = 4; // 32-bit word encoded by aptX encoder |
@@ -2507,6 +2546,16 @@ static void btif_media_task_enc_init(BT_HDR *p_msg) | ||
2507 | 2546 | < pInitAudio->MtuSize) ? (BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_OFFSET |
2508 | 2547 | - sizeof(BT_HDR)) : pInitAudio->MtuSize; |
2509 | 2548 | return; |
2549 | + } else if ((pInitAudio->BluetoothVendorID == A2D_APTX_HD_VENDOR_ID) | |
2550 | + && (pInitAudio->BluetoothCodecID == A2D_APTX_HD_CODEC_ID_BLUETOOTH)) { | |
2551 | + btif_media_cb.aptxhdEncoderParams.s16SamplingFreq= pInitAudio->SamplingFreq; | |
2552 | + btif_media_cb.aptxhdEncoderParams.s16ChannelMode = pInitAudio->ChannelMode; | |
2553 | + btif_media_cb.aptxhdEncoderParams.u16PacketLength = 6; // 48-bit word encoded by aptX encoder | |
2554 | + btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_APTX_HD; | |
2555 | + btif_media_cb.TxAaMtuSize = ((BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_HD_OFFSET-sizeof(BT_HDR)) | |
2556 | + < pInitAudio->MtuSize) ? (BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_HD_OFFSET | |
2557 | + - sizeof(BT_HDR)) : pInitAudio->MtuSize; | |
2558 | + return; | |
2510 | 2559 | } else { |
2511 | 2560 | /* do nothing, fall through to SBC */ |
2512 | 2561 | } |
@@ -2586,13 +2635,18 @@ static void btif_media_task_enc_update(BT_HDR *p_msg) | ||
2586 | 2635 | pUpdateAudio->BluetoothVendorID, pUpdateAudio->BluetoothCodecID); |
2587 | 2636 | |
2588 | 2637 | if ((pUpdateAudio->BluetoothVendorID == A2D_APTX_VENDOR_ID) |
2589 | - && (pUpdateAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) /* aptX Classic */ | |
2590 | - { | |
2638 | + && (pUpdateAudio->BluetoothCodecID == A2D_APTX_CODEC_ID_BLUETOOTH)) { | |
2591 | 2639 | APPL_TRACE_DEBUG("%s aptX ", __func__); |
2592 | 2640 | btif_media_cb.TxAaMtuSize = ((BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_OFFSET - sizeof(BT_HDR)) < pUpdateAudio->MinMtuSize) ? |
2593 | 2641 | (BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_OFFSET - sizeof(BT_HDR)) : pUpdateAudio->MinMtuSize; |
2594 | 2642 | APPL_TRACE_DEBUG("%s : aptX btif_media_cb.TxAaMtuSize %d", __func__, btif_media_cb.TxAaMtuSize); |
2595 | 2643 | return; |
2644 | + } else if ((pUpdateAudio->BluetoothVendorID == A2D_APTX_HD_VENDOR_ID) | |
2645 | + && (pUpdateAudio->BluetoothCodecID == A2D_APTX_HD_CODEC_ID_BLUETOOTH)) { | |
2646 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
2647 | + btif_media_cb.TxAaMtuSize = ((BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_HD_OFFSET - sizeof(BT_HDR)) < pUpdateAudio->MinMtuSize) ? | |
2648 | + (BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_APTX_HD_OFFSET - sizeof(BT_HDR)) : pUpdateAudio->MinMtuSize; | |
2649 | + return; | |
2596 | 2650 | } else { |
2597 | 2651 | /* do nothing, fall through to SBC */ |
2598 | 2652 | } |
@@ -2832,6 +2886,80 @@ static void btif_media_task_pcm2sbc_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_feed | ||
2832 | 2886 | |
2833 | 2887 | /******************************************************************************* |
2834 | 2888 | ** |
2889 | + ** Function btif_media_task_pcm2aptx_hd_init | |
2890 | + ** | |
2891 | + ** Description Init encoding task for PCM to aptX according to feeding | |
2892 | + ** | |
2893 | + ** Returns void | |
2894 | + ** | |
2895 | + *******************************************************************************/ | |
2896 | +static void btif_media_task_pcm2aptx_hd_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_feeding) | |
2897 | +{ | |
2898 | + BOOLEAN reconfig_needed = FALSE; | |
2899 | + | |
2900 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
2901 | + APPL_TRACE_DEBUG("%s PCM feeding:", __func__); | |
2902 | + APPL_TRACE_DEBUG("%s sampling_freq:%d", __func__, p_feeding->feeding.cfg.pcm.sampling_freq); | |
2903 | + APPL_TRACE_DEBUG("%s num_channel:%d", __func__, p_feeding->feeding.cfg.pcm.num_channel); | |
2904 | + APPL_TRACE_DEBUG("%s bit_per_sample:%d", __func__, p_feeding->feeding.cfg.pcm.bit_per_sample); | |
2905 | + | |
2906 | + /* Check the PCM feeding sampling_freq */ | |
2907 | + switch (p_feeding->feeding.cfg.pcm.sampling_freq) | |
2908 | + { | |
2909 | + case 8000: | |
2910 | + case 12000: | |
2911 | + case 16000: | |
2912 | + case 24000: | |
2913 | + case 32000: | |
2914 | + case 48000: | |
2915 | + /* For these sampling_freq the AV connection must be 48000 */ | |
2916 | + if (btif_media_cb.aptxhdEncoderParams.s16SamplingFreq != A2D_APTX_HD_SAMPLERATE_48000) | |
2917 | + { | |
2918 | + /* Reconfiguration needed at 48000 */ | |
2919 | + APPL_TRACE_DEBUG("%s Reconfiguration needed at 48000", __func__); | |
2920 | + btif_media_cb.aptxhdEncoderParams.s16SamplingFreq = A2D_APTX_HD_SAMPLERATE_48000; | |
2921 | + reconfig_needed = TRUE; | |
2922 | + } | |
2923 | + break; | |
2924 | + | |
2925 | + case 11025: | |
2926 | + case 22050: | |
2927 | + case 44100: | |
2928 | + /* For these sampling_freq the AV connection must be 44100 */ | |
2929 | + if (btif_media_cb.aptxhdEncoderParams.s16SamplingFreq != A2D_APTX_HD_SAMPLERATE_44100) | |
2930 | + { | |
2931 | + /* Reconfiguration needed at 44100 */ | |
2932 | + APPL_TRACE_DEBUG("%s Reconfiguration needed at 44100", __func__); | |
2933 | + btif_media_cb.aptxhdEncoderParams.s16SamplingFreq = A2D_APTX_HD_SAMPLERATE_44100; | |
2934 | + reconfig_needed = TRUE; | |
2935 | + } | |
2936 | + break; | |
2937 | + default: | |
2938 | + APPL_TRACE_DEBUG("%s Feeding PCM sampling_freq unsupported", __func__); | |
2939 | + break; | |
2940 | + } | |
2941 | + | |
2942 | + /* Some AV Headsets do not support Mono => always ask for Stereo */ | |
2943 | + if (btif_media_cb.aptxhdEncoderParams.s16ChannelMode == A2D_APTX_HD_CHANNELS_MONO) | |
2944 | + { | |
2945 | + APPL_TRACE_DEBUG("%s Reconfiguration needed in Stereo", __func__); | |
2946 | + btif_media_cb.aptxhdEncoderParams.s16ChannelMode = A2D_APTX_HD_CHANNELS_STEREO; | |
2947 | + reconfig_needed = TRUE; | |
2948 | + } | |
2949 | + | |
2950 | + if (reconfig_needed != FALSE) | |
2951 | + { | |
2952 | + APPL_TRACE_DEBUG("%s calls APTX_HD_Encoder_Init", __func__); | |
2953 | + APPL_TRACE_DEBUG("%s mtu %d", __func__, btif_media_cb.TxAaMtuSize); | |
2954 | + APPL_TRACE_DEBUG("%s ch mode %d, Smp freq %d", __func__, | |
2955 | + btif_media_cb.aptxhdEncoderParams.s16ChannelMode, btif_media_cb.aptxhdEncoderParams.s16SamplingFreq); | |
2956 | + } else { | |
2957 | + APPL_TRACE_DEBUG("%s No aptX HD reconfig needed", __func__); | |
2958 | + } | |
2959 | +} | |
2960 | + | |
2961 | +/******************************************************************************* | |
2962 | + ** | |
2835 | 2963 | ** Function btif_media_task_pcm2aptx_init |
2836 | 2964 | ** |
2837 | 2965 | ** Description Init encoding task for PCM to aptX according to feeding |
@@ -2928,30 +3056,31 @@ static void btif_media_task_audio_feeding_init(BT_HDR *p_msg) | ||
2928 | 3056 | case BTIF_AV_CODEC_PCM: |
2929 | 3057 | { |
2930 | 3058 | UINT8 codectype; |
2931 | - codectype = bta_av_get_current_codec(); | |
3059 | + codectype = bta_av_co_get_current_codec(); | |
3060 | + | |
3061 | + if (A2D_NON_A2DP_MEDIA_CT == codectype) { | |
3062 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
3063 | + if (ptr) { | |
3064 | + // tA2D_APTX_CIE starts on 4th byte | |
3065 | + codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
3066 | + if (codecInfo) { | |
3067 | + APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecInfo->codecId); | |
3068 | + APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, codecInfo->vendorId); | |
3069 | + } | |
2932 | 3070 | |
2933 | - if (A2D_NON_A2DP_MEDIA_CT == codectype) | |
2934 | - { | |
2935 | - UINT8* ptr = bta_av_get_current_codecInfo(); | |
2936 | - if (ptr) | |
2937 | - { | |
2938 | - // tA2D_APTX_CIE starts on 4th byte | |
2939 | - codecInfo = (tA2D_APTX_CIE*) &ptr[3]; | |
2940 | - if (codecInfo) | |
2941 | - { | |
2942 | - APPL_TRACE_DEBUG("%s codecId = %d ", __func__, codecInfo->codecId); | |
2943 | - APPL_TRACE_DEBUG("%s vendorId = %x ", __func__, codecInfo->vendorId); | |
2944 | - } | |
2945 | - | |
2946 | - if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) /* aptX Classic */ | |
2947 | - { | |
2948 | - APPL_TRACE_DEBUG("%s aptX", __func__); | |
2949 | - btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_APTX; | |
2950 | - btif_media_task_pcm2aptx_init(p_feeding); | |
2951 | - break; | |
2952 | - } else { | |
2953 | - /* do nothing, fall through to SBC */ | |
2954 | - } | |
3071 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) { | |
3072 | + APPL_TRACE_DEBUG("%s aptX", __func__); | |
3073 | + btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_APTX; | |
3074 | + btif_media_task_pcm2aptx_init(p_feeding); | |
3075 | + break; | |
3076 | + } else if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) { | |
3077 | + APPL_TRACE_DEBUG("%s aptX HD", __func__); | |
3078 | + btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_APTX_HD; | |
3079 | + btif_media_task_pcm2aptx_hd_init(p_feeding); | |
3080 | + break; | |
3081 | + } else { | |
3082 | + /* do nothing, fall through to SBC */ | |
3083 | + } | |
2955 | 3084 | } |
2956 | 3085 | } |
2957 | 3086 |
@@ -3249,6 +3378,12 @@ int btif_media_task_cb_packet_send(uint8_t* packet, int length, int pcm_bytes_en | ||
3249 | 3378 | { |
3250 | 3379 | int bytes_per_frame = 2; |
3251 | 3380 | uint64_t timestamp_us = 0; |
3381 | + UINT8 codectype; | |
3382 | + codectype = bta_av_co_get_current_codec(); | |
3383 | + | |
3384 | + if (btif_media_task_get_aptX_codec_type() == APTX_HD_CODEC) { | |
3385 | + bytes_per_frame = 3; | |
3386 | + } | |
3252 | 3387 | |
3253 | 3388 | if (length > 0 ) { |
3254 | 3389 |
@@ -3267,7 +3402,7 @@ int btif_media_task_cb_packet_send(uint8_t* packet, int length, int pcm_bytes_en | ||
3267 | 3402 | osi_free(fixed_queue_try_dequeue(btif_media_cb.TxAaQ)); |
3268 | 3403 | } |
3269 | 3404 | |
3270 | - BT_HDR *p_buf = osi_malloc(BTIF_MEDIA_AA_BUF_SIZE); | |
3405 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(BTIF_MEDIA_AA_BUF_SIZE); | |
3271 | 3406 | |
3272 | 3407 | int rtpTimestamp = (pcm_bytes_encoded / btif_media_cb.media_feeding.cfg.pcm.num_channel / bytes_per_frame); |
3273 | 3408 |
@@ -3340,7 +3475,7 @@ static void btif_media_task_aa_start_tx(void) | ||
3340 | 3475 | BOOLEAN use_SCMS_T = false; |
3341 | 3476 | #endif |
3342 | 3477 | A2D_AptXCodecType aptX_codec_type = btif_media_task_get_aptX_codec_type(); |
3343 | - BOOLEAN is_24bit_audio = false; | |
3478 | + BOOLEAN is_24bit_audio = true; | |
3344 | 3479 | |
3345 | 3480 | BOOLEAN test = false; |
3346 | 3481 | BOOLEAN trace = false; |
@@ -3743,7 +3878,7 @@ UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt) | ||
3743 | 3878 | BT_HDR *btif_media_aa_readbuf(void) |
3744 | 3879 | { |
3745 | 3880 | uint64_t now_us = time_now_us(); |
3746 | - BT_HDR *p_buf = fixed_queue_try_dequeue(btif_media_cb.TxAaQ); | |
3881 | + BT_HDR *p_buf = (BT_HDR *)fixed_queue_try_dequeue(btif_media_cb.TxAaQ); | |
3747 | 3882 | |
3748 | 3883 | btif_media_cb.stats.tx_queue_total_readbuf_calls++; |
3749 | 3884 | btif_media_cb.stats.tx_queue_last_readbuf_us = now_us; |
@@ -3777,9 +3912,9 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id) | ||
3777 | 3912 | UINT16 bytes_needed = blocm_x_subband * btif_media_cb.encoder.s16NumOfChannels * \ |
3778 | 3913 | btif_media_cb.media_feeding.cfg.pcm.bit_per_sample / 8; |
3779 | 3914 | static UINT16 up_sampled_buffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS |
3780 | - * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * 2]; | |
3915 | + * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * 4]; | |
3781 | 3916 | static UINT16 read_buffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS |
3782 | - * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; | |
3917 | + * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * 2]; | |
3783 | 3918 | UINT32 src_size_used; |
3784 | 3919 | UINT32 dst_size_used; |
3785 | 3920 | BOOLEAN fract_needed; |
@@ -3810,7 +3945,7 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id) | ||
3810 | 3945 | if (sbc_sampling == btif_media_cb.media_feeding.cfg.pcm.sampling_freq) { |
3811 | 3946 | read_size = bytes_needed - btif_media_cb.media_feeding_state.pcm.aa_feed_residue; |
3812 | 3947 | nb_byte_read = UIPC_Read(channel_id, &event, |
3813 | - ((UINT8 *)btif_media_cb.encoder.as16PcmBuffer) + | |
3948 | + ((UINT8 *)btif_media_cb.encoder.as32PcmBuffer) + | |
3814 | 3949 | btif_media_cb.media_feeding_state.pcm.aa_feed_residue, |
3815 | 3950 | read_size); |
3816 | 3951 | if (nb_byte_read == read_size) { |
@@ -3929,7 +4064,7 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id) | ||
3929 | 4064 | if(btif_media_cb.media_feeding_state.pcm.aa_feed_residue >= bytes_needed) |
3930 | 4065 | { |
3931 | 4066 | /* Copy the output pcm samples in SBC encoding buffer */ |
3932 | - memcpy((UINT8 *)btif_media_cb.encoder.as16PcmBuffer, | |
4067 | + memcpy((UINT8 *)btif_media_cb.encoder.as32PcmBuffer, | |
3933 | 4068 | (UINT8 *)up_sampled_buffer, |
3934 | 4069 | bytes_needed); |
3935 | 4070 | /* update the residue */ |
@@ -3964,7 +4099,7 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame, | ||
3964 | 4099 | btif_media_cb.encoder.s16NumOfBlocks; |
3965 | 4100 | |
3966 | 4101 | while (nb_frame) { |
3967 | - BT_HDR *p_buf = osi_malloc(BTIF_MEDIA_AA_BUF_SIZE); | |
4102 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(BTIF_MEDIA_AA_BUF_SIZE); | |
3968 | 4103 | |
3969 | 4104 | /* Init buffer */ |
3970 | 4105 | p_buf->offset = BTIF_MEDIA_AA_SBC_OFFSET; |
@@ -3976,12 +4111,14 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame, | ||
3976 | 4111 | /* Write @ of allocated buffer in encoder.pu8Packet */ |
3977 | 4112 | btif_media_cb.encoder.pu8Packet = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len; |
3978 | 4113 | /* Fill allocated buffer with 0 */ |
3979 | - memset(btif_media_cb.encoder.as16PcmBuffer, 0, blocm_x_subband | |
3980 | - * btif_media_cb.encoder.s16NumOfChannels); | |
4114 | + memset(btif_media_cb.encoder.as32PcmBuffer, 0, blocm_x_subband | |
4115 | + * btif_media_cb.encoder.s16NumOfChannels * 2); | |
3981 | 4116 | |
3982 | 4117 | /* Read PCM data and upsample them if needed */ |
3983 | 4118 | if (btif_media_aa_read_feeding(UIPC_CH_ID_AV_AUDIO)) |
3984 | 4119 | { |
4120 | + size_t frames = blocm_x_subband * btif_media_cb.encoder.s16NumOfChannels; | |
4121 | + memcpy_by_audio_format(btif_media_cb.encoder.as16PcmBuffer, AUDIO_FORMAT_PCM_16_BIT, btif_media_cb.encoder.as32PcmBuffer, AUDIO_FORMAT_PCM_8_24_BIT, frames); | |
3985 | 4122 | SBC_Encoder(&(btif_media_cb.encoder)); |
3986 | 4123 | |
3987 | 4124 | /* Update SBC frame length */ |
@@ -4199,7 +4336,7 @@ void disconnect_a2dp_on_vendor_start_failure() | ||
4199 | 4336 | |
4200 | 4337 | void btif_media_send_reset_vendor_state() |
4201 | 4338 | { |
4202 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
4339 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4203 | 4340 | |
4204 | 4341 | p_buf->event = BTIF_MEDIA_RESET_VS_STATE; |
4205 | 4342 | if (btif_media_cmd_msg_queue != NULL) |
@@ -4227,7 +4364,7 @@ void btif_media_start_vendor_command() | ||
4227 | 4364 | |
4228 | 4365 | void btif_media_on_start_vendor_command() |
4229 | 4366 | { |
4230 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
4367 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4231 | 4368 | |
4232 | 4369 | p_buf->event = BTIF_MEDIA_START_VS_CMD; |
4233 | 4370 | if (btif_media_cmd_msg_queue != NULL) |
@@ -4236,7 +4373,7 @@ void btif_media_on_start_vendor_command() | ||
4236 | 4373 | |
4237 | 4374 | void btif_media_on_stop_vendor_command() |
4238 | 4375 | { |
4239 | - BT_HDR *p_buf = osi_malloc(sizeof(BT_HDR)); | |
4376 | + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4240 | 4377 | |
4241 | 4378 | APPL_TRACE_IMP("btif_media_on_stop_vendor_command"); |
4242 | 4379 | p_buf->event = BTIF_MEDIA_STOP_VS_CMD; |
@@ -4255,7 +4392,7 @@ void btif_media_a2dp_start_cb(tBTM_VSC_CMPL *param) | ||
4255 | 4392 | } |
4256 | 4393 | APPL_TRACE_IMP("VS_QHCI_START_A2DP_MEDIA sent with error code: %u", status); |
4257 | 4394 | |
4258 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4395 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4259 | 4396 | |
4260 | 4397 | if (!status) |
4261 | 4398 | p_buf->event = BTIF_MEDIA_VS_A2DP_START_SUCCESS; |
@@ -4300,7 +4437,7 @@ void btif_media_a2dp_stop_cb(tBTM_VSC_CMPL *param) | ||
4300 | 4437 | } |
4301 | 4438 | APPL_TRACE_IMP("VS_QHCI_STOP_A2DP_MEDIA sent with error code: %u", status); |
4302 | 4439 | |
4303 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4440 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4304 | 4441 | |
4305 | 4442 | if (!status) |
4306 | 4443 | p_buf->event = BTIF_MEDIA_VS_A2DP_STOP_SUCCESS; |
@@ -4348,7 +4485,7 @@ void btif_media_selected_codec_cb(tBTM_VSC_CMPL *param) | ||
4348 | 4485 | |
4349 | 4486 | if (!status) |
4350 | 4487 | { |
4351 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4488 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4352 | 4489 | p_buf->event = BTIF_MEDIA_VS_A2DP_SELECTED_CODEC_SUCCESS; |
4353 | 4490 | if (btif_media_cmd_msg_queue != NULL) |
4354 | 4491 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -4365,11 +4502,11 @@ void btif_media_selected_codec_cb(tBTM_VSC_CMPL *param) | ||
4365 | 4502 | |
4366 | 4503 | BOOLEAN btif_media_send_vendor_selected_codec() |
4367 | 4504 | { |
4368 | - UINT8 param[12], codec_type = A2DP_CODEC_SBC;//bta_av_get_current_code(); | |
4505 | + UINT8 param[12], codec_type = A2DP_CODEC_SBC; | |
4369 | 4506 | UINT16 index = 0; |
4370 | 4507 | |
4371 | - codec_type = bta_av_get_current_codec(); | |
4372 | - if (codec_type == 0xFF) | |
4508 | + codec_type = bta_av_co_get_current_codec(); | |
4509 | + if (codec_type == A2D_NON_A2DP_MEDIA_CT) | |
4373 | 4510 | codec_type = A2DP_CODEC_APTX; |
4374 | 4511 | |
4375 | 4512 | APPL_TRACE_IMP("btif_media_send_selected_codec: codec: %d", codec_type); |
@@ -4408,7 +4545,7 @@ void btif_media_transport_cfg_cb(tBTM_VSC_CMPL *param) | ||
4408 | 4545 | |
4409 | 4546 | if (!status) |
4410 | 4547 | { |
4411 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4548 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4412 | 4549 | p_buf->event = BTIF_MEDIA_VS_A2DP_TRANSPORT_CFG_SUCCESS; |
4413 | 4550 | if (btif_media_cmd_msg_queue != NULL) |
4414 | 4551 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -4425,11 +4562,11 @@ void btif_media_transport_cfg_cb(tBTM_VSC_CMPL *param) | ||
4425 | 4562 | BOOLEAN btif_media_send_vendor_transport_cfg() |
4426 | 4563 | { |
4427 | 4564 | UINT8 param[3]; |
4428 | - UINT8 codec_type = bta_av_get_current_codec(); | |
4565 | + UINT8 codec_type = bta_av_co_get_current_codec(); | |
4429 | 4566 | UINT8 stream_type; |
4430 | 4567 | APPL_TRACE_IMP("btif_media_send_vendor_transport_cfg: codec: %d", codec_type); |
4431 | 4568 | stream_type = codec_type; |
4432 | - if (codec_type == 0xFF) | |
4569 | + if (codec_type == A2D_NON_A2DP_MEDIA_CT) | |
4433 | 4570 | stream_type = A2DP_TRANSPORT_STREAM_TYPE_APTX; |
4434 | 4571 | param[0] = VS_QHCI_A2DP_TRANSPORT_CONFIGURATION; |
4435 | 4572 | param[1] = A2DP_TRANSPORT_TYPE_SLIMBUS; |
@@ -4453,7 +4590,7 @@ void btif_media_a2dp_media_chn_cfg_cb(tBTM_VSC_CMPL *param) | ||
4453 | 4590 | |
4454 | 4591 | if (!status) |
4455 | 4592 | { |
4456 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4593 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4457 | 4594 | p_buf->event = BTIF_MEDIA_VS_A2DP_MEDIA_CHNL_CFG_SUCCESS; |
4458 | 4595 | if (btif_media_cmd_msg_queue != NULL) |
4459 | 4596 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -4506,7 +4643,7 @@ void btif_media_a2dp_write_sbc_cfg_cb(tBTM_VSC_CMPL *param) | ||
4506 | 4643 | |
4507 | 4644 | if (!status) |
4508 | 4645 | { |
4509 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4646 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4510 | 4647 | p_buf->event = BTIF_MEDIA_VS_A2DP_WRITE_SBC_CFG_SUCCESS; |
4511 | 4648 | if (btif_media_cmd_msg_queue != NULL) |
4512 | 4649 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -4576,7 +4713,7 @@ void btif_media_pref_bit_rate_cb(tBTM_VSC_CMPL *param) | ||
4576 | 4713 | |
4577 | 4714 | if (!status) |
4578 | 4715 | { |
4579 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4716 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4580 | 4717 | p_buf->event = BTIF_MEDIA_VS_A2DP_PREF_BIT_RATE_SUCCESS; |
4581 | 4718 | if (btif_media_cmd_msg_queue != NULL) |
4582 | 4719 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -4618,7 +4755,7 @@ void btif_media_scmst_cb(tBTM_VSC_CMPL *param) | ||
4618 | 4755 | |
4619 | 4756 | if (!status) |
4620 | 4757 | { |
4621 | - p_buf = osi_malloc(sizeof(BT_HDR)); | |
4758 | + p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR)); | |
4622 | 4759 | p_buf->event = BTIF_MEDIA_VS_A2DP_SET_SCMST_HDR_SUCCESS; |
4623 | 4760 | if (btif_media_cmd_msg_queue != NULL) |
4624 | 4761 | fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf); |
@@ -401,7 +401,6 @@ extern BOOLEAN btif_av_is_playing(); | ||
401 | 401 | extern BOOLEAN btif_av_is_device_connected(BD_ADDR address); |
402 | 402 | extern void btif_av_trigger_dual_handoff(BOOLEAN handoff, BD_ADDR address); |
403 | 403 | extern BOOLEAN btif_hf_is_call_idle(); |
404 | -extern BOOLEAN btif_av_get_multicast_state(); | |
405 | 404 | extern BOOLEAN btif_av_is_current_device(BD_ADDR address); |
406 | 405 | extern UINT16 btif_av_get_num_connected_devices(void); |
407 | 406 | extern UINT16 btif_av_get_num_playing_devices(void); |
@@ -175,6 +175,7 @@ typedef struct SBC_ENC_PARAMS_TAG | ||
175 | 175 | SINT16 *ps16PcmBuffer; |
176 | 176 | #else |
177 | 177 | SINT16 as16PcmBuffer[SBC_MAX_NUM_FRAME*SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; |
178 | + SINT32 as32PcmBuffer[SBC_MAX_NUM_FRAME*SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; | |
178 | 179 | #endif |
179 | 180 | |
180 | 181 | SINT16 s16ScartchMemForBitAlloc[16]; |
@@ -1,4 +1,4 @@ | ||
1 | -/****************************************************************************** | |
1 | + /****************************************************************************** | |
2 | 2 | * Copyright (c) 2016, The Linux Foundation. All rights reserved. |
3 | 3 | * |
4 | 4 | * Not a contribution. |
@@ -138,7 +138,7 @@ | ||
138 | 138 | #endif |
139 | 139 | |
140 | 140 | #ifndef BTIF_A2DP_SRC_BIT_DEPTH |
141 | -#define BTIF_A2DP_SRC_BIT_DEPTH 16 | |
141 | +#define BTIF_A2DP_SRC_BIT_DEPTH 32 | |
142 | 142 | #endif |
143 | 143 | |
144 | 144 | #ifndef BTIF_A2DP_SRC_NUM_CHANNELS |
@@ -1210,9 +1210,9 @@ | ||
1210 | 1210 | */ |
1211 | 1211 | #ifndef AVDT_NUM_SEPS |
1212 | 1212 | #if defined(AAC_ENCODER_INCLUDED) && (AAC_ENCODER_INCLUDED == TRUE) |
1213 | -#define AVDT_NUM_SEPS 7 | |
1213 | +#define AVDT_NUM_SEPS 9 | |
1214 | 1214 | #else |
1215 | -#define AVDT_NUM_SEPS 5 | |
1215 | +#define AVDT_NUM_SEPS 7 | |
1216 | 1216 | #endif |
1217 | 1217 | #endif |
1218 | 1218 |
@@ -53,7 +53,8 @@ LOCAL_C_INCLUDES+= . \ | ||
53 | 53 | $(LOCAL_PATH)/../utils/include \ |
54 | 54 | $(bluetooth_C_INCLUDES) \ |
55 | 55 | external/tinyxml2 \ |
56 | - external/zlib | |
56 | + external/zlib \ | |
57 | + $(call include-path-for, audio-utils) | |
57 | 58 | |
58 | 59 | LOCAL_SHARED_LIBRARIES := \ |
59 | 60 | libcutils \ |
@@ -64,7 +65,8 @@ LOCAL_SHARED_LIBRARIES := \ | ||
64 | 65 | libprotobuf-cpp-full \ |
65 | 66 | libmedia \ |
66 | 67 | libutils \ |
67 | - libchrome | |
68 | + libchrome \ | |
69 | + libaudioutils | |
68 | 70 | |
69 | 71 | LOCAL_STATIC_LIBRARIES := \ |
70 | 72 | libtinyxml2 \ |
@@ -39,6 +39,7 @@ LOCAL_SRC_FILES:= \ | ||
39 | 39 | ./a2dp/a2d_api.c \ |
40 | 40 | ./a2dp/a2d_sbc.c \ |
41 | 41 | ./a2dp/a2d_aptx.c \ |
42 | + ./a2dp/a2d_aptx_hd.c \ | |
42 | 43 | ./a2dp/a2d_aac.c \ |
43 | 44 | ./avrc/avrc_api.c \ |
44 | 45 | ./avrc/avrc_sdp.c \ |
@@ -44,6 +44,7 @@ | ||
44 | 44 | #include "a2d_api.h" |
45 | 45 | #include "a2d_int.h" |
46 | 46 | #include "a2d_aptx.h" |
47 | +#include "a2d_aptx_hd.h" | |
47 | 48 | #include <utils/Log.h> |
48 | 49 | |
49 | 50 | const char* A2D_APTX_SCHED_LIB_NAME = "libaptXScheduler.so"; |
@@ -277,19 +278,45 @@ void A2D_deinit_aptX(void) | ||
277 | 278 | |
278 | 279 | if (isA2dAptXEnabled && A2dAptXSchedLibHandle) |
279 | 280 | { |
280 | - // remove aptX thread | |
281 | - if (A2d_aptx_thread) | |
282 | - { | |
283 | - A2D_aptx_sched_stop(); | |
284 | - thread_free(A2d_aptx_thread); | |
285 | - A2d_aptx_thread = NULL; | |
286 | - } | |
287 | - | |
288 | - A2D_aptx_encoder_deinit(); | |
289 | - dlclose(A2dAptXSchedLibHandle); | |
290 | - A2dAptXSchedLibHandle = NULL; | |
291 | - isA2dAptXEnabled = false; | |
281 | + A2D_aptx_encoder_deinit(); | |
282 | + isA2dAptXEnabled = false; | |
283 | + } | |
284 | + | |
285 | + return; | |
286 | +} | |
287 | + | |
288 | +/******************************************************************************* | |
289 | +** | |
290 | +** Function A2D_close_aptX | |
291 | +** | |
292 | +** Description This function close aptX | |
293 | +** | |
294 | +** Returns Nothing | |
295 | +** | |
296 | +*******************************************************************************/ | |
297 | +void A2D_close_aptX(void) | |
298 | +{ | |
299 | + A2D_TRACE_DEBUG("%s", __func__); | |
300 | + | |
301 | + if (A2dAptXSchedLibHandle) | |
302 | + { | |
303 | + // remove aptX thread | |
304 | + if (A2d_aptx_thread) | |
305 | + { | |
306 | + A2D_aptx_sched_stop(); | |
307 | + thread_free(A2d_aptx_thread); | |
308 | + A2d_aptx_thread = NULL; | |
309 | + } | |
292 | 310 | } |
293 | 311 | |
312 | + // de-initialize aptX HD | |
313 | + A2D_deinit_aptX_HD(); | |
314 | + | |
315 | + // de-initialize aptX | |
316 | + A2D_deinit_aptX(); | |
317 | + | |
318 | + dlclose(A2dAptXSchedLibHandle); | |
319 | + A2dAptXSchedLibHandle = NULL; | |
320 | + | |
294 | 321 | return; |
295 | 322 | } |
@@ -0,0 +1,251 @@ | ||
1 | +/****************************************************************************** | |
2 | + | |
3 | + Copyright (c) 2016, The Linux Foundation. All rights reserved. | |
4 | + | |
5 | + Redistribution and use in source and binary forms, with or without | |
6 | + modification, are permitted provided that the following conditions are | |
7 | + met: | |
8 | + * Redistributions of source code must retain the above copyright | |
9 | + notice, this list of conditions and the following disclaimer. | |
10 | + * Redistributions in binary form must reproduce the above | |
11 | + copyright notice, this list of conditions and the following | |
12 | + disclaimer in the documentation and/or other materials provided | |
13 | + with the distribution. | |
14 | + * Neither the name of The Linux Foundation nor the names of its | |
15 | + contributors may be used to endorse or promote products derived | |
16 | + from this software without specific prior written permission. | |
17 | + | |
18 | + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | |
19 | + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
20 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | |
21 | + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | |
22 | + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
23 | + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
24 | + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
25 | + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
26 | + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
27 | + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | |
28 | + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | + | |
30 | + ******************************************************************************/ | |
31 | +/****************************************************************************** | |
32 | + | |
33 | + Utility functions to help build and parse the aptX HD Codec Information | |
34 | + Element and Media Payload. | |
35 | + | |
36 | +******************************************************************************/ | |
37 | + | |
38 | +#include "bt_target.h" | |
39 | + | |
40 | +#include <string.h> | |
41 | +#include <dlfcn.h> | |
42 | +#include "osi/include/thread.h" | |
43 | +#include "bt_utils.h" | |
44 | +#include "a2d_api.h" | |
45 | +#include "a2d_int.h" | |
46 | +#include "a2d_aptx.h" | |
47 | +#include "a2d_aptx_hd.h" | |
48 | +#include <utils/Log.h> | |
49 | + | |
50 | + | |
51 | +BOOLEAN isA2dAptXHdEnabled = FALSE; | |
52 | + | |
53 | +int (*A2D_aptx_hd_encoder_init)(void); | |
54 | +void (*A2D_aptx_hd_encoder_deinit)(void); | |
55 | + | |
56 | +/****************************************************************************** | |
57 | +** | |
58 | +** Function A2D_BldAptx_hdInfo | |
59 | +** | |
60 | +******************************************************************************/ | |
61 | +UINT8 A2D_BldAptx_hdInfo(UINT8 media_type, tA2D_APTX_HD_CIE *p_ie, UINT8 *p_result) | |
62 | +{ | |
63 | + A2D_TRACE_API("%s: - MediaType:%d", __func__, media_type); | |
64 | + | |
65 | + UINT8 status = 0; | |
66 | + status = A2D_SUCCESS; | |
67 | + *p_result++ = A2D_APTX_HD_CODEC_LEN; | |
68 | + *p_result++ = media_type; | |
69 | + *p_result++ = A2D_NON_A2DP_MEDIA_CT; | |
70 | + *p_result++ = (UINT8)(p_ie->vendorId & 0x000000FF); | |
71 | + *p_result++ = (UINT8)(p_ie->vendorId & 0x0000FF00)>> 8; | |
72 | + *p_result++ = (UINT8)(p_ie->vendorId & 0x00FF0000)>> 16; | |
73 | + *p_result++ = (UINT8)(p_ie->vendorId & 0xFF000000)>> 24; | |
74 | + *p_result++ = (UINT8)(p_ie->codecId & 0x00FF); | |
75 | + *p_result++ = (UINT8)(p_ie->codecId & 0xFF00) >> 8; | |
76 | + *p_result++ = p_ie->sampleRate | p_ie->channelMode; | |
77 | + *p_result++ = p_ie->acl_sprint_reserved0; | |
78 | + *p_result++ = p_ie->acl_sprint_reserved1; | |
79 | + *p_result++ = p_ie->acl_sprint_reserved2; | |
80 | + *p_result++ = p_ie->acl_sprint_reserved3; | |
81 | + return status; | |
82 | +} | |
83 | + | |
84 | +/****************************************************************************** | |
85 | +** | |
86 | +** Function A2D_ParsAptx_hdInfo | |
87 | +** | |
88 | +******************************************************************************/ | |
89 | +tA2D_STATUS A2D_ParsAptx_hdInfo(tA2D_APTX_HD_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps) | |
90 | +{ | |
91 | + tA2D_STATUS status; | |
92 | + UINT8 losc; | |
93 | + UINT8 mt; | |
94 | + | |
95 | + A2D_TRACE_API("%s: - MediaType:%d", __func__, for_caps); | |
96 | + | |
97 | + if (p_ie == NULL || p_info == NULL) | |
98 | + { | |
99 | + A2D_TRACE_ERROR("A2D_ParsAptx_hdInfo - Invalid Params"); | |
100 | + status = A2D_INVALID_PARAMS; | |
101 | + } | |
102 | + else | |
103 | + { | |
104 | + losc = *p_info++; | |
105 | + mt = *p_info++; | |
106 | + A2D_TRACE_DEBUG("%s: losc %d, mt %02x", __func__, losc, mt); | |
107 | + | |
108 | + /* If the function is called for the wrong Media Type or Media Codec Type */ | |
109 | + if (losc != A2D_APTX_HD_CODEC_LEN || *p_info != A2D_NON_A2DP_MEDIA_CT) { | |
110 | + A2D_TRACE_ERROR("%s: wrong media type %02x", __func__, *p_info); | |
111 | + status = A2D_WRONG_CODEC; | |
112 | + } | |
113 | + else | |
114 | + { | |
115 | + p_info++; | |
116 | + p_ie->vendorId = (*p_info & 0x000000FF) | | |
117 | + (*(p_info+1) << 8 & 0x0000FF00) | | |
118 | + (*(p_info+2) << 16 & 0x00FF0000) | | |
119 | + (*(p_info+3) << 24 & 0xFF000000); | |
120 | + p_info = p_info+4; | |
121 | + p_ie->codecId = (*p_info & 0x00FF) | (*(p_info+1) << 8 & 0xFF00); | |
122 | + p_info = p_info+2; | |
123 | + p_ie->channelMode= *p_info & 0x0F; | |
124 | + p_ie->sampleRate = *p_info & 0xF0; | |
125 | + p_info = p_info+1; | |
126 | + p_ie->acl_sprint_reserved0 = *(p_info ++); | |
127 | + p_ie->acl_sprint_reserved1 = *(p_info ++); | |
128 | + p_ie->acl_sprint_reserved2 = *(p_info ++); | |
129 | + p_ie->acl_sprint_reserved3 = *(p_info ++); | |
130 | + | |
131 | + status = A2D_SUCCESS; | |
132 | + | |
133 | + if (for_caps == FALSE) | |
134 | + { | |
135 | + if (A2D_BitsSet(p_ie->sampleRate) != A2D_SET_ONE_BIT) | |
136 | + status = A2D_BAD_SAMP_FREQ; | |
137 | + if (A2D_BitsSet(p_ie->channelMode) != A2D_SET_ONE_BIT) | |
138 | + status = A2D_BAD_CH_MODE; | |
139 | + } | |
140 | + } | |
141 | + } | |
142 | + return status; | |
143 | +} | |
144 | + | |
145 | +/******************************************************************************* | |
146 | +** | |
147 | +** Function a2d_av_aptx_hd_cfg_in_cap | |
148 | +** | |
149 | +** Description This function checks whether an aptX HD codec configuration | |
150 | +** is allowable for the given codec capabilities. | |
151 | +** | |
152 | +** Returns 0 if ok, nonzero if error. | |
153 | +** | |
154 | +*******************************************************************************/ | |
155 | +UINT8 a2d_av_aptx_hd_cfg_in_cap(UINT8 *p_cfg, tA2D_APTX_HD_CIE *p_cap) | |
156 | +{ | |
157 | + UINT8 status = 0; | |
158 | + tA2D_APTX_HD_CIE cfg_cie; | |
159 | + | |
160 | + A2D_TRACE_API("%s", __func__); | |
161 | + | |
162 | + /* parse configuration */ | |
163 | + if ((status = A2D_ParsAptx_hdInfo(&cfg_cie, p_cfg, FALSE)) != 0) | |
164 | + { | |
165 | + A2D_TRACE_ERROR("%s: aptX HD parse failed", __func__); | |
166 | + return status; | |
167 | + } | |
168 | + | |
169 | + /* verify that each parameter is in range */ | |
170 | + | |
171 | + /* sampling frequency */ | |
172 | + if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) | |
173 | + status = A2D_NS_SAMP_FREQ; | |
174 | + /* channel mode */ | |
175 | + else if ((cfg_cie.channelMode & p_cap->channelMode) == 0) | |
176 | + status = A2D_NS_CH_MODE; | |
177 | + | |
178 | + return status; | |
179 | +} | |
180 | + | |
181 | +/******************************************************************************* | |
182 | +** | |
183 | +** Function A2D_check_and_init_aptX_HD | |
184 | +** | |
185 | +** Description This function checks if all the libraries required for | |
186 | +** aptX HD are present and needed function pointers are resolved | |
187 | +** | |
188 | +** Returns returns true if aptX HD codec initialization succeeds | |
189 | +** | |
190 | +*******************************************************************************/ | |
191 | +BOOLEAN A2D_check_and_init_aptX_HD(void) | |
192 | +{ | |
193 | + A2D_TRACE_DEBUG("%s", __func__); | |
194 | + | |
195 | + if (isA2dAptXEnabled && A2dAptXSchedLibHandle) | |
196 | + { | |
197 | + A2D_aptx_hd_encoder_init = (int (*)(void))dlsym(A2dAptXSchedLibHandle, | |
198 | + "aptx_hd_encoder_init"); | |
199 | + if (!A2D_aptx_hd_encoder_init) | |
200 | + { | |
201 | + A2D_TRACE_ERROR("%s: aptX HD encoder init missing", __func__); | |
202 | + goto error_exit; | |
203 | + } | |
204 | + | |
205 | + A2D_aptx_hd_encoder_deinit = (void (*)(void))dlsym(A2dAptXSchedLibHandle, | |
206 | + "aptx_hd_encoder_deinit"); | |
207 | + if (!A2D_aptx_hd_encoder_deinit) | |
208 | + { | |
209 | + A2D_TRACE_ERROR("%s: aptX HD encoder deinit missing", __func__); | |
210 | + goto error_exit; | |
211 | + } | |
212 | + | |
213 | + if (A2D_aptx_hd_encoder_init()) | |
214 | + { | |
215 | + A2D_TRACE_ERROR("%s: aptX HD encoder init failed - %s", __func__, dlerror()); | |
216 | + goto error_exit; | |
217 | + } | |
218 | + } else { | |
219 | + A2D_TRACE_ERROR("%s: isA2dAptXEnabled = false", __func__); | |
220 | + goto error_exit; | |
221 | + } | |
222 | + isA2dAptXHdEnabled = true; | |
223 | + return isA2dAptXHdEnabled; | |
224 | + | |
225 | + error_exit:; | |
226 | + isA2dAptXHdEnabled = false; | |
227 | + return isA2dAptXHdEnabled; | |
228 | + | |
229 | +} | |
230 | + | |
231 | +/******************************************************************************* | |
232 | +** | |
233 | +** Function A2D_deinit_aptX_HD | |
234 | +** | |
235 | +** Description This function de-initialized aptX HD | |
236 | +** | |
237 | +** Returns Nothing | |
238 | +** | |
239 | +*******************************************************************************/ | |
240 | +void A2D_deinit_aptX_HD(void) | |
241 | +{ | |
242 | + A2D_TRACE_DEBUG("%s", __func__); | |
243 | + | |
244 | + if (isA2dAptXHdEnabled && isA2dAptXEnabled && A2dAptXSchedLibHandle) | |
245 | + { | |
246 | + A2D_aptx_hd_encoder_deinit(); | |
247 | + isA2dAptXHdEnabled = false; | |
248 | + } | |
249 | + | |
250 | + return; | |
251 | +} |
@@ -69,9 +69,7 @@ const UINT8 avdt_scb_role_evt[] = { | ||
69 | 69 | AVDT_OPEN_CFM_EVT /* AVDT_OPEN_INT */ |
70 | 70 | }; |
71 | 71 | |
72 | -extern UINT8* bta_av_get_current_codecInfo(); | |
73 | 72 | |
74 | -#define NON_A2DP_MEDIA_CT 0xff | |
75 | 73 | /******************************************************************************* |
76 | 74 | ** |
77 | 75 | ** Function avdt_scb_gen_ssrc |
@@ -1239,11 +1237,9 @@ void avdt_scb_hdl_write_req_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) | ||
1239 | 1237 | } |
1240 | 1238 | osi_free_and_reset((void **)&p_scb->p_pkt); |
1241 | 1239 | |
1242 | - /* build a media packet if the codec type is not aptX */ | |
1243 | -#if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE) | |
1244 | -#else | |
1245 | - if (p_data->apiwrite.m_pt != NON_A2DP_MEDIA_CT) | |
1246 | -#endif | |
1240 | + /* build a media packet */ | |
1241 | + /* Add RTP header if required */ | |
1242 | + if ( !(p_data->apiwrite.opt & AVDT_DATA_OPT_NO_RTP) ) | |
1247 | 1243 | { |
1248 | 1244 | ssrc = avdt_scb_gen_ssrc(p_scb); |
1249 | 1245 |
@@ -86,7 +86,7 @@ | ||
86 | 86 | #define A2D_BAD_CP_FORMAT 0xE1 /* The format of Content Protection Service Capability/Content Protection Scheme Dependent Data is not correct. */ |
87 | 87 | |
88 | 88 | |
89 | -#define A2D_NON_A2DP_MEDIA_CT 0xff /* NON A2DP media codec */ | |
89 | +#define A2D_NON_A2DP_MEDIA_CT 0xFF /* NON A2DP media codec */ | |
90 | 90 | |
91 | 91 | typedef UINT8 tA2D_STATUS; |
92 | 92 |
@@ -60,8 +60,7 @@ | ||
60 | 60 | typedef enum { |
61 | 61 | APTX_CODEC_NONE=0, |
62 | 62 | APTX_CODEC, |
63 | - APTX_CODEC_LL, | |
64 | - APTX_CODEC_HD, | |
63 | + APTX_HD_CODEC, | |
65 | 64 | } A2D_AptXCodecType; |
66 | 65 | |
67 | 66 | typedef void (*A2D_AptXThreadFn)(void *context); |
@@ -122,6 +121,7 @@ extern void (*A2D_aptx_encoder_deinit)(void); | ||
122 | 121 | extern UINT8 a2d_av_aptx_cfg_in_cap(UINT8 *p_cfg, tA2D_APTX_CIE *p_cap); |
123 | 122 | extern BOOLEAN A2D_check_and_init_aptX(); |
124 | 123 | extern void A2D_deinit_aptX(); |
124 | +extern void A2D_close_aptX(); | |
125 | 125 | |
126 | 126 | #ifdef __cplusplus |
127 | 127 | } |
@@ -0,0 +1,105 @@ | ||
1 | +/****************************************************************************** | |
2 | + | |
3 | + Copyright (c) 2016, The Linux Foundation. All rights reserved. | |
4 | + | |
5 | + Redistribution and use in source and binary forms, with or without | |
6 | + modification, are permitted provided that the following conditions are | |
7 | + met: | |
8 | + * Redistributions of source code must retain the above copyright | |
9 | + notice, this list of conditions and the following disclaimer. | |
10 | + * Redistributions in binary form must reproduce the above | |
11 | + copyright notice, this list of conditions and the following | |
12 | + disclaimer in the documentation and/or other materials provided | |
13 | + with the distribution. | |
14 | + * Neither the name of The Linux Foundation nor the names of its | |
15 | + contributors may be used to endorse or promote products derived | |
16 | + from this software without specific prior written permission. | |
17 | + | |
18 | + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | |
19 | + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
20 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | |
21 | + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | |
22 | + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
23 | + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
24 | + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
25 | + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
26 | + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
27 | + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | |
28 | + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | + | |
30 | + ******************************************************************************/ | |
31 | +/****************************************************************************** | |
32 | + interface to aptX HD codec | |
33 | + ******************************************************************************/ | |
34 | +#ifndef A2D_APTX_HD_H | |
35 | +#define A2D_APTX_HD_H | |
36 | + | |
37 | +/* aptX HD codec specific settings*/ | |
38 | +#define A2D_APTX_HD_CODEC_LEN 13 | |
39 | + | |
40 | +#define A2D_APTX_HD_VENDOR_ID (0x000000D7) | |
41 | +#define A2D_APTX_HD_CODEC_ID_BLUETOOTH ((UINT16) 0x0024) | |
42 | +#define A2D_APTX_HD_SAMPLERATE_44100 (0x20) | |
43 | +#define A2D_APTX_HD_SAMPLERATE_48000 (0x10) | |
44 | +#define A2D_APTX_HD_CHANNELS_STEREO (0x02) | |
45 | +#define A2D_APTX_HD_CHANNELS_MONO (0x01) | |
46 | +#define A2D_APTX_HD_ACL_SPRINT_RESERVED0 (0x00) | |
47 | +#define A2D_APTX_HD_ACL_SPRINT_RESERVED1 (0x00) | |
48 | +#define A2D_APTX_HD_ACL_SPRINT_RESERVED2 (0x00) | |
49 | +#define A2D_APTX_HD_ACL_SPRINT_RESERVED3 (0x00) | |
50 | +#define A2D_APTX_HD_OTHER_FEATURES_NONE (0x00000000) | |
51 | +#define A2D_APTX_HD_AV_AUDIO (0x00) | |
52 | +#define A2D_APTX_HD_CODEC_ID (0xff) | |
53 | +#define A2D_APTX_HD_CHANNEL (0x0001) | |
54 | +#define A2D_APTX_HD_SAMPLERATE (0x22) | |
55 | + | |
56 | +/***************************************************************************** | |
57 | +** Type Definitions | |
58 | +*****************************************************************************/ | |
59 | + | |
60 | +typedef struct { | |
61 | + UINT32 vendorId; | |
62 | + UINT16 codecId; /* Codec ID for aptX HD */ | |
63 | + UINT8 sampleRate; /* Sampling Frequency */ | |
64 | + UINT8 channelMode; /* STEREO/DUAL/MONO */ | |
65 | + UINT8 acl_sprint_reserved0; | |
66 | + UINT8 acl_sprint_reserved1; | |
67 | + UINT8 acl_sprint_reserved2; | |
68 | + UINT8 acl_sprint_reserved3; | |
69 | +} tA2D_APTX_HD_CIE; | |
70 | + | |
71 | +typedef struct { | |
72 | + INT16 s16SamplingFreq; /* 16k, 32k, 44.1k or 48k*/ | |
73 | + INT16 s16ChannelMode; /* mono, dual, streo or joint streo*/ | |
74 | + UINT16 u16BitRate; | |
75 | + UINT16 *ps16NextPcmBuffer; | |
76 | + UINT8 *pu8Packet; | |
77 | + UINT8 *pu8NextPacket; | |
78 | + UINT16 u16PacketLength; | |
79 | + void* encoder; | |
80 | +} A2D_APTX_HD_ENC_PARAMS; | |
81 | + | |
82 | +extern BOOLEAN isA2dAptXHdEnabled; | |
83 | + | |
84 | +/***************************************************************************** | |
85 | +** external function declarations | |
86 | +*****************************************************************************/ | |
87 | +#ifdef __cplusplus | |
88 | +extern "C" | |
89 | +{ | |
90 | +#endif | |
91 | +extern UINT8 A2D_BldAptx_hdInfo(UINT8 media_type, tA2D_APTX_HD_CIE *p_ie, | |
92 | + UINT8 *p_result); | |
93 | +extern UINT8 A2D_ParsAptx_hdInfo(tA2D_APTX_HD_CIE *p_ie, UINT8 *p_info, | |
94 | + BOOLEAN for_caps); | |
95 | +extern int (*A2D_aptx_hd_encoder_init)(void); | |
96 | +extern void (*A2D_aptx_hd_encoder_deinit)(void); | |
97 | +extern UINT8 a2d_av_aptx_hd_cfg_in_cap(UINT8 *p_cfg, tA2D_APTX_HD_CIE *p_cap); | |
98 | +extern BOOLEAN A2D_check_and_init_aptX_HD(); | |
99 | +extern void A2D_deinit_aptX_HD(); | |
100 | + | |
101 | +#ifdef __cplusplus | |
102 | +} | |
103 | +#endif | |
104 | + | |
105 | +#endif /* A2D_APTX_HD_H */ |