Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b9f7716 authored by Hemant Gupta's avatar Hemant Gupta Committed by Mike Lockwood
Browse files

Add A2DP Sink Support

Change-Id: I9affefdd2d00597545e49c593ef3bddb110d4c9c
parent d6ba9659
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ else
endif

bdroid_CFLAGS += -Wall -Werror
bdroid_CFLAGS += -DBTA_AVK_INCLUDED

include $(call all-subdir-makefiles)

+214 −26
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ static const UINT16 bta_av_stream_evt_fail[] = {
    0                               /* AVDT_DELAY_REPORT_CFM_EVT */
};

void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);
static void bta_av_stream0_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
static void bta_av_stream1_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
#if BTA_AV_NUM_STRS > 2
@@ -225,6 +226,48 @@ tAVDT_CTRL_CBACK * const bta_av_dt_cback[] =
    ,bta_av_stream5_cback
#endif
};
/***********************************************
**
** Function         bta_get_scb_handle
**
** Description      gives the registered AVDT handle.by checking with sep_type.
**
**
** Returns          void
***********************************************/
UINT8  bta_av_get_scb_handle ( tBTA_AV_SCB *p_scb, UINT8 local_sep )
{
    UINT8 xx =0;
    for (xx = 0; xx<BTA_AV_MAX_SEPS; xx++)
    {
        if ((p_scb->seps[xx].tsep == local_sep) &&
            (p_scb->seps[xx].codec_type == p_scb->codec_type))
            return (p_scb->seps[xx].av_handle);
    }
    APPL_TRACE_DEBUG0(" bta_av_get_scb_handle appropiate sep_type not found")
    return 0; /* return invalid handle */
}

/***********************************************
**
** Function         bta_av_get_scb_sep_type
**
** Description      gives the sep type by cross-checking with AVDT handle
**
**
** Returns          void
***********************************************/
UINT8  bta_av_get_scb_sep_type ( tBTA_AV_SCB *p_scb, UINT8 tavdt_handle)
{
    UINT8 xx =0;
    for (xx = 0; xx<BTA_AV_MAX_SEPS; xx++)
    {
        if (p_scb->seps[xx].av_handle == tavdt_handle)
            return (p_scb->seps[xx].tsep);
    }
    APPL_TRACE_DEBUG0(" bta_av_get_scb_sep_type appropiate handle not found")
    return 3; /* return invalid sep type */
}

/*******************************************************************************
**
@@ -320,12 +363,19 @@ static BOOLEAN bta_av_next_getcap(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    int     i;
    tAVDT_GETCAP_REQ    *p_req;
    BOOLEAN     sent_cmd = FALSE;
    UINT16 uuid_int = p_scb->uuid_int;
    UINT8 sep_requested = 0;

    if(uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
       sep_requested = AVDT_TSEP_SNK;
    else if(uuid_int == UUID_SERVCLASS_AUDIO_SINK)
       sep_requested = AVDT_TSEP_SRC;

    for (i = p_scb->sep_info_idx; i < p_scb->num_seps; i++)
    {
        /* steam not in use, is a sink, and is the right media type (audio/video) */
        if ((p_scb->sep_info[i].in_use == FALSE) &&
            (p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
            (p_scb->sep_info[i].tsep == sep_requested) &&
            (p_scb->sep_info[i].media_type == p_scb->media_type))
        {
            p_scb->sep_info_idx = i;
@@ -507,6 +557,39 @@ void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CT
    bta_av_conn_cback(handle, bd_addr, event, p_data);
}

/*******************************************************************************
**
** Function         bta_av_stream_data_cback
**
** Description      This is the AVDTP callback function for stream events.
**
** Returns          void
**
*******************************************************************************/
void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt)
{
    int index = 0;
    tBTA_AV_SCB         *p_scb ;
    APPL_TRACE_DEBUG3("bta_av_stream_data_cback avdt_handle: %d pkt_len=0x%x  ofst = 0x%x", handle,p_pkt->len,p_pkt->offset);
    APPL_TRACE_DEBUG1(" Number of frames 0x%x",*((UINT8*)(p_pkt + 1) + p_pkt->offset));
    APPL_TRACE_DEBUG1("Sequence Number 0x%x",p_pkt->layer_specific);
    /* Get  SCB  and correct sep type*/
    for(index = 0; index < BTA_AV_NUM_STRS;index ++ )
    {
        p_scb = bta_av_cb.p_scb[index];
        if((p_scb->avdt_handle == handle)&&(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK))
            break;
    }
    if(index == BTA_AV_NUM_STRS) /* cannot find correct handler */
    {
        GKI_freebuf(p_pkt);
        return;
    }
    p_pkt->event = BTA_AV_MEDIA_DATA_EVT;
    p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_DATA_EVT, (tBTA_AV_MEDIA*)p_pkt);
    GKI_freebuf(p_pkt);  /* a copy of packet had been delivered, we free this buffer */
}

/*******************************************************************************
**
** Function         bta_av_stream0_cback
@@ -650,16 +733,16 @@ static void bta_av_a2d_sdp_cback(BOOLEAN found, tA2D_Service *p_service)
** Returns
**
*******************************************************************************/
static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb)
static void bta_av_adjust_seps_idx(tBTA_AV_SCB *p_scb, UINT8 avdt_handle)
{
    int xx;

    APPL_TRACE_DEBUG1("bta_av_adjust_seps_idx codec_type: %d", p_scb->codec_type);
    for(xx=0; xx<BTA_AV_MAX_SEPS; xx++)
    {
        APPL_TRACE_DEBUG2("av_handle: %d codec_type: %d",
            p_scb->seps[xx].av_handle, p_scb->seps[xx].codec_type);
        if(p_scb->seps[xx].av_handle && p_scb->codec_type == p_scb->seps[xx].codec_type)
        if((p_scb->seps[xx].av_handle && p_scb->codec_type == p_scb->seps[xx].codec_type)
            && (p_scb->seps[xx].av_handle == avdt_handle))
        {
            p_scb->sep_idx      = xx;
            p_scb->avdt_handle  = p_scb->seps[xx].av_handle;
@@ -781,6 +864,10 @@ void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
                av_open.chnl   = p_scb->chnl;
                av_open.hndl   = p_scb->hndl;
                start.status = BTA_AV_FAIL_ROLE;
                if(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
                    av_open.sep = AVDT_TSEP_SNK;
                else if(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
                    av_open.sep = AVDT_TSEP_SRC;
                (*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *)&av_open);
            }
            else
@@ -830,6 +917,7 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    UINT16              attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST,
                                       ATTR_ID_PROTOCOL_DESC_LIST,
                                       ATTR_ID_BT_PROFILE_DESC_LIST};
    UINT16 sdp_uuid = 0; /* UUID for which SDP has to be done */

    APPL_TRACE_DEBUG3("bta_av_do_disc_a2d use_rc: %d rs:%d, oc:%d",
        p_data->api_open.use_rc, p_data->api_open.switch_res, bta_av_cb.audio_open_cnt);
@@ -922,8 +1010,14 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        db_params.num_attr = 3;
        db_params.p_db = p_scb->p_disc_db;
        db_params.p_attrs = attr_list;

        if(A2D_FindService(UUID_SERVCLASS_AUDIO_SINK, p_scb->peer_addr, &db_params,
        p_scb->uuid_int = p_data->api_open.uuid;
        if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SINK)
            sdp_uuid = UUID_SERVCLASS_AUDIO_SOURCE;
        else if (p_scb->uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
            sdp_uuid = UUID_SERVCLASS_AUDIO_SINK;

        APPL_TRACE_DEBUG2("uuid_int 0x%x, Doing SDP For 0x%x", p_scb->uuid_int, sdp_uuid);
        if(A2D_FindService(sdp_uuid, p_scb->peer_addr, &db_params,
                        bta_av_a2d_sdp_cback) == A2D_SUCCESS)
        {
            return;
@@ -1021,8 +1115,12 @@ void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    tAVDT_SEP_INFO       *p_info;
    tAVDT_CFG            *p_evt_cfg = &p_data->str_msg.cfg;
    UINT8   psc_mask = (p_evt_cfg->psc_mask | p_scb->cfg.psc_mask);
    UINT8 local_sep;    /* sep type of local handle on which connection was received */
    UINT8 count = 0;
    tBTA_AV_STR_MSG  *p_msg = (tBTA_AV_STR_MSG *)p_data;
    UNUSED(p_data);

    local_sep = bta_av_get_scb_sep_type(p_scb, p_msg->handle);
    p_scb->avdt_label = p_data->str_msg.msg.hdr.label;
    memcpy(p_scb->cfg.codec_info, p_evt_cfg->codec_info, AVDT_CODEC_SIZE);
    p_scb->codec_type = p_evt_cfg->codec_info[BTA_AV_CODEC_TYPE_IDX];
@@ -1048,7 +1146,13 @@ void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        p_info->in_use = 0;
        p_info->media_type = p_scb->media_type;
        p_info->seid = p_data->str_msg.msg.config_ind.int_seid;

        /* Sep type of Peer will be oppsite role to our local sep */
        if (local_sep == AVDT_TSEP_SRC)
            p_info->tsep = AVDT_TSEP_SNK;
        else if (local_sep == AVDT_TSEP_SNK)
            p_info->tsep = AVDT_TSEP_SRC;

        p_scb->role      |= BTA_AV_ROLE_AD_ACP;
        p_scb->cur_psc_mask = p_evt_cfg->psc_mask;
        if (bta_av_cb.features & BTA_AV_FEAT_RCTG)
@@ -1059,13 +1163,29 @@ void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        p_scb->num_seps  = 1;
        p_scb->sep_info_idx = 0;
        APPL_TRACE_DEBUG3("bta_av_config_ind: SEID: %d use_rc: %d cur_psc_mask:0x%x", p_info->seid, p_scb->use_rc, p_scb->cur_psc_mask);

        /*  in case of A2DP SINK this is the first time peer data is being sent to co functions */
        if (local_sep == AVDT_TSEP_SNK)
        {
            p_scb->p_cos->setcfg(p_scb->hndl, p_scb->codec_type,
                             p_evt_cfg->codec_info,
                             p_info->seid,
                             p_scb->peer_addr,
                             p_evt_cfg->num_protect,
                             p_evt_cfg->protect_info,
                             AVDT_TSEP_SNK,
                             p_msg->handle);
        }
        else
        {
            p_scb->p_cos->setcfg(p_scb->hndl, p_scb->codec_type,
                             p_evt_cfg->codec_info,
                             p_info->seid,
                             p_scb->peer_addr,
                             p_evt_cfg->num_protect,
                             p_evt_cfg->protect_info);
                             p_evt_cfg->protect_info,
                             AVDT_TSEP_SRC,
                             p_msg->handle);
        }
    }
}

@@ -1153,12 +1273,21 @@ void bta_av_security_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
    UINT8   num = p_data->ci_setconfig.num_seid + 1;
    UINT8   avdt_handle = p_data->ci_setconfig.avdt_handle;
    UINT8   *p_seid = p_data->ci_setconfig.p_seid;
    int     i;
    UINT8   local_sep;

    /* we like this codec_type. find the sep_idx */
    bta_av_adjust_seps_idx(p_scb);
    local_sep = bta_av_get_scb_sep_type(p_scb,avdt_handle);
    bta_av_adjust_seps_idx(p_scb, avdt_handle);
    APPL_TRACE_DEBUG2("bta_av_setconfig_rsp: sep_idx: %d cur_psc_mask:0x%x", p_scb->sep_idx, p_scb->cur_psc_mask);
    if ((AVDT_TSEP_SNK == local_sep) && (p_data->ci_setconfig.err_code == AVDT_SUCCESS) &&
                                     (p_scb->seps[p_scb->sep_idx].p_app_data_cback != NULL))
        p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_SINK_CFG_EVT,
                                              (tBTA_AV_MEDIA*)p_scb->cfg.codec_info);


    AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, p_data->ci_setconfig.err_code,
                   p_data->ci_setconfig.category);

@@ -1183,7 +1312,10 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        {
            /* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
                       * call disc_res now */
            p_scb->p_cos->disc_res(p_scb->hndl, num, num, p_scb->peer_addr);
           /* this is called in A2DP SRC path only, In case of SINK we don't need it  */
            if (local_sep == AVDT_TSEP_SRC)
                p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
                                                      UUID_SERVCLASS_AUDIO_SOURCE);
        }
        else
        {
@@ -1202,6 +1334,8 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
            p_scb->sep_info[i].media_type = p_scb->media_type;
            p_scb->sep_info[i].seid = p_seid[i-1];
        }
        /* only in case of local sep as SRC we need to look for other SEPs, In case of SINK we don't */
        if (local_sep == AVDT_TSEP_SRC)
            bta_av_next_getcap(p_scb, p_data);
    }
}
@@ -1275,6 +1409,11 @@ void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
        bta_ar_avdt_conn(BTA_ID_AV, open.bd_addr);
#endif
        if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
            open.sep = AVDT_TSEP_SNK;
        else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
            open.sep = AVDT_TSEP_SRC;

        (*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
        if(open.starting)
        {
@@ -1436,8 +1575,11 @@ void bta_av_sdp_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
*******************************************************************************/
void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
    UINT8 num_snks = 0, i;
    UINT8 num_snks = 0, num_srcs =0, i;
    /* our uuid in case we initiate connection */
    UINT16 uuid_int = p_scb->uuid_int;

    APPL_TRACE_DEBUG1(" initiator UUID 0x%x", uuid_int);
    /* store number of stream endpoints returned */
    p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps;

@@ -1445,15 +1587,23 @@ void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    {
        /* steam not in use, is a sink, and is audio */
        if ((p_scb->sep_info[i].in_use == FALSE) &&
            (p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
            (p_scb->sep_info[i].media_type == p_scb->media_type))
        {
            if((p_scb->sep_info[i].tsep == AVDT_TSEP_SNK) &&
               (uuid_int == UUID_SERVCLASS_AUDIO_SOURCE))
                num_snks++;

            if((p_scb->sep_info[i].tsep == AVDT_TSEP_SRC) &&
               (uuid_int == UUID_SERVCLASS_AUDIO_SINK))
                num_srcs++;

        }
    }

    p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, p_scb->peer_addr);
    p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, num_srcs, p_scb->peer_addr,
                                                                                    uuid_int);
    p_scb->num_disc_snks = num_snks;
    p_scb->num_disc_srcs = num_srcs;

    /* if we got any */
    if (p_scb->num_seps > 0)
@@ -1501,9 +1651,10 @@ void bta_av_disc_res_as_acp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
            num_snks++;
        }
    }

    p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, p_scb->peer_addr);
    p_scb->p_cos->disc_res(p_scb->hndl, p_scb->num_seps, num_snks, 0, p_scb->peer_addr,
                                                          UUID_SERVCLASS_AUDIO_SOURCE);
    p_scb->num_disc_snks = num_snks;
    p_scb->num_disc_srcs = 0;

    /* if we got any */
    if (p_scb->num_seps > 0)
@@ -1648,6 +1799,11 @@ void bta_av_open_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        /* set the state back to initial state */
        bta_av_set_scb_sst_init(p_scb);

        if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
            open.sep = AVDT_TSEP_SNK;
        else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
            open.sep = AVDT_TSEP_SRC;

        (*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);

    }
@@ -1674,6 +1830,7 @@ void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    tAVDT_CFG   cfg;
    UINT8       media_type;
    tAVDT_SEP_INFO  *p_info = &p_scb->sep_info[p_scb->sep_info_idx];
    UINT16 uuid_int; /* UUID for which connection was initiatied */

    memcpy(&cfg, &p_scb->cfg, sizeof(tAVDT_CFG));
    cfg.num_codec = 1;
@@ -1702,11 +1859,26 @@ void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        /* save copy of codec type and configuration */
        p_scb->codec_type = cfg.codec_info[BTA_AV_CODEC_TYPE_IDX];
        memcpy(&p_scb->cfg, &cfg, sizeof(tAVDT_CFG));
        bta_av_adjust_seps_idx(p_scb);

        uuid_int = p_scb->uuid_int;
        APPL_TRACE_DEBUG1(" initiator UUID = 0x%x ", uuid_int);
        if (uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
            bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC));
        else if (uuid_int == UUID_SERVCLASS_AUDIO_SINK)
            bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SNK));

        /* use only the services peer supports */
        cfg.psc_mask &= p_scb->p_cap->psc_mask;
        p_scb->cur_psc_mask = cfg.psc_mask;

        if ((uuid_int == UUID_SERVCLASS_AUDIO_SINK) &&
            (p_scb->seps[p_scb->sep_idx].p_app_data_cback != NULL))
        {
            APPL_TRACE_DEBUG0(" Configure Deoder for Sink Connection ");
            p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_SINK_CFG_EVT,
                     (tBTA_AV_MEDIA*)p_scb->cfg.codec_info);
        }

        /* open the stream */
        AVDT_OpenReq(p_scb->seps[p_scb->sep_idx].av_handle, p_scb->peer_addr,
                     p_scb->sep_info[p_scb->sep_info_idx].seid, &cfg);
@@ -1738,9 +1910,12 @@ void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
    tBTA_AV_REJECT reject;
    UINT8   avdt_handle = p_data->ci_setconfig.avdt_handle;

    bta_av_adjust_seps_idx(p_scb, avdt_handle);
    APPL_TRACE_DEBUG1("bta_av_setconfig_rej: sep_idx: %d",p_scb->sep_idx);
    AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label, AVDT_ERR_UNSUP_CFG, 0);

    APPL_TRACE_DEBUG0("bta_av_setconfig_rej");
    AVDT_ConfigRsp(p_data->str_msg.handle, p_data->str_msg.msg.hdr.label, AVDT_ERR_BAD_STATE, 0);
    bdcpy(reject.bd_addr, p_data->str_msg.bd_addr);
    reject.hndl = p_scb->hndl;
    (*bta_av_cb.p_cback)(BTA_AV_REJECT_EVT, (tBTA_AV *) &reject);
@@ -2129,6 +2304,13 @@ void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
    if (new_role & BTA_AV_ROLE_START_INT)
        initiator = TRUE;

    /* for A2DP SINK we do not send get_caps */
    if ((p_scb->avdt_handle == p_scb->seps[p_scb->sep_idx].av_handle)
         &&(p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK))
    {
        p_scb->wait &= ~(BTA_AV_WAIT_ACP_CAPS_ON);
        APPL_TRACE_DEBUG1(" Local SEP type is SNK  new wait is 0x%x",p_scb->wait);
    }
    if (p_scb->wait & BTA_AV_WAIT_ROLE_SW_FAILED)
    {
        /* role switch has failed */
@@ -2322,6 +2504,12 @@ void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        data.open.status = p_scb->open_status;
        data.open.chnl   = p_scb->chnl;
        data.open.hndl   = p_scb->hndl;

        if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC )
            data.open.sep = AVDT_TSEP_SNK;
        else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK )
            data.open.sep = AVDT_TSEP_SRC;

        event = BTA_AV_OPEN_EVT;
        p_scb->open_status = BTA_AV_SUCCESS;

@@ -2699,7 +2887,7 @@ void bta_av_rcfg_open (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
        memcpy(p_scb->cfg.codec_info, p_scb->p_cap->codec_info, AVDT_CODEC_SIZE);
        /* we may choose to use a different SEP at reconfig.
         * adjust the sep_idx now */
        bta_av_adjust_seps_idx(p_scb);
        bta_av_adjust_seps_idx(p_scb, bta_av_get_scb_handle(p_scb, AVDT_TSEP_SRC));

        /* open the stream with the new config */
        p_scb->sep_info_idx = p_scb->rcfg_idx;
+5 −0
Original line number Diff line number Diff line
@@ -1996,6 +1996,11 @@ void bta_av_dereg_comp(tBTA_AV_DATA *p_data)
#endif
                bta_av_del_sdp_rec(&p_cb->sdp_a2d_handle);
                bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SOURCE);

#ifdef BTA_AVK_INCLUDED
                bta_av_del_sdp_rec(&p_cb->sdp_a2d_snk_handle);
                bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK);
#endif
            }
        }
        else
+30 −2
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ void BTA_AvDisable(void)
** Returns          void
**
*******************************************************************************/
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id)
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK  *p_data_cback)
{
    tBTA_AV_API_REG  *p_buf;

@@ -128,6 +128,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id)
            p_buf->p_service_name[0] = 0;
        }
        p_buf->app_id = app_id;
        p_buf->p_app_data_cback = p_data_cback;
        bta_sys_sendmsg(p_buf);
    }
}
@@ -164,7 +165,8 @@ void BTA_AvDeregister(tBTA_AV_HNDL hndl)
** Returns          void
**
*******************************************************************************/
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask)
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask,
                                                                             UINT16 uuid)
{
    tBTA_AV_API_OPEN  *p_buf;

@@ -176,6 +178,7 @@ void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC s
        p_buf->use_rc = use_rc;
        p_buf->sec_mask = sec_mask;
        p_buf->switch_res = BTA_AV_RS_NONE;
        p_buf->uuid = uuid;
        bta_sys_sendmsg(p_buf);
    }
}
@@ -242,6 +245,31 @@ void BTA_AvStart(void)
    }
}

/*******************************************************************************
**
** Function         BTA_AvEnable_Sink
**
** Description      Enable/Disable A2DP Sink..
**
** Returns          void
**
*******************************************************************************/
void BTA_AvEnable_Sink(int enable)
{
    BT_HDR  *p_buf;

#ifdef BTA_AVK_INCLUDED
    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
    {
        p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
        p_buf->layer_specific = enable;
        bta_sys_sendmsg(p_buf);
    }
#else
    return;
#endif
}

/*******************************************************************************
**
** Function         BTA_AvStop
+2 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
**
*******************************************************************************/
void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
                         UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed)
                         UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed, UINT8 avdt_handle)
{
    tBTA_AV_CI_SETCONFIG  *p_buf;

@@ -81,6 +81,7 @@ void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
        p_buf->category = category;
        p_buf->recfg_needed = recfg_needed;
        p_buf->num_seid = num_seid;
        p_buf->avdt_handle= avdt_handle;
        if(p_seid && num_seid)
        {
            p_buf->p_seid   = (UINT8 *)(p_buf + 1);
Loading