kopia lustrzana https://github.com/espressif/esp-idf
component/bt: Fix bug a2dp have disconnect state when connecting with iphone 7
rodzic
b827e0e331
commit
cbab7fec76
|
@ -38,6 +38,7 @@
|
||||||
#include "btc_a2dp_sink.h"
|
#include "btc_a2dp_sink.h"
|
||||||
#include "btc_a2dp_source.h"
|
#include "btc_a2dp_source.h"
|
||||||
#include "esp_a2dp_api.h"
|
#include "esp_a2dp_api.h"
|
||||||
|
#include "osi/alarm.h"
|
||||||
|
|
||||||
#if BTC_AV_INCLUDED
|
#if BTC_AV_INCLUDED
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ typedef struct {
|
||||||
} btc_av_cb_t;
|
} btc_av_cb_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bt_bdaddr_t *target_bda;
|
bt_bdaddr_t target_bda;
|
||||||
uint16_t uuid;
|
uint16_t uuid;
|
||||||
} btc_av_connect_req_t;
|
} btc_av_connect_req_t;
|
||||||
|
|
||||||
|
@ -88,7 +89,10 @@ typedef struct {
|
||||||
** Static variables
|
** Static variables
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static btc_av_cb_t btc_av_cb = {0};
|
static btc_av_cb_t btc_av_cb = {0};
|
||||||
static TIMER_LIST_ENT tle_av_open_on_rc;
|
|
||||||
|
#if BTC_AV_SRC_INCLUDED
|
||||||
|
static osi_alarm_t *tle_av_open_on_rc = NULL;
|
||||||
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
|
|
||||||
/* both interface and media task needs to be ready to alloc incoming request */
|
/* both interface and media task needs to be ready to alloc incoming request */
|
||||||
#define CHECK_BTAV_INIT() do \
|
#define CHECK_BTAV_INIT() do \
|
||||||
|
@ -204,6 +208,7 @@ UNUSED_ATTR static const char *dump_av_sm_event_name(btc_av_sm_event_t event)
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Local helper functions
|
** Local helper functions
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
#if BTC_AV_SRC_INCLUDED
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function btc_initiate_av_open_tmr_hdlr
|
** Function btc_initiate_av_open_tmr_hdlr
|
||||||
|
@ -215,23 +220,23 @@ UNUSED_ATTR static const char *dump_av_sm_event_name(btc_av_sm_event_t event)
|
||||||
** Returns void
|
** Returns void
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
static void btc_initiate_av_open_tmr_hdlr(TIMER_LIST_ENT *tle)
|
static void btc_initiate_av_open_tmr_hdlr(void *arg)
|
||||||
{
|
{
|
||||||
|
UNUSED(arg);
|
||||||
BD_ADDR peer_addr;
|
BD_ADDR peer_addr;
|
||||||
UNUSED(tle);
|
|
||||||
btc_av_connect_req_t connect_req;
|
btc_av_connect_req_t connect_req;
|
||||||
UNUSED(tle);
|
|
||||||
/* is there at least one RC connection - There should be */
|
/* is there at least one RC connection - There should be */
|
||||||
if (btc_rc_get_connected_peer(peer_addr)) {
|
if (btc_rc_get_connected_peer(peer_addr)) {
|
||||||
LOG_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
|
LOG_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
|
||||||
/* In case of AVRCP connection request, we will initiate SRC connection */
|
/* In case of AVRCP connection request, we will initiate SRC connection */
|
||||||
connect_req.target_bda = (bt_bdaddr_t *)&peer_addr;
|
memcpy(connect_req.target_bda.address, peer_addr, sizeof(bt_bdaddr_t));
|
||||||
connect_req.uuid = UUID_SERVCLASS_AUDIO_SOURCE;
|
connect_req.uuid = UUID_SERVCLASS_AUDIO_SOURCE;
|
||||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_CONNECT_REQ_EVT, (char *)&connect_req);
|
btc_dispatch_sm_event(BTC_AV_CONNECT_REQ_EVT, &connect_req, sizeof(btc_av_connect_req_t));
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("%s No connected RC peers", __FUNCTION__);
|
LOG_ERROR("%s No connected RC peers", __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** Static functions
|
** Static functions
|
||||||
|
@ -303,7 +308,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||||
case BTA_AV_PENDING_EVT:
|
case BTA_AV_PENDING_EVT:
|
||||||
case BTC_AV_CONNECT_REQ_EVT: {
|
case BTC_AV_CONNECT_REQ_EVT: {
|
||||||
if (event == BTC_AV_CONNECT_REQ_EVT) {
|
if (event == BTC_AV_CONNECT_REQ_EVT) {
|
||||||
memcpy(&btc_av_cb.peer_bda, ((btc_av_connect_req_t *)p_data)->target_bda,
|
memcpy(&btc_av_cb.peer_bda, &((btc_av_connect_req_t *)p_data)->target_bda,
|
||||||
sizeof(bt_bdaddr_t));
|
sizeof(bt_bdaddr_t));
|
||||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||||
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||||
|
@ -326,11 +331,11 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||||
* TODO: We may need to do this only on an AVRCP Play. FixMe
|
* TODO: We may need to do this only on an AVRCP Play. FixMe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if BTC_AV_SRC_INCLUDED
|
||||||
LOG_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
|
LOG_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
|
||||||
memset(&tle_av_open_on_rc, 0, sizeof(tle_av_open_on_rc));
|
tle_av_open_on_rc = osi_alarm_new("AVconn", btc_initiate_av_open_tmr_hdlr, NULL, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000);
|
||||||
tle_av_open_on_rc.param = (UINT32)btc_initiate_av_open_tmr_hdlr;
|
osi_alarm_set(tle_av_open_on_rc, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000);
|
||||||
btu_start_timer(&tle_av_open_on_rc, BTU_TTYPE_USER_FUNC,
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
BTC_TIMEOUT_AV_OPEN_ON_RC_SECS);
|
|
||||||
btc_rc_handler(event, p_data);
|
btc_rc_handler(event, p_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -343,10 +348,12 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BTA_AV_RC_CLOSE_EVT:
|
case BTA_AV_RC_CLOSE_EVT:
|
||||||
if (tle_av_open_on_rc.in_use) {
|
#if BTC_AV_SRC_INCLUDED
|
||||||
LOG_DEBUG("BTA_AV_RC_CLOSE_EVT: Stopping AV timer.");
|
if (tle_av_open_on_rc) {
|
||||||
btu_stop_timer(&tle_av_open_on_rc);
|
osi_alarm_free(tle_av_open_on_rc);
|
||||||
|
tle_av_open_on_rc = NULL;
|
||||||
}
|
}
|
||||||
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
btc_rc_handler(event, p_data);
|
btc_rc_handler(event, p_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -681,7 +688,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BTC_AV_CONNECT_REQ_EVT:
|
case BTC_AV_CONNECT_REQ_EVT:
|
||||||
if (memcmp ((bt_bdaddr_t *)p_data, &(btc_av_cb.peer_bda),
|
if (memcmp (&((btc_av_connect_req_t *)p_data)->target_bda, &(btc_av_cb.peer_bda),
|
||||||
sizeof(btc_av_cb.peer_bda)) == 0) {
|
sizeof(btc_av_cb.peer_bda)) == 0) {
|
||||||
LOG_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__);
|
LOG_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__);
|
||||||
} else {
|
} else {
|
||||||
|
@ -996,7 +1003,7 @@ static bt_status_t btc_av_init(int service_id)
|
||||||
static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
|
static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
|
||||||
{
|
{
|
||||||
btc_av_connect_req_t connect_req;
|
btc_av_connect_req_t connect_req;
|
||||||
connect_req.target_bda = bd_addr;
|
memcpy(&connect_req.target_bda, bd_addr, sizeof(bt_bdaddr_t));
|
||||||
connect_req.uuid = uuid;
|
connect_req.uuid = uuid;
|
||||||
LOG_DEBUG("%s\n", __FUNCTION__);
|
LOG_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
@ -1021,6 +1028,10 @@ static void clean_up(int service_id)
|
||||||
if (service_id == BTA_A2DP_SOURCE_SERVICE_ID) {
|
if (service_id == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||||
#if BTC_AV_SRC_INCLUDED
|
#if BTC_AV_SRC_INCLUDED
|
||||||
btc_a2dp_source_shutdown();
|
btc_a2dp_source_shutdown();
|
||||||
|
if (tle_av_open_on_rc) {
|
||||||
|
osi_alarm_free(tle_av_open_on_rc);
|
||||||
|
tle_av_open_on_rc = NULL;
|
||||||
|
}
|
||||||
#endif /* BTC_AV_SRC_INCLUDED */
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1371,6 +1382,9 @@ void btc_a2dp_call_handler(btc_msg_t *msg)
|
||||||
btc_a2dp_control_datapath_ctrl(arg->dp_evt);
|
btc_a2dp_control_datapath_ctrl(arg->dp_evt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case BTC_AV_CONNECT_REQ_EVT:
|
||||||
|
btc_sm_dispatch(btc_av_cb.sm_handle, msg->act, (char *)msg->arg);
|
||||||
|
break;
|
||||||
// case BTC_AV_DISCONNECT_REQ_EVT:
|
// case BTC_AV_DISCONNECT_REQ_EVT:
|
||||||
case BTC_AV_START_STREAM_REQ_EVT:
|
case BTC_AV_START_STREAM_REQ_EVT:
|
||||||
case BTC_AV_STOP_STREAM_REQ_EVT:
|
case BTC_AV_STOP_STREAM_REQ_EVT:
|
||||||
|
|
Ładowanie…
Reference in New Issue