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

Commit 4f0bf1a0 authored by Anubhav Gupta's avatar Anubhav Gupta Committed by Andre Eisenbach
Browse files

Override remote suspend flag on local play state changes

- Remote device may initiate AVDTP Suspend within 3s of AVRCP pause,
  which sets remote suspend flag. Later on resumption of local playback
  A2DP packets can not be processed further as Remote suspend flag
  remains set. current change overrides remote suspend flag if local
  suspend is triggered later.
- This change covers the usecase where play is pressed from DUT UI
  before local suspend triggers in such scenarios current change takes
  care of resetitng remote suspend flag on AVRCP play state change event.
- Moreover this change will drop A2DP packets when the setparameter
  is called with A2dpSuspended=true and resumes when the mentioned parameter
  is reset.

This change along with corresponding app change helps mitigating
issues reported due to A2Dp, HFP synchronizations and local and remote
device initiated AVDTP suspend handling.

Bug: 22028876
Change-Id:  I3bb334373414170254744d9233cbd2e66219bfa0
parent b23562fa
Loading
Loading
Loading
Loading
+17 −12
Original line number Original line Diff line number Diff line
@@ -348,6 +348,8 @@ static int a2dp_command(struct a2dp_stream_common *common, char cmd)


    DEBUG("A2DP COMMAND %s DONE STATUS %d", dump_a2dp_ctrl_event(cmd), ack);
    DEBUG("A2DP COMMAND %s DONE STATUS %d", dump_a2dp_ctrl_event(cmd), ack);


    if (ack == A2DP_CTRL_ACK_INCALL_FAILURE)
        return ack;
    if (ack != A2DP_CTRL_ACK_SUCCESS)
    if (ack != A2DP_CTRL_ACK_SUCCESS)
        return -1;
        return -1;


@@ -441,24 +443,30 @@ static void a2dp_stream_common_init(struct a2dp_stream_common *common)


static int start_audio_datapath(struct a2dp_stream_common *common)
static int start_audio_datapath(struct a2dp_stream_common *common)
{
{
    int oldstate = common->state;

    INFO("state %d", common->state);
    INFO("state %d", common->state);


    if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {
    if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {
        INFO("AUDIO_SKT_DISCONNECTED");
        INFO("%s AUDIO_SKT_DISCONNECTED", __func__);
        return -1;
        return -1;
    }
    }


    int oldstate = common->state;
    common->state = AUDIO_A2DP_STATE_STARTING;
    common->state = AUDIO_A2DP_STATE_STARTING;


    if (a2dp_command(common, A2DP_CTRL_CMD_START) < 0)
    int a2dp_status = a2dp_command(common, A2DP_CTRL_CMD_START);
    if (a2dp_status < 0)
    {
    {
        ERROR("audiopath start failed");
        ERROR("%s Audiopath start failed (status %d)", __func__, a2dp_status);


        common->state = oldstate;
        common->state = oldstate;
        return -1;
        return -1;
    }
    }
    else if (a2dp_status == A2DP_CTRL_ACK_INCALL_FAILURE)
    {
        ERROR("%s Audiopath start failed - in call, move to suspended", __func__);
        common->state = oldstate;
        return -1;
    }


    /* connect socket if not yet connected */
    /* connect socket if not yet connected */
    if (common->audio_fd == AUDIO_SKT_DISCONNECTED)
    if (common->audio_fd == AUDIO_SKT_DISCONNECTED)
@@ -476,7 +484,6 @@ static int start_audio_datapath(struct a2dp_stream_common *common)
    return 0;
    return 0;
}
}



static int stop_audio_datapath(struct a2dp_stream_common *common)
static int stop_audio_datapath(struct a2dp_stream_common *common)
{
{
    int oldstate = common->state;
    int oldstate = common->state;
@@ -666,11 +673,9 @@ static int out_standby(struct audio_stream *stream)
    FNLOG();
    FNLOG();


    pthread_mutex_lock(&out->common.lock);
    pthread_mutex_lock(&out->common.lock);

    // Do nothing in SUSPENDED state.
    if (out->common.state == AUDIO_A2DP_STATE_STARTED)
    if (out->common.state != AUDIO_A2DP_STATE_SUSPENDED)
        retVal = suspend_audio_datapath(&out->common, true);
        retVal = suspend_audio_datapath(&out->common, true);
    else
        retVal = 0;
    pthread_mutex_unlock (&out->common.lock);
    pthread_mutex_unlock (&out->common.lock);


    return retVal;
    return retVal;
+2 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,8 @@ typedef enum {


typedef enum {
typedef enum {
    A2DP_CTRL_ACK_SUCCESS,
    A2DP_CTRL_ACK_SUCCESS,
    A2DP_CTRL_ACK_FAILURE
    A2DP_CTRL_ACK_FAILURE,
    A2DP_CTRL_ACK_INCALL_FAILURE /* Failure when in Call*/
} tA2DP_CTRL_ACK;
} tA2DP_CTRL_ACK;




+10 −0
Original line number Original line Diff line number Diff line
@@ -141,4 +141,14 @@ BOOLEAN btif_av_is_connected(void);


BOOLEAN btif_av_is_peer_edr(void);
BOOLEAN btif_av_is_peer_edr(void);


/******************************************************************************
**
** Function         btif_av_clear_remote_suspend_flag
**
** Description      Clears remote suspended flag
**
** Returns          Void
********************************************************************************/
void btif_av_clear_remote_suspend_flag(void);

#endif /* BTIF_AV_H */
#endif /* BTIF_AV_H */
+13 −0
Original line number Original line Diff line number Diff line
@@ -1372,3 +1372,16 @@ BOOLEAN btif_av_is_peer_edr(void)
        return FALSE;
        return FALSE;
}
}


/******************************************************************************
**
** Function        btif_av_clear_remote_suspend_flag
**
** Description     Clears btif_av_cd.flags if BTIF_AV_FLAG_REMOTE_SUSPEND is set
**
** Returns          void
******************************************************************************/
void btif_av_clear_remote_suspend_flag(void)
{
    BTIF_TRACE_DEBUG("%s: flag :%x",__func__, btif_av_cb.flags);
    btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
}
+23 −0
Original line number Original line Diff line number Diff line
@@ -1465,6 +1465,29 @@ update_call_states:
    return status;
    return status;
}
}


/*******************************************************************************
**
** Function         btif_hf_is_call_idle
**
** Description      returns true if no call is in progress
**
** Returns          bt_status_t
**
*******************************************************************************/
BOOLEAN btif_hf_is_call_idle()
{
    if (bt_hf_callbacks == NULL)
        return TRUE;

    for (int i = 0; i < btif_max_hf_clients; ++i)
    {
        if ((btif_hf_cb[i].call_setup_state != BTHF_CALL_STATE_IDLE)
            || ((btif_hf_cb[i].num_held + btif_hf_cb[i].num_active) > 0))
            return FALSE;
    }

    return TRUE;
}


/*******************************************************************************
/*******************************************************************************
**
**
Loading