summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAyan Ghosh <abghosh@codeaurora.org>2016-07-12 16:06:49 +0530
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:10:04 -0600
commit436224238d7a8b8addc3df35fc84d99909eb0455 (patch)
tree25f3f6dadee49d5a8115f35cc39f1e7a42d22b9a
parent7e356f403e1c35759a03c524d8117f226c4983e9 (diff)
downloadandroid_system_bt-436224238d7a8b8addc3df35fc84d99909eb0455.tar.gz
android_system_bt-436224238d7a8b8addc3df35fc84d99909eb0455.tar.bz2
android_system_bt-436224238d7a8b8addc3df35fc84d99909eb0455.zip
Do AV registration for different roles in proper way
For multiple codec (SBC, APTx) and multiple role (SRC, SNK) enabled environment make sure registration of individual AV endpoints are done in a way that enabling different roles for differnt codecs does not affect other codecs or roles. CRs-Fixed: 1042243 Change-Id: I03e05eef7d9bf669c6600630afcb507bb52bd5a7
-rw-r--r--bta/av/bta_av_main.c55
-rw-r--r--bta/include/bta_av_co.h13
-rw-r--r--btif/co/bta_av_co.c6
-rw-r--r--btif/include/btif_av_co.h9
4 files changed, 49 insertions, 34 deletions
diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c
index 6591c2e59..bece9c0d6 100644
--- a/bta/av/bta_av_main.c
+++ b/bta/av/bta_av_main.c
@@ -504,8 +504,9 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
char *p_service_name;
tBTA_AV_CODEC codec_type;
tBTA_UTL_COD cod;
- UINT8 index = 0;
- UINT8 xx;
+ UINT8 startIndex = 0;
+ UINT8 endIndex = 0;
+ UINT8 index;
UINT16 profile_initialized;
memset(&cs,0,sizeof(tAVDT_CS));
@@ -657,46 +658,54 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE)
{
cs.tsep = AVDT_TSEP_SRC;
- index = 0;
+ startIndex = BTIF_SV_AV_AA_SBC_INDEX;
+ endIndex = BTIF_SV_AV_AA_SRC_SEP_INDEX;
}
else if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK)
{
cs.tsep = AVDT_TSEP_SNK;
cs.p_data_cback = bta_av_stream_data_cback;
- index = 1;
+ startIndex = BTIF_SV_AV_AA_SBC_SINK_INDEX;
+ endIndex = BTIF_SV_AV_AA_SNK_SEP_INDEX;
}
/* Initialize Handles to zero */
- for(xx=0; xx<BTA_AV_MAX_SEPS; xx++)
+ for(index = 0; index < (endIndex - startIndex); index++)
{
- p_scb->seps[xx].av_handle = 0;
+ p_scb->seps[index].av_handle = 0;
}
/* keep the configuration in the stream control block */
memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
- while (index < BTA_AV_MAX_SEPS &&
+ index = startIndex;
+ while (index < endIndex &&
(*bta_av_a2d_cos.init)(&codec_type, cs.cfg.codec_info,
&cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE)
{
- if(AVDT_CreateStream(&p_scb->seps[index].av_handle, &cs) == AVDT_SUCCESS)
+ if(AVDT_CreateStream(&p_scb->seps[index - startIndex].av_handle, &cs) ==
+ AVDT_SUCCESS)
{
- UINT8* ptr = cs.cfg.codec_info;
- tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3];
- UINT8 vendorId = codecInfo->vendorId;
- UINT8 codecId = codecInfo->codecId;
-
- p_scb->seps[index].vendorId = vendorId;
- p_scb->seps[index].codecId = codecId;
- APPL_TRACE_DEBUG("%s audio[%x] vendorId: %x codecId: %x", __func__,
- index, p_scb->seps[index].vendorId, p_scb->seps[index].codecId);
- p_scb->seps[index].codec_type = codec_type;
- p_scb->seps[index].tsep = cs.tsep;
+ if ((profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) &&
+ (index == BTIF_SV_AV_AA_APTX_INDEX))
+ {
+ UINT8* ptr = cs.cfg.codec_info;
+ tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[3];
+ UINT8 vendorId = codecInfo->vendorId;
+ UINT8 codecId = codecInfo->codecId;
+
+ p_scb->seps[index - startIndex].vendorId = vendorId;
+ p_scb->seps[index - startIndex].codecId = codecId;
+ APPL_TRACE_DEBUG("%s audio[%x] vendorId: %x codecId: %x", __func__,
+ index, p_scb->seps[index - startIndex].vendorId,
+ p_scb->seps[index - startIndex].codecId);
+ }
+ p_scb->seps[index - startIndex].codec_type = codec_type;
+ p_scb->seps[index - startIndex].tsep = cs.tsep;
if(cs.tsep == AVDT_TSEP_SNK)
- p_scb->seps[index].p_app_data_cback = p_data->api_reg.p_app_data_cback;
+ p_scb->seps[index - startIndex].p_app_data_cback = p_data->api_reg.p_app_data_cback;
else
- p_scb->seps[index].p_app_data_cback = NULL; /* In case of A2DP SOURCE we don't need a callback to handle media packets */
-
- index++;
+ p_scb->seps[index - startIndex].p_app_data_cback = NULL; /* In case of A2DP SOURCE we don't need a callback to handle media packets */
+ index++;
} else
break;
}
diff --git a/bta/include/bta_av_co.h b/bta/include/bta_av_co.h
index ad8e697d9..ceea0f581 100644
--- a/bta/include/bta_av_co.h
+++ b/bta/include/bta_av_co.h
@@ -59,6 +59,19 @@ enum
BTA_AV_CO_ST_STREAM
};
+enum
+{
+ BTIF_SV_AV_AA_SBC_INDEX = 0,
+ BTIF_SV_AV_AA_APTX_INDEX,
+ BTIF_SV_AV_AA_SRC_SEP_INDEX /* Last index */
+};
+
+enum
+{
+ BTIF_SV_AV_AA_SBC_SINK_INDEX = BTIF_SV_AV_AA_SRC_SEP_INDEX,
+ BTIF_SV_AV_AA_SNK_SEP_INDEX /* Last index */
+};
+
/* data type for the Audio Codec Information*/
typedef struct
diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c
index a50f21ca3..2776d2e37 100644
--- a/btif/co/bta_av_co.c
+++ b/btif/co/bta_av_co.c
@@ -152,8 +152,10 @@ typedef struct
typedef struct
{
BD_ADDR addr; /* address of audio/video peer */
- tBTA_AV_CO_SINK snks[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported sinks */
- tBTA_AV_CO_SINK srcs[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported srcs */
+ /* array of supported sinks */
+ tBTA_AV_CO_SINK snks[BTIF_SV_AV_AA_SRC_SEP_INDEX - BTIF_SV_AV_AA_SBC_INDEX];
+ /* array of supported srcs */
+ tBTA_AV_CO_SINK srcs[BTIF_SV_AV_AA_SNK_SEP_INDEX - BTIF_SV_AV_AA_SBC_SINK_INDEX];
UINT8 num_snks; /* total number of sinks at peer */
UINT8 num_srcs; /* total number of srcs at peer */
UINT8 num_seps; /* total number of seids at peer */
diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h
index c7107de95..201aafc52 100644
--- a/btif/include/btif_av_co.h
+++ b/btif/include/btif_av_co.h
@@ -31,15 +31,6 @@
** Constants & Macros
********************************************************************************/
-enum
-{
- BTIF_SV_AV_AA_SBC_INDEX = 0,
- BTIF_SV_AV_AA_APTX_INDEX,
- BTIF_SV_AV_AA_SBC_SINK_INDEX,
- BTIF_SV_AV_AA_SEP_INDEX /* Last index */
-};
-
-
/*******************************************************************************
** Functions
********************************************************************************/