Add TMAP & GMAP information services
Subsystems (2)
v2 cover Add TMAP & GMAP information services
Add support for TMAP and GMAP services. They contain only device audio capability bitmasks.
v2:
- Rework the service wait to be general mechanism that also determines the service autoconnect order.
This is now slightly more involved, but this sort of "soft" ordering dependency must know which services the autoconnect mechanism is going to start.
Sorting autoconnect services is one of the ways to do it, probably makes sense also otherwise, and we could insert service conflict handling at the same place.
- Make org.bluez.MediaEndpoint::SupportedFeatures per-uuid dict
---
Expose the values from remote devices inorg.bluez.MediaEndpoint->SupportedFeatures
This maybe could also be org.bluez.Device->SupportedFeatures instead, but MediaEndpoint looks OK too.
Sound server can use theses to determine which mandatory capabilities devices have.
TODO (maybe later): add way to configure advertised local service values, e.g. via config file.
Pauli Virtanen (9):
shared/gmap: add GMAP Service
test-gmap: add test for GMAP Service
gmap: Add GMAP profile
doc: org.bluez.MediaEndpoint: add SupportedFeatures
bap: add SupportedFeatures for MediaEndpoints
profile: add after_uuids for ordering profile startup
device: use after_uuids in service autoconnect and sort also GATT
service: add btd_profile::ready callback when after_uuids ready
bap: have unicast client wait for VCS & TMAS & GMAP
.gitignore | 1 + Makefile.am | 7 + Makefile.plugins | 5 + configure.ac | 7 + doc/org.bluez.MediaEndpoint.rst | 108 +++++++ lib/bluetooth/uuid.h | 8 + profiles/audio/bap.c | 163 ++++++++++- profiles/audio/gmap.c | 200 +++++++++++++ src/device.c | 74 ++++- src/profile.c | 89 ++++++ src/profile.h | 16 ++ src/service.c | 100 +++++++ src/shared/gmap.c | 401 ++++++++++++++++++++++++++ src/shared/gmap.h | 70 +++++ unit/test-gmap.c | 496 ++++++++++++++++++++++++++++++++ 15 files changed, 1730 insertions(+), 15 deletions(-) create mode 100644 profiles/audio/gmap.c create mode 100644 src/shared/gmap.c create mode 100644 src/shared/gmap.h create mode 100644 unit/test-gmap.c
Signature · 1 line
2.51.1
PATCH v2 1/9 shared/gmap: add GMAP Service
GMAP Service is just a simple service with bitmasks.
The values can be used to figure out which GMAP roles and features the remote device claims it supports (matters for available mandatory features). Also can advertise the same for remote clients.
---
Notes:
v2:
- remove one unnecessary #include
Makefile.am | 1 + lib/bluetooth/uuid.h | 8 + src/shared/gmap.c | 401 +++++++++++++++++++++++++++++++++++++++++++ src/shared/gmap.h | 70 ++++++++ 4 files changed, 480 insertions(+) create mode 100644 src/shared/gmap.c create mode 100644 src/shared/gmap.h
Makefile.am +1 -0
@@ -243,6 +243,7 @@ shared_sources = src/shared/io.h src/shared/timeout.h \ src/shared/bass.h src/shared/bass.c \ src/shared/ccp.h src/shared/ccp.c \ src/shared/tmap.c src/shared/tmap.h \ + src/shared/gmap.c src/shared/gmap.h \ src/shared/lc3.h src/shared/tty.h \ src/shared/bap-defs.h \ src/shared/asha.h src/shared/asha.c \
lib/bluetooth/uuid.h +8 -0
@@ -216,6 +216,14 @@ extern "C" {#define TMAS_UUID 0x1855#define TMAP_ROLE_CHRC_UUID 0x2b51 +/* Gaming Audio Service */ +#define GMAS_UUID 0x1858 +#define GMAP_ROLE_CHRC_UUID 0x2c00 +#define GMAP_UGG_CHRC_UUID 0x2c01 +#define GMAP_UGT_CHRC_UUID 0x2c02 +#define GMAP_BGS_CHRC_UUID 0x2c03 +#define GMAP_BGR_CHRC_UUID 0x2c04 +/* Coordinated Set Identification Profile(CSIP) */ #define CSIS_UUID 0x1846#define CS_SIRK 0x2B84
src/shared/gmap.c new file +401 -0
401 lines not on this page · raw message
src/shared/gmap.h new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.51.1
PATCH v2 2/9 test-gmap: add test for GMAP Service
In reply to Pauli VirtanenAdd tests on GMAP service for reading the attributes.
---
Notes:
v2:
- no change
.gitignore | 1 + Makefile.am | 6 + unit/test-gmap.c | 496 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 503 insertions(+) create mode 100644 unit/test-gmap.c
.gitignore +1 -0
@@ -119,6 +119,7 @@ unit/test-bap unit/test-bass unit/test-battery unit/test-tmap +unit/test-gmap tools/mgmt-tester tools/smp-tester tools/gap-tester
Makefile.am +6 -0
@@ -709,6 +709,12 @@ unit_test_tmap_SOURCES = unit/test-tmap.c $(btio_sources) unit_test_tmap_LDADD = src/libshared-glib.la \ lib/libbluetooth-internal.la $(GLIB_LIBS) +unit_tests += unit/test-gmap + +unit_test_gmap_SOURCES = unit/test-gmap.c $(btio_sources) +unit_test_gmap_LDADD = src/libshared-glib.la \ + lib/libbluetooth-internal.la $(GLIB_LIBS) + unit_tests += unit/test-battery unit_test_battery_SOURCES = unit/test-battery.c
unit/test-gmap.c new file +496 -0
496 lines not on this page · raw message
Signature · 1 line
2.51.1
PATCH v2 3/9 gmap: Add GMAP profile
In reply to Pauli VirtanenRead GMAP properties from remote devices and enable advertising the values for local services.
---
Notes:
v2:
- remove one unnecessary #include
Makefile.plugins | 5 ++ configure.ac | 7 ++ profiles/audio/gmap.c | 200 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 profiles/audio/gmap.c
Makefile.plugins +5 -0
@@ -151,6 +151,11 @@ builtin_modules += tmap builtin_sources += profiles/audio/tmap.c endif +if GMAP +builtin_modules += gmap +builtin_sources += profiles/audio/gmap.c +endif + if ASHA builtin_modules += asha builtin_sources += profiles/audio/asha.h profiles/audio/asha.c
configure.ac +7 -0
@@ -234,6 +234,13 @@ if test "${enable_tmap}" != "no"; then AC_DEFINE(HAVE_TMAP, 1, [Define to 1 if you have TMAP support.]) fi +AC_ARG_ENABLE(gmap, AS_HELP_STRING([--disable-gmap], + [disable GMAP profile]), [enable_gmap=${enableval}]) +AM_CONDITIONAL(GMAP, test "${enable_gmap}" != "no") +if test "${enable_gmap}" != "no"; then + AC_DEFINE(HAVE_GMAP, 1, [Define to 1 if you have GMAP support.]) +fi + AC_ARG_ENABLE(asha, AS_HELP_STRING([--disable-asha], [disable ASHA support]), [enable_asha=${enableval}]) AM_CONDITIONAL(ASHA, test "${enable_asha}" != "no")
profiles/audio/gmap.c new file +200 -0
200 lines not on this page · raw message
Signature · 1 line
2.51.1
PATCH v2 4/9 doc: org.bluez.MediaEndpoint: add SupportedFeatures
In reply to Pauli VirtanenAdd SupportedFeatures field for indicating TMAP & GMAP roles and features.
---
Notes:
v2:
- make it a dict of uuid -> features
doc/org.bluez.MediaEndpoint.rst | 108 ++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+)
doc/org.bluez.MediaEndpoint.rst +108 -0
@@ -299,3 +299,111 @@ Indicates QoS capabilities. :uint32 PreferredMaximumDelay: Indicates endpoint preferred maximum presentation delay. + +dict SupportedFeatures [readonly, ISO only, experimental] +````````````````````````````````````````````````````````` + +Dictionary representing supported features for different +services. Keys are service UUIDs, values arrays of strings. + +Services: + +:array{string} 00001855-0000-1000-8000-00805f9b34fb: + + TMAP Features. Possible items: + + :"cg": + + Call Gateway + + :"ct": + + Call Terminal + + :"ums": + + Unicast Media Sender + + :"umr": + + Unicast Media Receiver + + :"bms": + + Broadcast Media Sender + + :"bmr": + + Broadcast Media Receiver + +:array{string} 00001858-0000-1000-8000-00805f9b34fb: + + GMAP Features. Possible items: + + :"ugg": + + Unicast Game Gateway + + :"ugt": + + Unicast Game Terminal + + :"bgs": + + Broadcast Game Sender + + :"bgr": + + Broadcast Game Receiver + + :"ugg-multiplex": + + UGG Multiplex feature support + + :"ugg-96kbps-source": + + UGG 96 kbps Source feature support + + :"ugg-multisink": + + UGG Multisink feature support + + :"ugt-source": + + UGT Source feature support + + :"ugt-80kbps-source": + + UGT 80 kbps Source feature support + + :"ugt-sink": + + UGT Sink feature support + + :"ugt-64kbps-sink": + + UGT 64 kbps Sink feature support + + :"ugt-multiplex": + + UGT Multiplex feature support + + :"ugt-multisink": + + UGT Multisink feature support + + :"ugt-multisource": + + UGT Multisource feature support + + :"bgs-96kbps": + + BGS 96 kbps feature support + + :"bgr-multisink": + + BGR Multisink feature support + + :"bgr-multiplex": + + BGR Multiplex feature support
Signature · 1 line
2.51.1
PATCH v2 5/9 bap: add SupportedFeatures for MediaEndpoints
In reply to Pauli VirtanenIndicate TMAP & GMAP capabilities in SupportedFeatures.
---
Notes:
v2:
- make it a dict uuid -> features
profiles/audio/bap.c | 122 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+)
profiles/audio/bap.c +122 -0
@@ -46,6 +46,8 @@#include "src/shared/gatt-client.h" #include "src/shared/gatt-server.h" #include "src/shared/bap.h" +#include "src/shared/tmap.h" +#include "src/shared/gmap.h" #include "btio/btio.h" #include "src/plugin.h"
@@ -65,6 +67,10 @@#define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"#define MEDIA_INTERFACE "org.bluez.Media1" +#define VCS_UUID_STR "00001844-0000-1000-8000-00805f9b34fb" +#define TMAS_UUID_STR "00001855-0000-1000-8000-00805f9b34fb" +#define GMAS_UUID_STR "00001858-0000-1000-8000-00805f9b34fb" +struct bap_setup ; typedef void (*bap_setup_ready_func_t)(struct bap_setup *setup, int code,
@@ -438,6 +444,120 @@ static gboolean get_qos(const GDBusPropertyTable *property,return TRUE; } +static bool probe_tmap_role (struct bap_ep *ep,uint32_t data) +{ +struct gatt_db *db =bt_bap_get_db (ep->data->bap, true); + +return bt_tmap_get_role (bt_tmap_find (db)) & data; +} + +static bool probe_gmap_role (struct bap_ep *ep,uint32_t data) +{ +struct gatt_db *db =bt_bap_get_db (ep->data->bap, true); + +return bt_gmap_get_role (bt_gmap_find (db)) & data; +} + +static bool probe_gmap_feature (struct bap_ep *ep,uint32_t data) +{ +struct gatt_db *db =bt_bap_get_db (ep->data->bap, true); + +return bt_gmap_get_features (bt_gmap_find (db)) & data; +} + +struct feature { +const char *name; +bool (*probe)(struct bap_ep *ep,uint32_t data); +uint32_t data; +}; + +static const struct feature tmap_features[] = { + {"cg" , probe_tmap_role,BT_TMAP_ROLE_CG }, + {"ct" , probe_tmap_role,BT_TMAP_ROLE_CT }, + {"ums" , probe_tmap_role,BT_TMAP_ROLE_UMS }, + {"umr" , probe_tmap_role,BT_TMAP_ROLE_UMR }, + {"bms" , probe_tmap_role,BT_TMAP_ROLE_BMS }, + {"bmr" , probe_tmap_role,BT_TMAP_ROLE_BMR }, +}; + +static const struct feature gmap_features[] = { + {"ugg" , probe_gmap_role,BT_GMAP_ROLE_UGG }, + {"ugt" , probe_gmap_role,BT_GMAP_ROLE_UGT }, + {"bgs" , probe_gmap_role,BT_GMAP_ROLE_BGS }, + {"bgr" , probe_gmap_role,BT_GMAP_ROLE_BGR }, + {"ugg-multiplex" , probe_gmap_feature,BT_GMAP_UGG_MULTIPLEX }, + {"ugg-96kbps-source" , probe_gmap_feature,BT_GMAP_UGG_96KBPS }, + {"ugg-multisink" , probe_gmap_feature,BT_GMAP_UGG_MULTISINK }, + {"ugt-source" , probe_gmap_feature,BT_GMAP_UGT_SOURCE }, + {"ugt-80kbps-source" , probe_gmap_feature, +BT_GMAP_UGT_80KBPS_SOURCE }, + {"ugt-sink" , probe_gmap_feature,BT_GMAP_UGT_SINK }, + {"ugt-64kbps-sink" , probe_gmap_feature,BT_GMAP_UGT_64KBPS_SINK }, + {"ugt-multiplex" , probe_gmap_feature,BT_GMAP_UGT_MULTIPLEX }, + {"ugt-multisink" , probe_gmap_feature,BT_GMAP_UGT_MULTISINK }, + {"ugt-multisource" , probe_gmap_feature,BT_GMAP_UGT_MULTISOURCE }, + {"bgs-96kbps" , probe_gmap_feature,BT_GMAP_BGS_96KBPS }, + {"bgr-multisink" , probe_gmap_feature,BT_GMAP_BGR_MULTISINK }, + {"bgr-multiplex" , probe_gmap_feature,BT_GMAP_BGR_MULTIPLEX }, +}; + +static const struct { +const char *uuid; +const struct feature *items; +size_t count; +} features[] = { + {TMAS_UUID_STR , tmap_features,ARRAY_SIZE (tmap_features) }, + {GMAS_UUID_STR , gmap_features,ARRAY_SIZE (gmap_features) }, +}; + +static gboolean supported_features (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *data) +{ +struct bap_ep *ep = data; +DBusMessageIter dict, entry, variant, list; +size_t i, j; + +dbus_message_iter_open_container (iter,DBUS_TYPE_ARRAY ,"{sv}" , &dict); + +for (i =0 ; i <ARRAY_SIZE (features); ++i) { +for (j =0 ; j < features[i].count; ++j) { +const struct feature *feature = &features[i].items[j]; + +if (feature->probe (ep, feature->data)) +break ; + } +if (j == features[i].count) +continue ; + +dbus_message_iter_open_container (&dict,DBUS_TYPE_DICT_ENTRY , +NULL , &entry); +dbus_message_iter_append_basic (&entry,DBUS_TYPE_STRING , + &features[i].uuid); +dbus_message_iter_open_container (&entry,DBUS_TYPE_VARIANT , +"as" , &variant); +dbus_message_iter_open_container (&variant,DBUS_TYPE_ARRAY , +"s" , &list); + +for (j =0 ; j < features[i].count; ++j) { +const struct feature *feature = &features[i].items[j]; + +if (!feature->probe (ep, feature->data)) +continue ; + +dbus_message_iter_append_basic (&list,DBUS_TYPE_STRING , + &feature->name); + } + +dbus_message_iter_close_container (&variant, &list); +dbus_message_iter_close_container (&entry, &variant); +dbus_message_iter_close_container (&dict, &entry); + } + +dbus_message_iter_close_container (iter, &dict); + +return TRUE; +} +static const GDBusPropertyTable ep_properties[] = { {"UUID" ,"s" , get_uuid,NULL ,NULL ,G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
@@ -457,6 +577,8 @@ static const GDBusPropertyTable ep_properties[] = { G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, {"QoS" ,"a{sv}" , get_qos,NULL , qos_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, + { "SupportedFeatures", "a{sv}", supported_features, NULL, NULL, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, { } };
Signature · 1 line
2.51.1
PATCH v2 6/9 profile: add after_uuids for ordering profile startup
In reply to Pauli VirtanenAdd btd_profile::after_uuids to specify the profile connect/accept order for autoconnect. This is a "soft" dependency so it doesn't fail if the other services fail to start nor try to start them if they otherwise wouldn't.
Add btd_profile_sort_list() for sorting a list according to profile ordering, taking account priority and after_uuids.
Add btd_profile_find_remote_uuid() lookup utility, needed when using btd_profile_sort_list() with uuid lists.
---
Notes:
v2:
- new commit
src/profile.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/profile.h | 13 ++++++++ 2 files changed, 102 insertions(+)
src/profile.c +89 -0
@@ -773,6 +773,30 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)return NULL ; } +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid) +{ +GSList *l, *next; + +for (l = profiles; l !=NULL ; l = next) { +struct btd_profile *p = l->data; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +for (l = ext_profiles; l !=NULL ; l = next) { +struct ext_profile *ext = l->data; +struct btd_profile *p = &ext->p; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +return NULL ; +} +int btd_profile_register (struct btd_profile *profile) { if (profile->experimental && !(g_dbus_get_flags() &
@@ -2650,3 +2674,68 @@ void btd_profile_cleanup(void)g_dbus_unregister_interface (btd_get_dbus_connection (),"/org/bluez" ,"org.bluez.ProfileManager1" ); } + +/* Stable sort of a list according to profile priority & after_uuids */ +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data) +{ +GSList *result =NULL ; +GSList *remain = list; +GHashTable *uuids; +GSList *entry; +const struct btd_profile *p; + + uuids =g_hash_table_new_full (g_str_hash, g_str_equal, g_free,NULL ); + +/* Unsatisfied remote uuids */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_add (uuids,g_strdup (p->remote_uuid)); + } + +/* Sort */ +while (remain) { +GSList *first_entry = remain; +int max_priority =INT_MIN ; + +/* Find max priority */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->priority > max_priority) { + first_entry = entry; + max_priority = p->priority; + } + } + +/* Find max priority entry with no unsatisfied dependencies */ +for (entry = remain; entry; entry =g_slist_next (entry)) { +const char **uuid; + + p =get (entry->data, user_data); +if (p->priority < max_priority) +continue ; + +for (uuid = p->after_uuids; uuid && *uuid; uuid++) +if (g_hash_table_contains (uuids, *uuid)) +break ; +if (!(uuid && *uuid)) +break ; + } + +/* If cyclic dependencies: break preserving priority & order */ +if (!entry) + entry = first_entry; + + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_remove (uuids, p->remote_uuid); + + remain =g_slist_remove_link (remain, entry); + result =g_slist_concat (result, entry); + } + +g_hash_table_destroy (uuids); + +return result; +}
src/profile.h +13 -0
@@ -38,6 +38,12 @@ struct btd_profile {*/ bool testing; +/* Indicates the profile should be ordered after profiles providing +* these remote uuids when connecting. A NULL-terminated array of +* strings. +*/ +const char **after_uuids; +int (*device_probe) (struct btd_service *service);void (*device_remove) (struct btd_service *service);
@@ -76,3 +82,10 @@ bool btd_profile_remove_custom_prop(const char *uuid, const char *name);void btd_profile_init (void );void btd_profile_cleanup (void ); + +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid); + +typedef const struct btd_profile *(*btd_profile_list_get )(void *item, +void *user_data); +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data);
Signature · 1 line
2.51.1
PATCH v2 7/9 device: use after_uuids in service autoconnect and sort also GATT
In reply to Pauli VirtanenUse btd_profile_sort_list() for selecting the order in which services are connected: first by priority, then by after_uuids.
Probe and accept also GATT services in profile order. Previously this was done in the order they were in GATT db.
---
Notes:
v2:
- new commit
src/device.c | 74 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 12 deletions(-)
src/device.c +62 -12
@@ -2523,14 +2523,6 @@ static struct btd_service *find_connectable_service(struct btd_device *dev,return NULL ; } -static int service_prio_cmp (gconstpointer a,gconstpointer b) -{ -struct btd_profile *p1 =btd_service_get_profile (a); -struct btd_profile *p2 =btd_service_get_profile (b); - -return p2->priority - p1->priority; -} -bool btd_device_all_services_allowed (struct btd_device *dev) {GSList *l;
@@ -2581,6 +2573,12 @@ void btd_device_update_allowed_services(struct btd_device *dev) } } +static const struct btd_profile *get_service_profile (void *data, +void *user_data) +{ +return btd_service_get_profile (data); +} +static GSList *create_pending_list (struct btd_device *dev,const char *uuid) {struct btd_service *service;
@@ -2619,10 +2617,13 @@ static GSList *create_pending_list(struct btd_device *dev, const char *uuid) BTD_SERVICE_STATE_DISCONNECTED)continue ; - dev->pending =g_slist_insert_sorted (dev->pending, service, - service_prio_cmp); + dev->pending =g_slist_append (dev->pending, service); } +/* Connect in priority order */ + dev->pending =btd_profile_sort_list (dev->pending, get_service_profile, +NULL ); +return dev->pending; }
@@ -4630,9 +4631,42 @@ done:service_accept (service,btd_device_is_initiator (device)); } + +static const struct btd_profile *get_gatt_profile (void *data,void *user_data) +{ +struct gatt_db_attribute *attr = data; +struct btd_profile *profile; +bt_uuid_t uuid; +struct btd_profile *dummy_profile = user_data; +char *uuid_str = (char *)dummy_profile->remote_uuid; + +gatt_db_attribute_get_service_uuid (attr, &uuid); +bt_uuid_to_string (&uuid, uuid_str,MAX_LEN_UUID_STR ); + + profile =btd_profile_find_remote_uuid (uuid_str); +if (!profile) + profile = dummy_profile; + +return profile; +} + +static void get_gatt_attrs (struct gatt_db_attribute *attr, +void *user_data) +{ +GSList **list = user_data; + + *list =g_slist_append (*list, attr); +} +static void device_add_gatt_services (struct btd_device *device) {char addr[18 ]; +GSList *attrs =NULL ; +GSList *entry; +char uuid_str[MAX_LEN_UUID_STR ]; +struct btd_profile dummy_profile = { + .remote_uuid = uuid_str, + };ba2str (&device->bdaddr, addr);
@@ -4641,18 +4675,34 @@ static void device_add_gatt_services(struct btd_device *device)return ; } -gatt_db_foreach_service (device->db,NULL , add_gatt_service, device); +/* Probe and accept in profile priority order */ +gatt_db_foreach_service (device->db,NULL , get_gatt_attrs, &attrs); + + attrs =btd_profile_sort_list (attrs, get_gatt_profile, + &dummy_profile); + +for (entry = attrs; entry; entry =g_slist_next (entry)) +add_gatt_service (entry->data, device); + +g_slist_free (attrs); }static void device_accept_gatt_profiles (struct btd_device *device) {GSList *l;bool initiator =btd_device_is_initiator (device); +GSList *services;DBG ("initiator %s" , initiator ?"true" :"false" ); -for (l = device->services; l !=NULL ; l =g_slist_next (l)) +/* Accept in profile priority order */ + services =g_slist_copy (device->services); + services =btd_profile_sort_list (services, get_service_profile,NULL ); + +for (l = services; l !=NULL ; l =g_slist_next (l))service_accept (l->data, initiator); + +g_slist_free (services); } static void device_remove_gatt_service(struct btd_device *device,
Signature · 1 line
2.51.1
PATCH v2 8/9 service: add btd_profile::ready callback when after_uuids ready
In reply to Pauli VirtanenAdd btd_profile::ready that is called when after_uuids dependencies have finished connecting.
---
Notes:
v2:
- new commit
src/profile.h | 3 ++ src/service.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
src/profile.h +3 -0
@@ -52,6 +52,9 @@ struct btd_profile {int (*accept) (struct btd_service *service); +/* Emitted when services in after_uuids are no longer connecting */ +void (*ready)(struct btd_service *service); +int (*adapter_probe) (struct btd_profile *p,struct btd_adapter *adapter); void (*adapter_remove) (struct btd_profile *p,
src/service.c +100 -0
154 lines not on this page · raw message
Signature · 1 line
2.51.1
PATCH v2 9/9 bap: have unicast client wait for VCS & TMAS & GMAP
In reply to Pauli VirtanenHave unicast client to wait for VCS, TMAS, and GMAP before creating endpoints and transports, so that their information is available at that point.
---
Notes:
v2:
- use the generic mechanism to do this
profiles/audio/bap.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
profiles/audio/bap.c +38 -3
@@ -145,6 +145,8 @@ struct bap_data {GIOChannel *listen_io;unsigned int io_id;unsigned int cig_update_id; +bool services_ready; +bool bap_ready; };static struct queue *sessions;
@@ -2137,10 +2139,10 @@ static bool pac_found_bcast(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac,return true; } -static void bap_ready (struct bt_bap *bap,void *user_data) +static void bap_ucast_start (struct bap_data *data) { -struct btd_service *service = user_data; -struct bap_data *data =btd_service_get_user_data (service); +struct btd_service *service = data->service; +struct bt_bap *bap = data->bap;DBG ("bap %p" , bap);
@@ -3723,6 +3725,29 @@ static void pa_and_big_sync(struct bap_setup *setup) } } +static void bap_ready (struct bt_bap *bap,void *user_data) +{ +struct btd_service *service = user_data; +struct bap_data *data =btd_service_get_user_data (service); + +DBG ("bap %p" , bap); + + data->bap_ready = true; +if (data->services_ready) +bap_ucast_start (data); +} + +static void bap_services_ready (struct btd_service *service) +{ +struct bap_data *data =btd_service_get_user_data (service); + +DBG ("%p" , data); + + data->services_ready = true; +if (data->bap_ready) +bap_ucast_start (data); +} +static int bap_bcast_probe (struct btd_service *service) {struct btd_device *device =btd_service_get_device (service);
@@ -3877,6 +3902,9 @@ static int bap_accept(struct btd_service *service)return -EINVAL ; } + data->bap_ready = false; + data->services_ready = false; +if (!bt_bap_attach (data->bap, client)) {error ("BAP unable to attach" );return -EINVAL ;
@@ -3996,10 +4024,17 @@ static struct btd_profile bap_profile = { .device_remove = bap_remove, .accept = bap_accept, .disconnect = bap_disconnect, + .ready = bap_services_ready, .adapter_probe = bap_adapter_probe, .adapter_remove = bap_adapter_remove, .auto_connect = true, .experimental = true, + .after_uuids = (const char *[]) { +VCS_UUID_STR , +TMAS_UUID_STR , +GMAS_UUID_STR , +NULL + }, };static struct btd_profile bap_bcast_profile = {
Signature · 1 line
2.51.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1028785
---Test result---
Test Summary:
CheckPatch PENDING 0.33 seconds GitLint PENDING 0.30 seconds BuildEll PASS 20.19 seconds BluezMake PASS 637.42 seconds MakeCheck PASS 21.70 seconds MakeDistcheck PASS 239.12 seconds CheckValgrind PASS 297.87 seconds CheckSmatch PASS 344.65 seconds bluezmakeextell PASS 180.66 seconds IncrementalBuild PENDING 0.25 seconds ScanBuild PASS 976.58 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Pauli,
Quoted 18 lines · Pauli Virtanen
Add support for TMAP and GMAP services. They contain only device audio capability bitmasks.
v2:
- Rework the service wait to be general mechanism that also determines the service autoconnect order.This is now slightly more involved, but this sort of "soft" ordering dependency must know which services the autoconnect mechanism is going to start.
Sorting autoconnect services is one of the ways to do it, probably makes sense also otherwise, and we could insert service conflict handling at the same place.
- Make
org.bluez.MediaEndpoint::SupportedFeaturesper-uuid dict
Quoted 7 lines
---
Expose the values from remote devices in
org.bluez.MediaEndpoint->SupportedFeaturesThis maybe could also be
org.bluez.Device->SupportedFeaturesinstead, but MediaEndpoint looks OK too.
This is definitely too specialized to be in the Device interface, so I think it being in MediaEndpoint is actually the proper place.
Quoted 5 lines
Sound server can use theses to determine which mandatory capabilities devices have.
TODO (maybe later): add way to configure advertised local service values, e.g. via config file.
For the local SupportedFeatures Id expect the application registering the MediaEndpoint to populate what they support, even though these features are considered device wide, not per PACS, production system will probably stick with a single entity registering endpoints (e.g. pipewire), so it seems a lot simpler to have them adds its features via MediaEndpoint.SupportedFeatures thus making the API symmetric with remote.
Quoted 36 lines
Pauli Virtanen (9):
shared/gmap: add GMAP Service
test-gmap: add test for GMAP Service
gmap: Add GMAP profile
doc: org.bluez.MediaEndpoint: add SupportedFeatures
bap: add SupportedFeatures for MediaEndpoints
profile: addafter_uuidsfor ordering profile startup
device: useafter_uuidsin service autoconnect and sort also GATT
service: addbtd_profile::readycallback whenafter_uuidsready
bap: have unicast client wait for VCS & TMAS & GMAP.gitignore | 1 + Makefile.am | 7 + Makefile.plugins | 5 + configure.ac | 7 + doc/org.bluez.MediaEndpoint.rst | 108 +++++++ lib/bluetooth/uuid.h | 8 + profiles/audio/bap.c | 163 ++++++++++- profiles/audio/gmap.c | 200 +++++++++++++ src/device.c | 74 ++++- src/profile.c | 89 ++++++ src/profile.h | 16 ++ src/service.c | 100 +++++++ src/shared/gmap.c | 401 ++++++++++++++++++++++++++ src/shared/gmap.h | 70 +++++ unit/test-gmap.c | 496 ++++++++++++++++++++++++++++++++ 15 files changed, 1730 insertions(+), 15 deletions(-) create mode 100644 profiles/audio/gmap.c create mode 100644 src/shared/gmap.c create mode 100644 src/shared/gmap.h create mode 100644 unit/test-gmap.c--
2.51.1
Signature · 1 line
Luiz Augusto von Dentz
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Fri, 28 Nov 2025 22:02:19 +0200 you wrote:
Add support for TMAP and GMAP services. They contain only device audio capability bitmasks.
v2:
- Rework the service wait to be general mechanism that also determines the service autoconnect order.[...]
Here is the summary with links:
- [BlueZ,v2,1/9] shared/gmap: add GMAP Service
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f11433431e92 - [BlueZ,v2,2/9] test-gmap: add test for GMAP Service https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5312066e67c8 - [BlueZ,v2,3/9] gmap: Add GMAP profile https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c6b1aed97b6a - [BlueZ,v2,4/9] doc: org.bluez.MediaEndpoint: add SupportedFeatures https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d4332653009c - [BlueZ,v2,5/9] bap: add SupportedFeatures for MediaEndpoints https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=71a3aa554f4f
- [BlueZ,v2,6/9] profile: add after_uuids for ordering profile startup (no matching commit)
- [BlueZ,v2,7/9] device: use after_uuids in service autoconnect and sort also GATT (no matching commit)
- [BlueZ,v2,8/9] service: add btd_profile::ready callback when after_uuids ready (no matching commit)
- [BlueZ,v2,9/9] bap: have unicast client wait for VCS & TMAS & GMAP (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ v2 6/9] profile: add after_uuids for ordering profile startup
In reply to Pauli VirtanenHi Pauli,
Quoted 115 lines · Pauli Virtanen
Add
btd_profile::after_uuidsto specify the profile connect/accept order for autoconnect. This is a "soft" dependency so it doesn't fail if the other services fail to start nor try to start them if they otherwise wouldn't.Add
btd_profile_sort_list()for sorting a list according to profile ordering, taking account priority andafter_uuids.Add
btd_profile_find_remote_uuid()lookup utility, needed when usingbtd_profile_sort_list()with uuid lists.
---Notes:
v2:
- new commitsrc/profile.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/profile.h | 13 ++++++++ 2 files changed, 102 insertions(+)src/profile.c +79
-0@@ -773,6 +773,30 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)return NULL ; } +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid) +{ +GSList *l, *next; + +for (l = profiles; l !=NULL ; l = next) { +struct btd_profile *p = l->data; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +for (l = ext_profiles; l !=NULL ; l = next) { +struct ext_profile *ext = l->data; +struct btd_profile *p = &ext->p; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +return NULL ; +} +int btd_profile_register (struct btd_profile *profile) { if (profile->experimental && !(g_dbus_get_flags() &@@ -2650,3 +2674,68 @@ void btd_profile_cleanup(void)g_dbus_unregister_interface (btd_get_dbus_connection (),"/org/bluez" ,"org.bluez.ProfileManager1" ); } + +/* Stable sort of a list according to profile priority & after_uuids */ +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data) +{ +GSList *result =NULL ; +GSList *remain = list; +GHashTable *uuids; +GSList *entry; +const struct btd_profile *p; + + uuids =g_hash_table_new_full (g_str_hash, g_str_equal, g_free,NULL ); + +/* Unsatisfied remote uuids */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_add (uuids,g_strdup (p->remote_uuid)); + } + +/* Sort */ +while (remain) { +GSList *first_entry = remain; +int max_priority =INT_MIN ; + +/* Find max priority */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->priority > max_priority) { + first_entry = entry; + max_priority = p->priority; + } + } + +/* Find max priority entry with no unsatisfied dependencies */ +for (entry = remain; entry; entry =g_slist_next (entry)) { +const char **uuid; + + p =get (entry->data, user_data); +if (p->priority < max_priority) +continue ; + +for (uuid = p->after_uuids; uuid && *uuid; uuid++) +if (g_hash_table_contains (uuids, *uuid)) +break ; +if (!(uuid && *uuid)) +break ; + } + +/* If cyclic dependencies: break preserving priority & order */ +if (!entry) + entry = first_entry; + + p =get (entry->data, user_data); +if (p->remote_uuid)
src/profile.c void btd_profile_cleanup(void) · line 2741
Quoted 10 lines
src/profile.c +10
-0+g_hash_table_remove (uuids, p->remote_uuid); + + remain =g_slist_remove_link (remain, entry); + result =g_slist_concat (result, entry); + } + +g_hash_table_destroy (uuids); + +return result; +}
We might need to build some unit testing for this sort of function, for checking if we handle cyclic/circular dependencies, if we don't end up with duplicated entries in the list as well, not sure how much testing you have done in this respect since we only really have one plugin using after_uuids.
src/profile.h struct btd_profile { · line 45
Quoted 13 lines
src/profile.h +5
-0@@ -38,6 +38,12 @@ struct btd_profile {*/ bool testing; +/* Indicates the profile should be ordered after profiles providing +* these remote uuids when connecting. A NULL-terminated array of +* strings. +*/ +const char **after_uuids;
Hmm, I wonder if this shouldn't be a struct with uuids list and function to be called when connected? Perhaps having a macro that initializes the list would be a good idea as well.
Quoted 5 lines
src/profile.h +1
-0+int (*device_probe) (struct btd_service *service);void (*device_remove) (struct btd_service *service);
src/profile.h bool btd_profile_remove_custom_prop(const char *uuid, const char *name); · line 91
Quoted 10 lines
src/profile.h +7
-0@@ -76,3 +82,10 @@ bool btd_profile_remove_custom_prop(const char *uuid, const char *name);void btd_profile_init (void );void btd_profile_cleanup (void ); + +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid); + +typedef const struct btd_profile *(*btd_profile_list_get )(void *item, +void *user_data); +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data);
Id use struct queue as return if possible.
Quoted 4 lines
--
2.51.1
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH BlueZ v2 6/9] profile: add after_uuids for ordering profile startup
ma, 2025-12-01 kello 12:00 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 126 lines
Hi Pauli,
Quoted 123 lines · Pauli Virtanen
Add
btd_profile::after_uuidsto specify the profile connect/accept order for autoconnect. This is a "soft" dependency so it doesn't fail if the other services fail to start nor try to start them if they otherwise wouldn't.Add
btd_profile_sort_list()for sorting a list according to profile ordering, taking account priority andafter_uuids.Add
btd_profile_find_remote_uuid()lookup utility, needed when usingbtd_profile_sort_list()with uuid lists.
---Notes:
v2:
- new commitsrc/profile.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/profile.h | 13 ++++++++ 2 files changed, 102 insertions(+)src/profile.c +87
-0@@ -773,6 +773,30 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)return NULL ; } +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid) +{ +GSList *l, *next; + +for (l = profiles; l !=NULL ; l = next) { +struct btd_profile *p = l->data; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +for (l = ext_profiles; l !=NULL ; l = next) { +struct ext_profile *ext = l->data; +struct btd_profile *p = &ext->p; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +return NULL ; +} +int btd_profile_register (struct btd_profile *profile) { if (profile->experimental && !(g_dbus_get_flags() &@@ -2650,3 +2674,68 @@ void btd_profile_cleanup(void)g_dbus_unregister_interface (btd_get_dbus_connection (),"/org/bluez" ,"org.bluez.ProfileManager1" ); } + +/* Stable sort of a list according to profile priority & after_uuids */ +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data) +{ +GSList *result =NULL ; +GSList *remain = list; +GHashTable *uuids; +GSList *entry; +const struct btd_profile *p; + + uuids =g_hash_table_new_full (g_str_hash, g_str_equal, g_free,NULL ); + +/* Unsatisfied remote uuids */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_add (uuids,g_strdup (p->remote_uuid)); + } + +/* Sort */ +while (remain) { +GSList *first_entry = remain; +int max_priority =INT_MIN ; + +/* Find max priority */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->priority > max_priority) { + first_entry = entry; + max_priority = p->priority; + } + } + +/* Find max priority entry with no unsatisfied dependencies */ +for (entry = remain; entry; entry =g_slist_next (entry)) { +const char **uuid; + + p =get (entry->data, user_data); +if (p->priority < max_priority) +continue ; + +for (uuid = p->after_uuids; uuid && *uuid; uuid++) +if (g_hash_table_contains (uuids, *uuid)) +break ; +if (!(uuid && *uuid)) +break ; + } + +/* If cyclic dependencies: break preserving priority & order */ +if (!entry) + entry = first_entry; + + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_remove (uuids, p->remote_uuid); + + remain =g_slist_remove_link (remain, entry); + result =g_slist_concat (result, entry); + } + +g_hash_table_destroy (uuids); +
Quoted 8 lines
src/profile.c void btd_profile_cleanup(void) · line 2741
Quoted 2 lines
src/profile.c +2
-0+return result; +}We might need to build some unit testing for this sort of function, for checking if we handle cyclic/circular dependencies, if we don't end up with duplicated entries in the list as well, not sure how much testing you have done in this respect since we only really have one plugin using
after_uuids.
I think the function should be correct, but yes unit tests would be good to have here.
Quoted 8 lines
Quoted 8 lines
src/profile.h +0
-0@@ -38,6 +38,12 @@ struct btd_profile {*/ bool testing;
Quoted 9 lines
src/profile.h struct btd_profile { · line 45
Quoted 5 lines
src/profile.h +5
-0+/* Indicates the profile should be ordered after profiles providing +* these remote uuids when connecting. A NULL-terminated array of +* strings. +*/ +const char **after_uuids;Hmm, I wonder if this shouldn't be a struct with uuids list and function to be called when connected? Perhaps having a macro that initializes the list would be a good idea as well.
So
struct btd_profile_uuid_cb {
void (*func)(struct btd_service *service);
unsigned int count;
const char *remote_uuids[];
};struct btd_profile {
...
const struct btd_profile_uuid_cb *after;
};or maybe you meant something different like separate callbacks for each UUID?
Quoted 7 lines
Quoted 7 lines
src/profile.h +1
-0+int (*device_probe) (struct btd_service *service);void (*device_remove) (struct btd_service *service);@@ -76,3 +82,10 @@ bool btd_profile_remove_custom_prop(const char *uuid, const char *name);
Quoted 11 lines
src/profile.h bool btd_profile_remove_custom_prop(const char *uuid, const char *name); · line 91
Quoted 9 lines
src/profile.h +7
-0void btd_profile_init (void );void btd_profile_cleanup (void ); + +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid); + +typedef const struct btd_profile *(*btd_profile_list_get )(void *item, +void *user_data); +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data);Id use struct queue as return if possible.
device.c used GSList for the pending list, but it could be queue in principle
Quoted 6 lines
Quoted 5 lines
--
2.51.1
Signature · 1 line
Pauli Virtanen
Luiz Augusto von Dentz
maintainerRe: [PATCH BlueZ v2 6/9] profile: add after_uuids for ordering profile startup
Hi Pauli,
Quoted 137 lines · Pauli Virtanen
ma, 2025-12-01 kello 12:00 -0500, Luiz Augusto von Dentz kirjoitti:
Quoted 126 lines
Hi Pauli,
Quoted 123 lines · Pauli Virtanen
Add
btd_profile::after_uuidsto specify the profile connect/accept order for autoconnect. This is a "soft" dependency so it doesn't fail if the other services fail to start nor try to start them if they otherwise wouldn't.Add
btd_profile_sort_list()for sorting a list according to profile ordering, taking account priority andafter_uuids.Add
btd_profile_find_remote_uuid()lookup utility, needed when usingbtd_profile_sort_list()with uuid lists.
---Notes:
v2:
- new commitsrc/profile.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/profile.h | 13 ++++++++ 2 files changed, 102 insertions(+)src/profile.c +87
-0@@ -773,6 +773,30 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)return NULL ; } +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid) +{ +GSList *l, *next; + +for (l = profiles; l !=NULL ; l = next) { +struct btd_profile *p = l->data; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +for (l = ext_profiles; l !=NULL ; l = next) { +struct ext_profile *ext = l->data; +struct btd_profile *p = &ext->p; + +if (!g_strcmp0 (p->remote_uuid, uuid)) +return p; + next =g_slist_next (l); + } + +return NULL ; +} +int btd_profile_register (struct btd_profile *profile) { if (profile->experimental && !(g_dbus_get_flags() &@@ -2650,3 +2674,68 @@ void btd_profile_cleanup(void)g_dbus_unregister_interface (btd_get_dbus_connection (),"/org/bluez" ,"org.bluez.ProfileManager1" ); } + +/* Stable sort of a list according to profile priority & after_uuids */ +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data) +{ +GSList *result =NULL ; +GSList *remain = list; +GHashTable *uuids; +GSList *entry; +const struct btd_profile *p; + + uuids =g_hash_table_new_full (g_str_hash, g_str_equal, g_free,NULL ); + +/* Unsatisfied remote uuids */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_add (uuids,g_strdup (p->remote_uuid)); + } + +/* Sort */ +while (remain) { +GSList *first_entry = remain; +int max_priority =INT_MIN ; + +/* Find max priority */ +for (entry = remain; entry; entry =g_slist_next (entry)) { + p =get (entry->data, user_data); +if (p->priority > max_priority) { + first_entry = entry; + max_priority = p->priority; + } + } + +/* Find max priority entry with no unsatisfied dependencies */ +for (entry = remain; entry; entry =g_slist_next (entry)) { +const char **uuid; + + p =get (entry->data, user_data); +if (p->priority < max_priority) +continue ; + +for (uuid = p->after_uuids; uuid && *uuid; uuid++) +if (g_hash_table_contains (uuids, *uuid)) +break ; +if (!(uuid && *uuid)) +break ; + } + +/* If cyclic dependencies: break preserving priority & order */ +if (!entry) + entry = first_entry; + + p =get (entry->data, user_data); +if (p->remote_uuid) +g_hash_table_remove (uuids, p->remote_uuid); + + remain =g_slist_remove_link (remain, entry); + result =g_slist_concat (result, entry); + } + +g_hash_table_destroy (uuids); +Quoted 8 lines
src/profile.c void btd_profile_cleanup(void) · line 2741
Quoted 2 lines
src/profile.c +2
-0+return result; +}We might need to build some unit testing for this sort of function, for checking if we handle cyclic/circular dependencies, if we don't end up with duplicated entries in the list as well, not sure how much testing you have done in this respect since we only really have one plugin using
after_uuids.
Quoted 2 lines
I think the function should be correct, but yes unit tests would be good to have here.
I don't think it is wrong, it seems correct at first glance, the problem is once it is integrated we can run into corner cases, so having some way to introduce tests for corner cases is in my opinion required.
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
src/profile.h +0
-0@@ -38,6 +38,12 @@ struct btd_profile {*/ bool testing;Quoted 9 lines
src/profile.h struct btd_profile { · line 45
Quoted 5 lines
src/profile.h +5
-0+/* Indicates the profile should be ordered after profiles providing +* these remote uuids when connecting. A NULL-terminated array of +* strings. +*/ +const char **after_uuids;Hmm, I wonder if this shouldn't be a struct with uuids list and function to be called when connected? Perhaps having a macro that initializes the list would be a good idea as well.
So
struct btd_profile_uuid_cb { void (*func)(struct btd_service *service); unsigned int count; const char *remote_uuids[]; };
Quoted 8 lines
struct btd_profile { ... const struct btd_profile_uuid_cb *after; };or maybe you meant something different like separate callbacks for each UUID?
Yeah, that seems alright, I guess we could have one per uuid as well in case the profile really need to do something for each profile it connects, but we need one for when everything has been connected anyway so Id leave just one callback for now until there is a use case where it needs callbacks to be run on a per uuid basis.
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
src/profile.h +1
-0+int (*device_probe) (struct btd_service *service);void (*device_remove) (struct btd_service *service);@@ -76,3 +82,10 @@ bool btd_profile_remove_custom_prop(const char *uuid, const char *name);Quoted 11 lines
src/profile.h bool btd_profile_remove_custom_prop(const char *uuid, const char *name); · line 91
Quoted 9 lines
src/profile.h +7
-0void btd_profile_init (void );void btd_profile_cleanup (void ); + +struct btd_profile *btd_profile_find_remote_uuid (const char *uuid); + +typedef const struct btd_profile *(*btd_profile_list_get )(void *item, +void *user_data); +GSList *btd_profile_sort_list (GSList *list,btd_profile_list_get get, +void *user_data);Id use struct queue as return if possible.
Quoted 2 lines
device.cused GSList for the pending list, but it could be queue in principle
Ah ok, well then I leave it to you if you feel like it doesn't take too much effort to convert the device.c to also use a queue that would be great, otherwise I'm fine with GSList as well.
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
--
2.51.1--
Pauli Virtanen
Signature · 1 line
Luiz Augusto von Dentz