mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
1.revert dummy command
2.fix send MEDIA_CTRL command in disconnect
This commit is contained in:
parent
3db75c4e9d
commit
09e48edd87
@ -76,7 +76,7 @@ typedef enum {
|
|||||||
|
|
||||||
/// A2DP media control commands
|
/// A2DP media control commands
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< Not for application use, use inside stack only. */
|
||||||
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
||||||
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
||||||
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#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 "btc_avrc.h"
|
|
||||||
|
|
||||||
#if BTC_AV_INCLUDED
|
#if BTC_AV_INCLUDED
|
||||||
|
|
||||||
@ -60,13 +59,11 @@ static inline void a2dp_cmd_acknowledge(int cmd, int status)
|
|||||||
|
|
||||||
void btc_a2dp_control_command_ack(int status)
|
void btc_a2dp_control_command_ack(int status)
|
||||||
{
|
{
|
||||||
/* sanity check
|
/* sanity check */
|
||||||
if (btc_aa_ctrl_cb.a2dp_cmd_pending == ESP_A2D_MEDIA_CTRL_NONE) {
|
if (btc_aa_ctrl_cb.a2dp_cmd_pending == ESP_A2D_MEDIA_CTRL_NONE) {
|
||||||
APPL_TRACE_ERROR("warning : no command pending, ignore ack");
|
APPL_TRACE_ERROR("warning : no command pending, ignore ack");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* clear pending */
|
/* clear pending */
|
||||||
int cmd = btc_aa_ctrl_cb.a2dp_cmd_pending;
|
int cmd = btc_aa_ctrl_cb.a2dp_cmd_pending;
|
||||||
@ -129,7 +126,7 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||||||
|
|
||||||
switch (ctrl) {
|
switch (ctrl) {
|
||||||
case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY:
|
case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY:
|
||||||
//#if BTC_AV_SRC_INCLUDED
|
#if BTC_AV_SRC_INCLUDED
|
||||||
if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||||
if (btc_a2dp_source_is_task_shutting_down()) {
|
if (btc_a2dp_source_is_task_shutting_down()) {
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
@ -139,15 +136,13 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
}
|
}
|
||||||
//#else /* BTC_AV_SRC_INCLUDED */
|
#else /* BTC_AV_SRC_INCLUDED */
|
||||||
//if (btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
//btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
#endif /* #if BTC_AV_SRC_INCLUDED */
|
||||||
//} /
|
|
||||||
//#endif /* #if BTC_AV_SRC_INCLUDED */
|
|
||||||
break;
|
break;
|
||||||
case ESP_A2D_MEDIA_CTRL_START:
|
case ESP_A2D_MEDIA_CTRL_START:
|
||||||
if (btc_av_stream_ready() == TRUE ) {
|
if (btc_av_stream_ready() == TRUE ) {
|
||||||
@ -168,24 +163,22 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_A2D_MEDIA_CTRL_STOP:
|
case ESP_A2D_MEDIA_CTRL_STOP:
|
||||||
|
if (btc_av_is_connected() == FALSE) {
|
||||||
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
#if BTC_AV_SRC_INCLUDED
|
#if BTC_AV_SRC_INCLUDED
|
||||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
|
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
|
||||||
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID && btc_av_is_peer_edr() == TRUE) {
|
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||||
/* we are already stopped, just ack back*/
|
/* we are already stopped, just ack back*/
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||||
break;
|
break;
|
||||||
/* check if connect a2dp */
|
|
||||||
} else if (btc_av_is_peer_edr() == FALSE){
|
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
|
||||||
}
|
}
|
||||||
#endif /* BTC_AV_SRC_INCLUDED */
|
#endif /* BTC_AV_SRC_INCLUDED */
|
||||||
btc_dispatch_sm_event(BTC_AV_STOP_STREAM_REQ_EVT, NULL, 0);
|
btc_dispatch_sm_event(BTC_AV_STOP_STREAM_REQ_EVT, NULL, 0);
|
||||||
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
||||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID &&
|
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||||
btc_av_is_peer_edr() == TRUE) {
|
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||||
} else if (btc_av_is_peer_edr() == FALSE){
|
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -194,14 +187,11 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||||||
if (btc_av_stream_started_ready()) {
|
if (btc_av_stream_started_ready()) {
|
||||||
btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
|
btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
|
||||||
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
||||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID &&
|
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||||
btc_av_is_peer_edr() == TRUE) {
|
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||||
} else if (btc_av_is_peer_edr() == FALSE) {
|
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (btc_av_is_peer_edr() == TRUE){
|
} else if (btc_av_is_connected() == TRUE) {
|
||||||
/* we are not in started state; just ack back ok. This can happen if we are
|
/* we are not in started state; just ack back ok. This can happen if we are
|
||||||
remotely suspended; clear REMOTE SUSPEND Flag */
|
remotely suspended; clear REMOTE SUSPEND Flag */
|
||||||
btc_av_clear_remote_suspend_flag();
|
btc_av_clear_remote_suspend_flag();
|
||||||
@ -210,7 +200,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl);
|
APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl);
|
||||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||||
|
Loading…
Reference in New Issue
Block a user