mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	bluetooth: Handle UUIDs announced later
In some cases (typically during pairing) UUIDs might be reported by BlueZ incrementally, that is, as soon as they have been discovered. At this point module-bluetooth-device might already be loaded, so the late UUID announcements need to be handled and additional card profiles might need to be created accordingly.
This commit is contained in:
		
							parent
							
								
									ebfd656fc9
								
							
						
					
					
						commit
						d4368aa608
					
				
					 1 changed files with 39 additions and 0 deletions
				
			
		| 
						 | 
					@ -140,6 +140,7 @@ struct userdata {
 | 
				
			||||||
    pa_module *module;
 | 
					    pa_module *module;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_bluetooth_device *device;
 | 
					    pa_bluetooth_device *device;
 | 
				
			||||||
 | 
					    pa_hook_slot *uuid_added_slot;
 | 
				
			||||||
    char *address;
 | 
					    char *address;
 | 
				
			||||||
    char *path;
 | 
					    char *path;
 | 
				
			||||||
    pa_bluetooth_transport *transport;
 | 
					    pa_bluetooth_transport *transport;
 | 
				
			||||||
| 
						 | 
					@ -2535,6 +2536,38 @@ static pa_bluetooth_device* find_device(struct userdata *u, const char *address,
 | 
				
			||||||
    return d;
 | 
					    return d;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Run from main thread */
 | 
				
			||||||
 | 
					static pa_hook_result_t uuid_added_cb(pa_bluetooth_device *d, const char *uuid, struct userdata *u) {
 | 
				
			||||||
 | 
					    pa_card_profile *p;
 | 
				
			||||||
 | 
					    pa_hashmap *new_ports;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(d);
 | 
				
			||||||
 | 
					    pa_assert(uuid);
 | 
				
			||||||
 | 
					    pa_assert(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    p = create_card_profile(u, uuid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!p)
 | 
				
			||||||
 | 
					        return PA_HOOK_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pa_hashmap_get(u->card->profiles, p->name)) {
 | 
				
			||||||
 | 
					        pa_card_profile_free(p);
 | 
				
			||||||
 | 
					        return PA_HOOK_OK;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_card_add_profile(u->card, p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    new_ports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    create_ports_for_profile(u, new_ports, p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_card_add_ports(u->card, new_ports);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_device_port_hashmap_free(new_ports);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Run from main thread */
 | 
					/* Run from main thread */
 | 
				
			||||||
static int setup_dbus(struct userdata *u) {
 | 
					static int setup_dbus(struct userdata *u) {
 | 
				
			||||||
    DBusError err;
 | 
					    DBusError err;
 | 
				
			||||||
| 
						 | 
					@ -2658,6 +2691,9 @@ int pa__init(pa_module* m) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    u->device = device;
 | 
					    u->device = device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    u->uuid_added_slot = pa_hook_connect(&device->hooks[PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED], PA_HOOK_NORMAL,
 | 
				
			||||||
 | 
					                                         (pa_hook_cb_t) uuid_added_cb, u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Add the card structure. This will also initialize the default profile */
 | 
					    /* Add the card structure. This will also initialize the default profile */
 | 
				
			||||||
    if (add_card(u) < 0)
 | 
					    if (add_card(u) < 0)
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
| 
						 | 
					@ -2776,6 +2812,9 @@ void pa__done(pa_module *m) {
 | 
				
			||||||
        pa_dbus_connection_unref(u->connection);
 | 
					        pa_dbus_connection_unref(u->connection);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (u->uuid_added_slot)
 | 
				
			||||||
 | 
					        pa_hook_slot_free(u->uuid_added_slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (u->msg)
 | 
					    if (u->msg)
 | 
				
			||||||
        pa_xfree(u->msg);
 | 
					        pa_xfree(u->msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue