From 22bed8e12d36d8545a8920fc8ccde6f8821294b0 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Thu, 1 Oct 2020 10:45:13 +0200 Subject: [PATCH] a2dp: remove redundant functions --- src/classic/a2dp_sink.c | 16 +++++----------- src/classic/a2dp_source.c | 8 ++++---- src/classic/avdtp_util.c | 16 ---------------- src/classic/avdtp_util.h | 2 -- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/classic/a2dp_sink.c b/src/classic/a2dp_sink.c index 6fe0dc2ce..7c5499209 100644 --- a/src/classic/a2dp_sink.c +++ b/src/classic/a2dp_sink.c @@ -225,12 +225,12 @@ static void a2dp_sink_packet_handler_internal(uint8_t packet_type, uint16_t chan // only care for outgoing connections if (!outgoing_active) break; outgoing_active = false; - a2dp_emit_signaling_connection_established(a2dp_sink_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_sink_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED); log_info("A2DP sink signaling connection failed status %d", status); break; } - a2dp_emit_signaling_connection_established(a2dp_sink_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_sink_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED); log_info("A2DP sink signaling connection established avdtp_cid 0x%02x", cid); break; @@ -264,12 +264,12 @@ static void a2dp_sink_packet_handler_internal(uint8_t packet_type, uint16_t chan status = avdtp_subevent_streaming_connection_established_get_status(packet); if (status != ERROR_CODE_SUCCESS){ log_info("A2DP sink streaming connection could not be established, avdtp_cid 0x%02x, status 0x%02x ---", cid, status); - a2dp_emit_streaming_connection_established(a2dp_sink_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_sink_packet_handler_user, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED); break; } log_info("A2DP streaming connection established --- avdtp_cid 0x%02x, local seid %d, remote seid %d", cid, local_seid, remote_seid); - a2dp_emit_streaming_connection_established(a2dp_sink_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_sink_packet_handler_user, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED); break; case AVDTP_SUBEVENT_SIGNALING_ACCEPT: @@ -325,13 +325,7 @@ static void a2dp_sink_packet_handler_internal(uint8_t packet_type, uint16_t chan if (cid != a2dp_sink_cid) break; stream_endpoint_configured = false; - // for outgoing connections, suppress release event and report stream established failed - if (outgoing_active){ - outgoing_active = false; - log_info("A2DP sink outgoing connection failed - disconnect"); - a2dp_emit_signaling_connection_established(a2dp_sink_packet_handler_user, packet, size, ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION); - break; - } + outgoing_active = false; a2dp_replace_subevent_id_and_emit_cmd(a2dp_sink_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_RELEASED); break; diff --git a/src/classic/a2dp_source.c b/src/classic/a2dp_source.c index 7f0c91ed5..cf5bd39bf 100644 --- a/src/classic/a2dp_source.c +++ b/src/classic/a2dp_source.c @@ -294,14 +294,14 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch if (outgoing_active && (a2dp_source_cid == cid)){ log_info("A2DP source signaling connection failed status 0x%02x", status); outgoing_active = false; - a2dp_emit_signaling_connection_established(a2dp_source_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_source_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED); } break; } log_info("A2DP source signaling connection established avdtp_cid 0x%02x", cid); // notify app - a2dp_emit_signaling_connection_established(a2dp_source_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_source_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED); // we already have a valid setup if (stream_endpoint_configured) return; @@ -509,13 +509,13 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch status = avdtp_subevent_streaming_connection_established_get_status(packet); if (status != ERROR_CODE_SUCCESS){ log_info("A2DP source streaming connection could not be established, avdtp_cid 0x%02x, status 0x%02x ---", cid, status); - a2dp_emit_streaming_connection_established(a2dp_source_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_source_packet_handler_user, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED); break; } log_info("A2DP source streaming connection established --- avdtp_cid 0x%02x, local seid 0x%02x, remote seid 0x%02x", cid, local_seid, remote_seid); a2dp_source_state = A2DP_STREAMING_OPENED; - a2dp_emit_streaming_connection_established(a2dp_source_packet_handler_user, packet, size, status); + a2dp_replace_subevent_id_and_emit_cmd(a2dp_source_packet_handler_user, packet, size, A2DP_SUBEVENT_STREAM_ESTABLISHED); break; case AVDTP_SUBEVENT_SIGNALING_ACCEPT: diff --git a/src/classic/avdtp_util.c b/src/classic/avdtp_util.c index 1f3b828ef..41b21c531 100644 --- a/src/classic/avdtp_util.c +++ b/src/classic/avdtp_util.c @@ -1043,22 +1043,6 @@ void a2dp_replace_subevent_id_and_emit_cmd(btstack_packet_handler_t callback, ui (*callback)(HCI_EVENT_PACKET, 0, packet, size); } -void a2dp_emit_streaming_connection_established(btstack_packet_handler_t callback, uint8_t * packet, uint16_t size, uint8_t status){ - btstack_assert(callback != NULL); - packet[0] = HCI_EVENT_A2DP_META; - packet[2] = A2DP_SUBEVENT_STREAM_ESTABLISHED; - packet[12] = status; - (*callback)(HCI_EVENT_PACKET, 0, packet, size); -} - -void a2dp_emit_signaling_connection_established(btstack_packet_handler_t callback, uint8_t * packet, uint16_t size, uint8_t status){ - btstack_assert(callback != NULL); - packet[0] = HCI_EVENT_A2DP_META; - packet[2] = A2DP_SUBEVENT_SIGNALING_CONNECTION_ESTABLISHED; - packet[13] = status; - (*callback)(HCI_EVENT_PACKET, 0, packet, size); -} - void a2dp_emit_stream_event(btstack_packet_handler_t callback, uint16_t cid, uint8_t local_seid, uint8_t subevent_id){ uint8_t event[6]; int pos = 0; diff --git a/src/classic/avdtp_util.h b/src/classic/avdtp_util.h index dc5d3169f..397753198 100644 --- a/src/classic/avdtp_util.h +++ b/src/classic/avdtp_util.h @@ -120,8 +120,6 @@ const char * avdtp_si2str(uint16_t index); void a2dp_replace_subevent_id_and_emit_cmd(btstack_packet_handler_t callback, uint8_t * packet, uint16_t size, uint8_t subevent_id); -void a2dp_emit_streaming_connection_established(btstack_packet_handler_t callback, uint8_t * packet, uint16_t size, uint8_t status); -void a2dp_emit_signaling_connection_established(btstack_packet_handler_t callback, uint8_t * packet, uint16_t size, uint8_t status); void a2dp_emit_stream_event(btstack_packet_handler_t callback, uint16_t cid, uint8_t local_seid, uint8_t subevent_id); #if defined __cplusplus