mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(bt/bluedroid): check HFP audio status before forwarding SCO data
This commit is contained in:
@@ -645,8 +645,10 @@ esp_err_t esp_hf_client_audio_data_send(esp_hf_sync_conn_hdl_t sync_conn_hdl, es
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
BTA_HfClientAudioDataSend(sync_conn_hdl, (uint8_t *)audio_buf, audio_buf->data, audio_buf->data_len);
|
||||
return ESP_OK;
|
||||
if (btc_hf_client_audio_data_send(sync_conn_hdl, (uint8_t *)audio_buf, audio_buf->data, audio_buf->data_len) == BT_STATUS_SUCCESS) {
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_pcm_resample_init(uint32_t src_sps, uint32_t bits, uint32_t channels)
|
||||
|
||||
@@ -719,6 +719,8 @@ void esp_hf_ag_audio_buff_free(esp_hf_audio_buff_t *audio_buf);
|
||||
* If the length of the audio data is equal to preferred_frame_size indicated by
|
||||
* ESP_HF_AUDIO_STATE_EVT, then we can reduce one memory copy inside the Bluedroid stack.
|
||||
* This function is only used in the case that Voice Over HCI is enabled.
|
||||
* On success, the stack takes ownership of audio_buf and will free it internally.
|
||||
* On failure, the caller is responsible for freeing audio_buf with esp_hf_ag_audio_buff_free.
|
||||
*
|
||||
* @param[in] sync_conn_hdl: (e)SCO connection handle
|
||||
*
|
||||
|
||||
@@ -719,6 +719,8 @@ void esp_hf_client_audio_buff_free(esp_hf_audio_buff_t *audio_buf);
|
||||
* If the length of the audio data is equal to preferred_frame_size indicated by
|
||||
* ESP_HF_CLIENT_AUDIO_STATE_EVT, then we can reduce one memory copy inside the Bluedroid stack.
|
||||
* This function is only used in the case that Voice Over HCI is enabled.
|
||||
* On success, the stack takes ownership of audio_buf and will free it internally.
|
||||
* On failure, the caller is responsible for freeing audio_buf with esp_hf_client_audio_buff_free.
|
||||
*
|
||||
* @param[in] sync_conn_hdl: (e)SCO connection handle
|
||||
*
|
||||
@@ -728,6 +730,7 @@ void esp_hf_client_audio_buff_free(esp_hf_audio_buff_t *audio_buf);
|
||||
* - ESP_OK: success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: invalid parameter
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_audio_data_send(esp_hf_sync_conn_hdl_t sync_conn_hdl, esp_hf_audio_buff_t *audio_buf);
|
||||
|
||||
@@ -1013,10 +1013,10 @@ bt_status_t btc_hf_ci_sco_data(void)
|
||||
bt_status_t btc_hf_ag_audio_data_send(uint16_t sync_conn_hdl, uint8_t *p_buff_start, uint8_t *p_data, uint8_t data_len)
|
||||
{
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE) && (BTA_HFP_EXT_CODEC == TRUE)
|
||||
/* currently, sync_conn_hdl is not used */
|
||||
int idx = btc_hf_latest_connected_idx();
|
||||
CHECK_HF_SLC_CONNECTED(idx);
|
||||
if (idx != BTC_HF_INVALID_IDX) {
|
||||
|
||||
if (sync_conn_hdl != ESP_INVALID_CONN_HANDLE && hf_local_param.btc_hf_cb[idx].sync_conn_hdl == sync_conn_hdl) {
|
||||
BTA_AgAudioDataSend(hf_local_param.btc_hf_cb[idx].handle, p_buff_start, p_data, data_len);
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -357,6 +357,19 @@ bt_status_t btc_hf_client_disconnect_audio( bt_bdaddr_t *bd_addr )
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
bt_status_t btc_hf_client_audio_data_send(uint16_t sync_conn_hdl, uint8_t *p_buff_start, uint8_t *p_data, uint8_t data_len)
|
||||
{
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE) && (BTA_HFP_EXT_CODEC == TRUE)
|
||||
CHECK_HF_CLIENT_SLC_CONNECTED();
|
||||
|
||||
if (sync_conn_hdl != ESP_INVALID_CONN_HANDLE && hf_client_local_param.btc_hf_client_cb.sync_conn_hdl == sync_conn_hdl) {
|
||||
BTA_HfClientAudioDataSend(sync_conn_hdl, p_buff_start, p_data, data_len);
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_hf_client_start_voice_recognition
|
||||
|
||||
@@ -176,6 +176,8 @@ void btc_hf_client_incoming_data_cb_to_app(const uint8_t *data, uint32_t len);
|
||||
|
||||
uint32_t btc_hf_client_outgoing_data_cb_to_app(uint8_t *data, uint32_t len);
|
||||
|
||||
bt_status_t btc_hf_client_audio_data_send(uint16_t sync_conn_hdl, uint8_t *p_buff_start, uint8_t *p_data, uint8_t data_len);
|
||||
|
||||
void btc_hf_client_get_profile_status(esp_hf_client_profile_status_t *param);
|
||||
#endif ///BTC_HF_CLIENT_INCLUDED == TRUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user