mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Revert "pw-cli: use core object to map id to proxy"
This reverts commit 918acd61ef.
			
			
This commit is contained in:
		
							parent
							
								
									e9884fcfb5
								
							
						
					
					
						commit
						d880db3933
					
				
					 1 changed files with 19 additions and 14 deletions
				
			
		| 
						 | 
					@ -121,6 +121,7 @@ struct remote_data {
 | 
				
			||||||
	struct spa_hook registry_listener;
 | 
						struct spa_hook registry_listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct pw_map globals;
 | 
						struct pw_map globals;
 | 
				
			||||||
 | 
						struct pw_map globals_by_proxy;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct proxy_data;
 | 
					struct proxy_data;
 | 
				
			||||||
| 
						 | 
					@ -441,6 +442,9 @@ static int destroy_global(void *obj, void *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rd = global->rd;
 | 
						rd = global->rd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (global->proxy_id)
 | 
				
			||||||
 | 
							pw_map_remove(&rd->globals_by_proxy, global->proxy_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_map_remove(&rd->globals, global->id);
 | 
						pw_map_remove(&rd->globals, global->id);
 | 
				
			||||||
	if (global->properties)
 | 
						if (global->properties)
 | 
				
			||||||
		pw_properties_free(global->properties);
 | 
							pw_properties_free(global->properties);
 | 
				
			||||||
| 
						 | 
					@ -467,21 +471,15 @@ remote_global(struct remote_data *rd, uint32_t id)
 | 
				
			||||||
static struct global *
 | 
					static struct global *
 | 
				
			||||||
remote_global_by_proxy(struct remote_data *rd, uint32_t id)
 | 
					remote_global_by_proxy(struct remote_data *rd, uint32_t id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_proxy *proxy;
 | 
						struct global *global;
 | 
				
			||||||
	struct proxy_data *pd;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!rd)
 | 
						if (!rd)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	proxy = pw_core_find_proxy(rd->core, id);
 | 
						global = pw_map_lookup(&rd->globals_by_proxy, id);
 | 
				
			||||||
	if (proxy == NULL)
 | 
						if (!global || !global->proxy || !pw_proxy_get_user_data(global->proxy))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
						return global;
 | 
				
			||||||
	pd = pw_proxy_get_user_data(proxy);
 | 
					 | 
				
			||||||
	if (pd == NULL)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return pd->global;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool global_can_subscribe_params(struct global *global)
 | 
					static bool global_can_subscribe_params(struct global *global)
 | 
				
			||||||
| 
						 | 
					@ -943,6 +941,7 @@ static bool do_connect(struct data *data, const char *cmd, char *args, char **er
 | 
				
			||||||
	rd->core = core;
 | 
						rd->core = core;
 | 
				
			||||||
	rd->data = data;
 | 
						rd->data = data;
 | 
				
			||||||
	pw_map_init(&rd->globals, 64, 16);
 | 
						pw_map_init(&rd->globals, 64, 16);
 | 
				
			||||||
 | 
						pw_map_init(&rd->globals_by_proxy, 64, 16);
 | 
				
			||||||
	rd->id = pw_map_insert_new(&data->vars, rd);
 | 
						rd->id = pw_map_insert_new(&data->vars, rd);
 | 
				
			||||||
	spa_list_append(&data->remotes, &rd->link);
 | 
						spa_list_append(&data->remotes, &rd->link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1815,6 +1814,7 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
 | 
				
			||||||
        pw_destroy_t destroy;
 | 
					        pw_destroy_t destroy;
 | 
				
			||||||
	struct proxy_data *pd;
 | 
						struct proxy_data *pd;
 | 
				
			||||||
	struct pw_proxy *proxy;
 | 
						struct pw_proxy *proxy;
 | 
				
			||||||
 | 
						size_t size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strcmp(global->type, PW_TYPE_INTERFACE_Core) == 0) {
 | 
						if (strcmp(global->type, PW_TYPE_INTERFACE_Core) == 0) {
 | 
				
			||||||
		events = &core_events;
 | 
							events = &core_events;
 | 
				
			||||||
| 
						 | 
					@ -1899,6 +1899,11 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
 | 
				
			||||||
	global->proxy = proxy;
 | 
						global->proxy = proxy;
 | 
				
			||||||
	global->proxy_id = pw_proxy_get_id(proxy);
 | 
						global->proxy_id = pw_proxy_get_id(proxy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size = pw_map_get_size(&rd->globals_by_proxy);
 | 
				
			||||||
 | 
						while (global->proxy_id > size)
 | 
				
			||||||
 | 
							pw_map_insert_at(&rd->globals_by_proxy, size++, NULL);
 | 
				
			||||||
 | 
						pw_map_insert_at(&rd->globals_by_proxy, global->proxy_id, global);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue