avdtp: remove stream endpoint id counter from context

This commit is contained in:
Milanka Ringwald 2020-07-10 16:32:08 +02:00
parent a1fb0563e9
commit 560b3f31ba
4 changed files with 9 additions and 26 deletions

View File

@ -59,9 +59,10 @@ avdtp_context_t * avdtp_sink_context = NULL;
static btstack_packet_handler_t avdtp_source_callback;
static btstack_packet_handler_t avdtp_sink_callback;
// static avdtp_context_t * sdp_query_context = NULL;
static uint16_t sdp_query_context_avdtp_cid = 0;
static uint16_t stream_endpoints_id_counter = 0;
static btstack_linked_list_t connections;
static uint16_t initiator_transaction_id_counter = 0;
@ -221,28 +222,13 @@ static uint16_t avdtp_get_next_cid(void){
return avdtp_cid_counter;
}
static avdtp_stream_endpoint_t * avdtp_get_stream_endpoint_for_id(avdtp_context_t * context, uint16_t stream_endpoint_id) {
btstack_linked_item_t *it;
for (it = (btstack_linked_item_t *) context->stream_endpoints; it ; it = it->next){
avdtp_stream_endpoint_t * stream_endpoint = ((avdtp_stream_endpoint_t *) it);
if (stream_endpoint->sep.seid == stream_endpoint_id) {
return stream_endpoint;
};
static uint16_t avdtp_get_next_local_seid(void){
if (stream_endpoints_id_counter == 0xffff) {
stream_endpoints_id_counter = 1;
} else {
stream_endpoints_id_counter++;
}
return NULL;
}
static uint16_t avdtp_get_next_local_seid(avdtp_context_t * context){
uint16_t stream_endpoint_id = context->stream_endpoints_id_counter;
do {
if (stream_endpoint_id == 0xffff) {
stream_endpoint_id = 1;
} else {
stream_endpoint_id++;
}
} while (avdtp_get_stream_endpoint_for_id(context, stream_endpoint_id) != NULL) ;
return stream_endpoint_id;
return stream_endpoints_id_counter;
}
static uint8_t avdtp_start_sdp_query(btstack_packet_handler_t packet_handler, avdtp_connection_t * connection) {
@ -439,7 +425,7 @@ avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type
log_error("Not enough memory to create stream endpoint");
return NULL;
}
stream_endpoint->sep.seid = avdtp_get_next_local_seid(context);
stream_endpoint->sep.seid = avdtp_get_next_local_seid();
stream_endpoint->sep.media_type = media_type;
stream_endpoint->sep.type = sep_type;
btstack_linked_list_add(&context->stream_endpoints, (btstack_linked_item_t *) stream_endpoint);

View File

@ -547,7 +547,6 @@ typedef struct {
typedef struct {
btstack_linked_list_t stream_endpoints;
uint16_t stream_endpoints_id_counter;
btstack_packet_handler_t avdtp_callback;
btstack_packet_handler_t a2dp_callback;

View File

@ -105,7 +105,6 @@ void avdtp_sink_init(avdtp_context_t * avdtp_context){
avdtp_sink_context = avdtp_context;
avdtp_sink_context->stream_endpoints = NULL;
avdtp_sink_context->stream_endpoints_id_counter = 0;
l2cap_register_service(&avdtp_packet_handler, BLUETOOTH_PSM_AVDTP, 0xffff, gap_get_security_level());
}

View File

@ -162,7 +162,6 @@ void avdtp_source_init(avdtp_context_t * avdtp_context){
avdtp_source_context = avdtp_context;
avdtp_source_context->stream_endpoints = NULL;
avdtp_source_context->stream_endpoints_id_counter = 0;
l2cap_register_service(&avdtp_packet_handler, BLUETOOTH_PSM_AVDTP, 0xffff, gap_get_security_level());
}