fix(bt/bluedroid): check HFP audio status before forwarding SCO data

This commit is contained in:
linruihao
2026-09-17 09:32:45 +08:00
parent 90f3513994
commit d783f9f02d
6 changed files with 26 additions and 4 deletions
@@ -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)
@@ -689,6 +689,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
*
@@ -715,6 +715,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
*
@@ -724,6 +726,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);