mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 04:34:31 +02:00
component/bt: A2DP clean-up
1. remove unused file audio_a2dp_hw.c 2. remove "BTIF_AV_SRC_INCLUDED" enclosed codes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,14 +25,10 @@
|
|||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
// #include <assert.h>
|
|
||||||
#include "bt_trace.h"
|
#include "bt_trace.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// #include <hardware/bluetooth.h>
|
|
||||||
#include "bt_defs.h"
|
#include "bt_defs.h"
|
||||||
// #include <system/audio.h>
|
|
||||||
// #include "bt_av.h"
|
|
||||||
#include "esp_bt_defs.h"
|
#include "esp_bt_defs.h"
|
||||||
#include "esp_a2dp_api.h"
|
#include "esp_a2dp_api.h"
|
||||||
#include "allocator.h"
|
#include "allocator.h"
|
||||||
@@ -438,13 +434,6 @@ static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *p_data
|
|||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTIF_SM_ENTER_EVT:
|
case BTIF_SM_ENTER_EVT:
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
/* immediately stop transmission of frames */
|
|
||||||
btif_a2dp_set_tx_flush(TRUE);
|
|
||||||
/* wait for audioflinger to stop a2dp */
|
|
||||||
}
|
|
||||||
#endif /* (BTIF_AV_SRC_INCLUDED == TRUE) */
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||||
btif_a2dp_set_rx_flush(TRUE);
|
btif_a2dp_set_rx_flush(TRUE);
|
||||||
}
|
}
|
||||||
@@ -452,12 +441,6 @@ static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *p_data
|
|||||||
|
|
||||||
case BTA_AV_STOP_EVT:
|
case BTA_AV_STOP_EVT:
|
||||||
case BTIF_AV_STOP_STREAM_REQ_EVT:
|
case BTIF_AV_STOP_STREAM_REQ_EVT:
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
/* immediately flush any pending tx frames while suspend is pending */
|
|
||||||
btif_a2dp_set_tx_flush(TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||||
btif_a2dp_set_rx_flush(TRUE);
|
btif_a2dp_set_rx_flush(TRUE);
|
||||||
}
|
}
|
||||||
@@ -525,11 +508,6 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BTIF_AV_START_STREAM_REQ_EVT:
|
case BTIF_AV_START_STREAM_REQ_EVT:
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep != AVDT_TSEP_SRC) {
|
|
||||||
btif_a2dp_setup_codec();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
BTA_AvStart();
|
BTA_AvStart();
|
||||||
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_START;
|
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_START;
|
||||||
break;
|
break;
|
||||||
@@ -542,27 +520,6 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
/* if remote tries to start a2dp when DUT is a2dp source
|
|
||||||
* then suspend. In case a2dp is sink and call is active
|
|
||||||
* then disconnect the AVDTP channel
|
|
||||||
*/
|
|
||||||
if (!(btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START)) {
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
BTIF_TRACE_EVENT("%s: trigger suspend as remote initiated!!\n", __FUNCTION__);
|
|
||||||
btif_dispatch_sm_event(BTIF_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case peer is A2DP SRC we do not want to ack commands on UIPC*/
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
if (btif_a2dp_on_started(&p_av->start,
|
|
||||||
((btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) != 0))) {
|
|
||||||
/* only clear pending flag after acknowledgement */
|
|
||||||
btif_av_cb.flags &= ~BTIF_AV_FLAG_PENDING_START;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* remain in open state if status failed */
|
/* remain in open state if status failed */
|
||||||
if (p_av->start.status != BTA_AV_SUCCESS) {
|
if (p_av->start.status != BTA_AV_SUCCESS) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -574,11 +531,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
|
|||||||
|
|
||||||
/* change state to started, send acknowledgement if start is pending */
|
/* change state to started, send acknowledgement if start is pending */
|
||||||
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
|
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
btif_a2dp_on_started(NULL, TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* pending start flag will be cleared when exit current state */
|
/* pending start flag will be cleared when exit current state */
|
||||||
}
|
}
|
||||||
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
|
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
|
||||||
@@ -679,12 +632,6 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BTIF_AV_START_STREAM_REQ_EVT:
|
case BTIF_AV_START_STREAM_REQ_EVT:
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
/* we were remotely started, just ack back the local request */
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
btif_a2dp_on_started(NULL, TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* fixme -- use suspend = true always to work around issue with BTA AV */
|
/* fixme -- use suspend = true always to work around issue with BTA AV */
|
||||||
@@ -698,12 +645,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
|||||||
/* if we were remotely suspended but suspend locally, local suspend
|
/* if we were remotely suspended but suspend locally, local suspend
|
||||||
always overrides */
|
always overrides */
|
||||||
btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
|
btif_av_cb.flags &= ~BTIF_AV_FLAG_REMOTE_SUSPEND;
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
/* immediately stop transmission of frames while suspend is pending */
|
|
||||||
btif_a2dp_set_tx_flush(TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
if (btif_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||||
btif_a2dp_set_rx_flush(TRUE);
|
btif_a2dp_set_rx_flush(TRUE);
|
||||||
btif_a2dp_on_stopped(NULL);
|
btif_a2dp_on_stopped(NULL);
|
||||||
@@ -735,12 +677,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
|
|||||||
/* if not successful, remain in current state */
|
/* if not successful, remain in current state */
|
||||||
if (p_av->suspend.status != BTA_AV_SUCCESS) {
|
if (p_av->suspend.status != BTA_AV_SUCCESS) {
|
||||||
btif_av_cb.flags &= ~BTIF_AV_FLAG_LOCAL_SUSPEND_PENDING;
|
btif_av_cb.flags &= ~BTIF_AV_FLAG_LOCAL_SUSPEND_PENDING;
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
if (btif_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
|
||||||
/* suspend failed, reset back tx flush state */
|
|
||||||
btif_a2dp_set_tx_flush(FALSE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,31 +885,6 @@ bt_status_t btif_av_init()
|
|||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
** Function init_src
|
|
||||||
**
|
|
||||||
** Description Initializes the AV interface for source mode
|
|
||||||
**
|
|
||||||
** Returns bt_status_t
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
static bt_status_t init_src(btav_callbacks_t *callbacks)
|
|
||||||
{
|
|
||||||
BTIF_TRACE_EVENT("%s()\n", __func__);
|
|
||||||
|
|
||||||
bt_status_t status = btif_av_init();
|
|
||||||
if (status == BT_STATUS_SUCCESS) {
|
|
||||||
bt_av_src_callbacks = callbacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Function register A2DP callback
|
* Function register A2DP callback
|
||||||
@@ -1028,18 +940,7 @@ static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
|
|||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
static bt_status_t src_connect_sink(bt_bdaddr_t *bd_addr)
|
|
||||||
{
|
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
|
||||||
CHECK_BTAV_INIT();
|
|
||||||
|
|
||||||
return btif_queue_connect(UUID_SERVCLASS_AUDIO_SOURCE, bd_addr, connect_int);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
esp_err_t esp_a2d_sink_connect(esp_bd_addr_t *remote_bda)
|
esp_err_t esp_a2d_sink_connect(esp_bd_addr_t *remote_bda)
|
||||||
// static bt_status_t sink_connect_src(bt_bdaddr_t *bd_addr)
|
|
||||||
{
|
{
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||||
CHECK_BTAV_INIT();
|
CHECK_BTAV_INIT();
|
||||||
@@ -1052,26 +953,6 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t *remote_bda)
|
|||||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
** Function disconnect
|
|
||||||
**
|
|
||||||
** Description Tears down the AV signalling channel with the remote headset
|
|
||||||
**
|
|
||||||
** Returns bt_status_t
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
static bt_status_t disconnect(bt_bdaddr_t *bd_addr)
|
|
||||||
{
|
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
|
||||||
|
|
||||||
CHECK_BTAV_INIT();
|
|
||||||
|
|
||||||
/* Switch to BTIF context */
|
|
||||||
return btif_transfer_context(btif_av_handle_event, BTIF_AV_DISCONNECT_REQ_EVT,
|
|
||||||
(char *)bd_addr, sizeof(bt_bdaddr_t), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t *remote_bda)
|
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t *remote_bda)
|
||||||
{
|
{
|
||||||
bt_status_t stat;
|
bt_status_t stat;
|
||||||
@@ -1109,20 +990,6 @@ static void cleanup(void)
|
|||||||
btif_av_cb.sm_handle = NULL;
|
btif_av_cb.sm_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
static void cleanup_src(void)
|
|
||||||
{
|
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
|
||||||
|
|
||||||
if (bt_av_src_callbacks) {
|
|
||||||
bt_av_src_callbacks = NULL;
|
|
||||||
if (bt_av_sink_callbacks == NULL) {
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void esp_a2d_sink_deinit(void)
|
void esp_a2d_sink_deinit(void)
|
||||||
{
|
{
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||||
@@ -1133,25 +1000,6 @@ void esp_a2d_sink_deinit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
static const btav_interface_t bt_av_src_interface = {
|
|
||||||
sizeof(btav_interface_t),
|
|
||||||
init_src,
|
|
||||||
src_connect_sink,
|
|
||||||
disconnect,
|
|
||||||
cleanup_src,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
static const btav_interface_t bt_av_sink_interface = {
|
|
||||||
sizeof(btav_interface_t),
|
|
||||||
init_sink,
|
|
||||||
sink_connect_src,
|
|
||||||
disconnect,
|
|
||||||
cleanup_sink,
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function btif_av_get_sm_handle
|
** Function btif_av_get_sm_handle
|
||||||
@@ -1288,24 +1136,6 @@ bt_status_t btif_av_sink_execute_service(BOOLEAN b_enable)
|
|||||||
return BT_STATUS_SUCCESS;
|
return BT_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (BTIF_AV_SRC_INCLUDED == TRUE)
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
** Function btif_av_get_src_interface
|
|
||||||
**
|
|
||||||
** Description Get the AV callback interface for A2DP source profile
|
|
||||||
**
|
|
||||||
** Returns btav_interface_t
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
const btav_interface_t *btif_av_get_src_interface(void)
|
|
||||||
{
|
|
||||||
BTIF_TRACE_EVENT("%s\n", __FUNCTION__);
|
|
||||||
return &bt_av_src_interface;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function btif_av_is_connected
|
** Function btif_av_is_connected
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@
|
|||||||
#include "bta_api.h"
|
#include "bta_api.h"
|
||||||
#include "gki.h"
|
#include "gki.h"
|
||||||
#include "btif_av_api.h"
|
#include "btif_av_api.h"
|
||||||
#include "audio_a2dp_hw.h"
|
// #include "audio_a2dp_hw.h"
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Constants
|
** Constants
|
||||||
|
Reference in New Issue
Block a user