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

Commit 1f81bc1f authored by Mattias Agren's avatar Mattias Agren Committed by John Huang
Browse files

Configure BTA DM to not force master role upon inquiry

* Some headsets will request master role upon connection. When inquiry
is attempted during streaming this results in a small audio glitch
while attempting to switch back to master.

Bug: 8266826
Bug: 8569352

Change-Id: Iaca0bc0f8847e32bc2d40e33100f26ce19d79a28
parent 0912d3dc
Loading
Loading
Loading
Loading

system/bta/dm/bta_dm_act.c

100644 → 100755
+15 −2
Original line number Diff line number Diff line
@@ -3281,18 +3281,31 @@ static void bta_dm_rs_cback (tBTM_ROLE_SWITCH_CMPL *p1)
*******************************************************************************/
static BOOLEAN bta_dm_check_av(UINT16 event)
{
    BOOLEAN avoid_roleswitch = FALSE;
    BOOLEAN switching = FALSE;
    UINT8 i;
    tBTA_DM_PEER_DEVICE *p_dev;

#if defined(BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY) && (BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY == TRUE)

    /* avoid role switch upon inquiry if a2dp is actively streaming as it
       introduces an audioglitch due to FW scheduling delays (unavoidable) */
    if (event == BTA_DM_API_SEARCH_EVT)
    {
        avoid_roleswitch = TRUE;
    }
#endif

    APPL_TRACE_WARNING1("bta_dm_check_av:%d", bta_dm_cb.cur_av_count);
    if(bta_dm_cb.cur_av_count)
    {
        for(i=0; i<bta_dm_cb.device_list.count; i++)
        {
            p_dev = &bta_dm_cb.device_list.peer_device[i];
            APPL_TRACE_WARNING3("[%d]: state:%d, info:x%x", i, p_dev->conn_state, p_dev->info);
            if((p_dev->conn_state == BTA_DM_CONNECTED) && (p_dev->info & BTA_DM_DI_AV_ACTIVE))
            APPL_TRACE_WARNING4("[%d]: state:%d, info:x%x, avoid_rs %d",
                                i, p_dev->conn_state, p_dev->info, avoid_roleswitch);
            if((p_dev->conn_state == BTA_DM_CONNECTED) && (p_dev->info & BTA_DM_DI_AV_ACTIVE) &&
               (avoid_roleswitch == FALSE))
            {
                /* make master and take away the role switch policy */
                if(BTM_CMD_STARTED == BTM_SwitchRole (p_dev->peer_bdaddr, HCI_ROLE_MASTER, (tBTM_CMPL_CB *)bta_dm_rs_cback))
+6 −1
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@
#define BTA_DM_LINK_TIMEOUT    8000
#endif

/* TRUE to avoid scatternet when av is streaming (be the master) */
#ifndef BTA_DM_AVOID_SCATTER_A2DP
#define BTA_DM_AVOID_SCATTER_A2DP    TRUE
#endif

/* For Insight, PM cfg lookup tables are runtime configurable (to allow tweaking of params for power consumption measurements) */
#ifndef BTE_SIM_APP
#define tBTA_DM_PM_TYPE_QUALIFIER   const
@@ -62,7 +67,7 @@ const tBTA_DM_CFG bta_dm_cfg =
    /* link supervision timeout in 625uS*/
    BTA_DM_LINK_TIMEOUT,
    /* TRUE to avoid scatternet when av is streaming (be the master) */
    TRUE
    BTA_DM_AVOID_SCATTER_A2DP
};

#ifndef BTA_DM_SCATTERNET
+3 −0
Original line number Diff line number Diff line
@@ -3768,6 +3768,9 @@ The maximum number of payload octets that the local device can receive in a sing
#define BTA_AG_CIND_INFO "(\"call\",(0,1)),(\"callsetup\",(0-3)),(\"service\",(0-1)),(\"signal\",(0-5)),(\"roam\",(0,1)),(\"battchg\",(0-5)),(\"callheld\",(0-2))"
#endif

#ifndef BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY
#define BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY TRUE
#endif

/******************************************************************************
**