avdtp: rewriting for handling multiple connections, draft

This commit is contained in:
Milanka Ringwald 2016-11-16 17:17:57 +01:00
parent 0fbdddf369
commit 12e7f38c5b
3 changed files with 48 additions and 1 deletions

View File

@ -515,6 +515,45 @@ void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_st
#endif
// MARK: avdtp_connection_t
#if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS)
#if defined(MAX_NO_AVDTP_CONNECTIONS)
#error "Deprecated MAX_NO_AVDTP_CONNECTIONS defined instead of MAX_NR_AVDTP_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_AVDTP_CONNECTIONS."
#else
#define MAX_NR_AVDTP_CONNECTIONS 0
#endif
#endif
#ifdef MAX_NR_AVDTP_CONNECTIONS
#if MAX_NR_AVDTP_CONNECTIONS > 0
static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS];
static btstack_memory_pool_t avdtp_connection_pool;
avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
return (avdtp_connection_t *) btstack_memory_pool_get(&avdtp_connection_pool);
}
void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection);
}
#else
avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
return NULL;
}
void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
// silence compiler warning about unused parameter in a portable way
(void) avdtp_connection;
};
#endif
#elif defined(HAVE_MALLOC)
avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
return (avdtp_connection_t*) malloc(sizeof(avdtp_connection_t));
}
void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
free(avdtp_connection);
}
#endif
#ifdef ENABLE_BLE
// MARK: gatt_client_t
@ -670,6 +709,9 @@ void btstack_memory_init(void){
#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t));
#endif
#if MAX_NR_AVDTP_CONNECTIONS > 0
btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t));
#endif
#ifdef ENABLE_BLE
#if MAX_NR_GATT_CLIENTS > 0
btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t));

View File

@ -122,6 +122,10 @@ void btstack_memory_service_record_item_free(service_record_item_t *service_re
avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void);
void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint);
// avdtp_connection
avdtp_connection_t * btstack_memory_avdtp_connection_get(void);
void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection);
#ifdef ENABLE_BLE
// gatt_client, whitelist_entry, sm_lookup_entry
gatt_client_t * btstack_memory_gatt_client_get(void);

View File

@ -178,7 +178,8 @@ list_of_structs = [
["bnep_service", "bnep_channel"],
["hfp_connection"],
["service_record_item"],
["avdtp_stream_endpoint"]
["avdtp_stream_endpoint"],
["avdtp_connection"]
]
list_of_le_structs = [["gatt_client", "whitelist_entry", "sm_lookup_entry"]]