From bf67b2dbb05485fd6358b78287317d204c3d60cc Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 8 Feb 2021 11:36:17 +0100 Subject: [PATCH] avrcp: request can send now again for controller if both want to send --- src/classic/avrcp.c | 17 +++++++++++------ src/classic/avrcp_target.c | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/classic/avrcp.c b/src/classic/avrcp.c index f6f1d2c08..45ba7a7a2 100644 --- a/src/classic/avrcp.c +++ b/src/classic/avrcp.c @@ -726,7 +726,8 @@ static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t avrcp_connection_t * connection_controller; avrcp_connection_t * connection_target; - + bool can_send; + switch (packet_type) { case HCI_EVENT_PACKET: switch (hci_event_packet_get_type(packet)) { @@ -843,19 +844,23 @@ static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t case L2CAP_EVENT_CAN_SEND_NOW: local_cid = l2cap_event_can_send_now_get_local_cid(packet); - + can_send = true; + connection_target = avrcp_get_connection_for_l2cap_signaling_cid_for_role(AVRCP_TARGET, local_cid); if ((connection_target != NULL) && connection_target->wait_to_send){ connection_target->wait_to_send = false; (*avrcp_target_packet_handler)(HCI_EVENT_PACKET, channel, packet, size); - break; + can_send = false; } connection_controller = avrcp_get_connection_for_l2cap_signaling_cid_for_role(AVRCP_CONTROLLER, local_cid); if ((connection_controller != NULL) && connection_controller->wait_to_send){ - connection_controller->wait_to_send = false; - (*avrcp_controller_packet_handler)(HCI_EVENT_PACKET, channel, packet, size); - break; + if (can_send){ + connection_controller->wait_to_send = false; + (*avrcp_controller_packet_handler)(HCI_EVENT_PACKET, channel, packet, size); + } else { + l2cap_request_can_send_now_event(local_cid); + } } break; diff --git a/src/classic/avrcp_target.c b/src/classic/avrcp_target.c index 01a29f856..521f9b217 100644 --- a/src/classic/avrcp_target.c +++ b/src/classic/avrcp_target.c @@ -325,7 +325,6 @@ static int avrcp_target_send_response(uint16_t cid, avrcp_connection_t * connect connection->cmd_operands_length); pos += connection->cmd_operands_length; - connection->wait_to_send = false; return l2cap_send_prepared(cid, pos); } @@ -1055,7 +1054,7 @@ static int avrcp_target_send_notification(uint16_t cid, avrcp_connection_t * con (void)memcpy(packet + pos, value, value_len); pos += value_len; } - connection->wait_to_send = false; + return l2cap_send_prepared(cid, pos); }