From 1114e1584c69892f7e89f0cb5f5ea3ae6661dc71 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 14 Jul 2021 12:00:22 +0200 Subject: [PATCH] avdtp: mark stream endpoint as used on send/receive of set config command --- src/classic/a2dp_source.c | 1 - src/classic/avdtp_acceptor.c | 10 ++++++++++ src/classic/avdtp_initiator.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/classic/a2dp_source.c b/src/classic/a2dp_source.c index 74370819f..e8718883e 100644 --- a/src/classic/a2dp_source.c +++ b/src/classic/a2dp_source.c @@ -422,7 +422,6 @@ static void a2dp_source_packet_handler_internal(uint8_t packet_type, uint16_t ch configuration.min_bitpool_value = avdtp_choose_sbc_min_bitpool_value(stream_endpoint, avdtp_subevent_signaling_media_codec_sbc_capability_get_min_bitpool_value(packet)); // and pre-select this endpoint - stream_endpoint->sep.in_use = 1; local_seid = avdtp_stream_endpoint_seid(stream_endpoint); remote_seid = avdtp_subevent_signaling_media_codec_sbc_capability_get_remote_seid(packet); a2dp_source_set_config_sbc(cid, local_seid, remote_seid, &configuration); diff --git a/src/classic/avdtp_acceptor.c b/src/classic/avdtp_acceptor.c index 23823ecca..770782569 100644 --- a/src/classic/avdtp_acceptor.c +++ b/src/classic/avdtp_acceptor.c @@ -101,6 +101,13 @@ avdtp_acceptor_handle_configuration_command(avdtp_connection_t *connection, int sep.configured_service_categories = avdtp_unpack_service_capabilities(connection, connection->acceptor_signaling_packet.signal_identifier, &sep.configuration, connection->acceptor_signaling_packet.command+offset, packet_size-offset); sep.in_use = 1; + // test if sep already in use + if (stream_endpoint->sep.in_use != 0){ + log_info("stream endpoint already in use"); + connection->error_code = AVDTP_ERROR_CODE_SEP_IN_USE; + connection->reject_service_category = 0; + } + // let application validate media configuration as well if (connection->error_code == 0){ if ((sep.configured_service_categories & (1 << AVDTP_MEDIA_CODEC)) != 0){ @@ -150,6 +157,9 @@ avdtp_acceptor_handle_configuration_command(avdtp_connection_t *connection, int stream_endpoint->remote_sep = sep; log_info("add remote seid %d", stream_endpoint->remote_sep.seid); } + + // mark as in_use + stream_endpoint->sep.in_use = 1; // if media codec configuration set, copy configuration and emit event if ((sep.configured_service_categories & (1 << AVDTP_MEDIA_CODEC)) != 0){ diff --git a/src/classic/avdtp_initiator.c b/src/classic/avdtp_initiator.c index fd2276878..d8c4ee6ba 100644 --- a/src/classic/avdtp_initiator.c +++ b/src/classic/avdtp_initiator.c @@ -171,6 +171,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t *connection, uint8_t sep.in_use = 1; stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CONFIGURED; + stream_endpoint->sep.in_use = 1; stream_endpoint->remote_sep = sep; stream_endpoint->connection = connection; connection->configuration_state = AVDTP_CONFIGURATION_STATE_LOCAL_CONFIGURED;