mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	bluetooth: Create pa_bluetooth_adapter for BlueZ 5 support
This commit is contained in:
		
							parent
							
								
									19a23cef10
								
							
						
					
					
						commit
						546da17cbe
					
				
					 2 changed files with 41 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -45,8 +45,36 @@ struct pa_bluetooth_discovery {
 | 
			
		|||
    bool filter_added;
 | 
			
		||||
    bool matches_added;
 | 
			
		||||
    pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
 | 
			
		||||
    pa_hashmap *adapters;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static pa_bluetooth_adapter* adapter_create(pa_bluetooth_discovery *y, const char *path) {
 | 
			
		||||
    pa_bluetooth_adapter *a;
 | 
			
		||||
 | 
			
		||||
    pa_assert(y);
 | 
			
		||||
    pa_assert(path);
 | 
			
		||||
 | 
			
		||||
    a = pa_xnew0(pa_bluetooth_adapter, 1);
 | 
			
		||||
    a->discovery = y;
 | 
			
		||||
    a->path = pa_xstrdup(path);
 | 
			
		||||
 | 
			
		||||
    pa_hashmap_put(y->adapters, a->path, a);
 | 
			
		||||
 | 
			
		||||
    return a;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void adapter_remove_all(pa_bluetooth_discovery *y) {
 | 
			
		||||
    pa_bluetooth_adapter *a;
 | 
			
		||||
 | 
			
		||||
    pa_assert(y);
 | 
			
		||||
 | 
			
		||||
    while ((a = pa_hashmap_steal_first(y->adapters))) {
 | 
			
		||||
        pa_xfree(a->path);
 | 
			
		||||
        pa_xfree(a->address);
 | 
			
		||||
        pa_xfree(a);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook) {
 | 
			
		||||
    pa_assert(y);
 | 
			
		||||
    pa_assert(PA_REFCNT_VALUE(y) > 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -109,6 +137,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
 | 
			
		|||
    y = pa_xnew0(pa_bluetooth_discovery, 1);
 | 
			
		||||
    PA_REFCNT_INIT(y);
 | 
			
		||||
    y->core = c;
 | 
			
		||||
    y->adapters = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++)
 | 
			
		||||
        pa_hook_init(&y->hooks[i], y);
 | 
			
		||||
| 
						 | 
				
			
			@ -165,6 +194,11 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
 | 
			
		|||
    if (PA_REFCNT_DEC(y) > 0)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (y->adapters) {
 | 
			
		||||
        adapter_remove_all(y);
 | 
			
		||||
        pa_hashmap_free(y->adapters);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (y->connection) {
 | 
			
		||||
 | 
			
		||||
        if (y->matches_added)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue