From 3338afc0d0984b01a0e6291a0b4c6e3653d7cd4c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 16 Oct 2020 12:25:00 +0200 Subject: [PATCH] avdtp: only use avdtp_get_stream_endpoint_for_seid --- src/classic/avdtp.c | 18 +++++++----------- src/classic/avdtp.h | 1 - src/classic/avdtp_acceptor.c | 4 ++-- src/classic/avdtp_sink.c | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 9bc5a628a..2da2ccd35 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -127,7 +127,7 @@ static avdtp_connection_t * avdtp_get_connection_for_bd_addr(bd_addr_t addr){ } -avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_with_seid(uint16_t seid){ +avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_seid(uint16_t seid){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, avdtp_get_stream_endpoints()); while (btstack_linked_list_iterator_has_next(&it)){ @@ -139,10 +139,6 @@ avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_with_seid(uint16_t seid){ return NULL; } -avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_seid(uint16_t seid){ - return avdtp_get_stream_endpoint_with_seid(seid); -} - avdtp_connection_t * avdtp_get_connection_for_l2cap_signaling_cid(uint16_t l2cap_cid){ btstack_linked_list_iterator_t it; btstack_linked_list_iterator_init(&it, &connections); @@ -827,7 +823,7 @@ void avdtp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet decline_connection = true; } else { // now, we're only dealing with media connections that are created by remote side - we're acceptor here - stream_endpoint = avdtp_get_stream_endpoint_with_seid(connection->acceptor_local_seid); + stream_endpoint = avdtp_get_stream_endpoint_for_seid(connection->acceptor_local_seid); if ((stream_endpoint == NULL) || (stream_endpoint->l2cap_media_cid != 0) ) { decline_connection = true; } @@ -1029,7 +1025,7 @@ uint8_t avdtp_open_stream(uint16_t avdtp_cid, uint8_t local_seid, uint8_t remote return ERROR_CODE_COMMAND_DISALLOWED; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("avdtp_media_connect: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; @@ -1058,7 +1054,7 @@ uint8_t avdtp_start_stream(uint16_t avdtp_cid, uint8_t local_seid){ return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("avdtp_start_stream: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; @@ -1092,7 +1088,7 @@ uint8_t avdtp_stop_stream(uint16_t avdtp_cid, uint8_t local_seid){ return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("avdtp_stop_stream: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; @@ -1121,7 +1117,7 @@ uint8_t avdtp_abort_stream(uint16_t avdtp_cid, uint8_t local_seid){ return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("avdtp_abort_stream: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; @@ -1149,7 +1145,7 @@ uint8_t avdtp_suspend_stream(uint16_t avdtp_cid, uint8_t local_seid){ log_error("avdtp_suspend_stream: no connection for signaling cid 0x%02x found", avdtp_cid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("avdtp_suspend_stream: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; diff --git a/src/classic/avdtp.h b/src/classic/avdtp.h index 82dfbab24..0de275995 100644 --- a/src/classic/avdtp.h +++ b/src/classic/avdtp.h @@ -560,7 +560,6 @@ btstack_linked_list_t * avdtp_get_connections(void); btstack_linked_list_t * avdtp_get_stream_endpoints(void); avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_seid(uint16_t seid); -avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_with_seid(uint16_t seid); btstack_packet_handler_t avdtp_packet_handler_for_stream_endpoint(const avdtp_stream_endpoint_t *stream_endpoint); void avdtp_emit_sink_and_source(uint8_t * packet, uint16_t size); diff --git a/src/classic/avdtp_acceptor.c b/src/classic/avdtp_acceptor.c index a7d5ac630..077d11432 100644 --- a/src/classic/avdtp_acceptor.c +++ b/src/classic/avdtp_acceptor.c @@ -174,7 +174,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t case AVDTP_SI_RECONFIGURE: case AVDTP_SI_DELAYREPORT: connection->acceptor_local_seid = packet[offset++] >> 2; - stream_endpoint = avdtp_get_stream_endpoint_with_seid(connection->acceptor_local_seid); + stream_endpoint = avdtp_get_stream_endpoint_for_seid(connection->acceptor_local_seid); if (!stream_endpoint){ log_info("cmd %d - REJECT", connection->acceptor_signaling_packet.signal_identifier); connection->error_code = BAD_ACP_SEID; @@ -216,7 +216,7 @@ void avdtp_acceptor_stream_config_subsm(avdtp_connection_t *connection, uint8_t } // deal with first susspended seid connection->acceptor_local_seid = connection->suspended_seids[0]; - stream_endpoint = avdtp_get_stream_endpoint_with_seid(connection->acceptor_local_seid); + stream_endpoint = avdtp_get_stream_endpoint_for_seid(connection->acceptor_local_seid); if (!stream_endpoint){ log_info("stream_endpoint not found, BAD_ACP_SEID"); connection->error_code = BAD_ACP_SEID; diff --git a/src/classic/avdtp_sink.c b/src/classic/avdtp_sink.c index 18b0d1123..dbf7d0db5 100644 --- a/src/classic/avdtp_sink.c +++ b/src/classic/avdtp_sink.c @@ -180,7 +180,7 @@ uint8_t avdtp_sink_delay_report(uint16_t avdtp_cid, uint8_t local_seid, uint16_t return ERROR_CODE_COMMAND_DISALLOWED; } - avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_with_seid(local_seid); + avdtp_stream_endpoint_t * stream_endpoint = avdtp_get_stream_endpoint_for_seid(local_seid); if (!stream_endpoint) { log_error("delay_report: no stream_endpoint with seid %d found", local_seid); return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;