From 49523328ea980515c572b335567d93a8041edcfd Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 19 Aug 2020 14:06:25 +0200 Subject: [PATCH] avdtp_source: remove send_stream_established_for_outgoing_connection --- src/classic/a2dp_source.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/classic/a2dp_source.c b/src/classic/a2dp_source.c index 8be096ab0..0b5917cd1 100644 --- a/src/classic/a2dp_source.c +++ b/src/classic/a2dp_source.c @@ -59,7 +59,6 @@ static const char * default_a2dp_source_service_provider_name = "BTstack A2DP So static btstack_timer_source_t a2dp_source_set_config_timer; -static bool send_stream_established_for_outgoing_connection = false; static bool discover_seps_in_process = false; static bool stream_endpoint_configured = false; @@ -251,21 +250,20 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch status = avdtp_subevent_signaling_connection_established_get_status(packet); if (status != ERROR_CODE_SUCCESS){ - connection->a2dp_source_state = A2DP_IDLE; - - // only care for outgoing connections - if (!send_stream_established_for_outgoing_connection) break; - send_stream_established_for_outgoing_connection = false; - log_info("A2DP source singnaling connection failed status %d", status); - a2dp_emit_signaling_connection_established(a2dp_source_packet_handler_user, packet, size, status); + // notify about connection error only if we're initator + if (connection->a2dp_source_state == A2DP_W4_CONNECTED){ + connection->a2dp_source_state = A2DP_IDLE; + log_info("A2DP source signaling connection failed status %d", status); + a2dp_emit_signaling_connection_established(a2dp_source_packet_handler_user, packet, size, status); + } break; } - log_info("A2DP source singnaling connection established avdtp_cid 0x%02x", cid); + log_info("A2DP source signaling connection established avdtp_cid 0x%02x", cid); if (discover_seps_in_process){ connection->a2dp_source_discover_seps = true; break; - } + } a2dp_start_discovering_seps(connection); // notify app @@ -429,8 +427,6 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch btstack_assert(connection != NULL); btstack_assert(connection->a2dp_source_state == A2DP_W4_OPEN_STREAM_WITH_SEID); - // about to notify client - send_stream_established_for_outgoing_connection = false; remote_seid = avdtp_subevent_streaming_connection_established_get_remote_seid(packet); local_seid = avdtp_subevent_streaming_connection_established_get_local_seid(packet); @@ -545,21 +541,11 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch connection = avdtp_get_connection_for_avdtp_cid(cid); btstack_assert(connection != NULL); -#if 0 - // TODO: where does this need to go? - if (send_stream_established_for_outgoing_connection){ - send_stream_established_for_outgoing_connection = false; - log_info("A2DP source outgoing connnection failed - disconnect"); - a2dp_emit_signaling_connection_established(a2dp_source_packet_handler_user, packet, size, ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION); - break; - } -#endif if (connection->a2dp_source_state == A2DP_CONFIGURED){ stream_endpoint_configured = false; connection->a2dp_source_state = A2DP_IDLE; a2dp_replace_subevent_id_and_emit_cmd(a2dp_source_packet_handler_user, packet, size, A2DP_SUBEVENT_SIGNALING_CONNECTION_RELEASED); } - break; default: @@ -607,7 +593,6 @@ uint8_t a2dp_source_establish_stream(bd_addr_t remote_addr, uint8_t loc_seid, ui avdtp_connection_t * connection = avdtp_get_connection_for_avdtp_cid(*avdtp_cid); btstack_assert(connection != NULL); - send_stream_established_for_outgoing_connection = true; connection->a2dp_source_state = A2DP_W4_CONNECTED; return ERROR_CODE_SUCCESS; }