mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	impl-node: ensure same data loop inside the node
Make sure the loop used to load the spa plugin matches the loop of the impl-node and the port mixer loops.
This commit is contained in:
		
							parent
							
								
									8dabf3486e
								
							
						
					
					
						commit
						7e26fa57e5
					
				
					 4 changed files with 26 additions and 17 deletions
				
			
		| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <spa/node/node.h>
 | 
					#include <spa/node/node.h>
 | 
				
			||||||
#include <spa/node/utils.h>
 | 
					#include <spa/node/utils.h>
 | 
				
			||||||
 | 
					#include <spa/utils/cleanup.h>
 | 
				
			||||||
#include <spa/utils/result.h>
 | 
					#include <spa/utils/result.h>
 | 
				
			||||||
#include <spa/param/props.h>
 | 
					#include <spa/param/props.h>
 | 
				
			||||||
#include <spa/pod/iter.h>
 | 
					#include <spa/pod/iter.h>
 | 
				
			||||||
| 
						 | 
					@ -223,16 +224,27 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
 | 
				
			||||||
	struct spa_handle *handle;
 | 
						struct spa_handle *handle;
 | 
				
			||||||
	void *iface;
 | 
						void *iface;
 | 
				
			||||||
	const struct pw_properties *p;
 | 
						const struct pw_properties *p;
 | 
				
			||||||
 | 
						struct pw_loop *loop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (properties) {
 | 
						if (properties) {
 | 
				
			||||||
		p = pw_context_get_properties(context);
 | 
							p = pw_context_get_properties(context);
 | 
				
			||||||
		pw_properties_set(properties, "clock.quantum-limit",
 | 
							pw_properties_set(properties, "clock.quantum-limit",
 | 
				
			||||||
				pw_properties_get(p, "default.clock.quantum-limit"));
 | 
									pw_properties_get(p, "default.clock.quantum-limit"));
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							properties = pw_properties_new(NULL, NULL);
 | 
				
			||||||
 | 
							if (properties == NULL)
 | 
				
			||||||
 | 
								return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						loop =  pw_context_acquire_loop(context, &properties->dict);
 | 
				
			||||||
 | 
						if (loop == NULL) {
 | 
				
			||||||
 | 
							res = -errno;
 | 
				
			||||||
 | 
							goto error_exit;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handle = pw_context_load_spa_handle(context,
 | 
						pw_properties_set(properties, PW_KEY_NODE_LOOP_NAME, loop->name);
 | 
				
			||||||
			factory_name,
 | 
						pw_context_release_loop(context, loop);
 | 
				
			||||||
			properties ? &properties->dict : NULL);
 | 
					
 | 
				
			||||||
 | 
						handle = pw_context_load_spa_handle(context, factory_name, &properties->dict);
 | 
				
			||||||
	if (handle == NULL) {
 | 
						if (handle == NULL) {
 | 
				
			||||||
		res = -errno;
 | 
							res = -errno;
 | 
				
			||||||
		goto error_exit;
 | 
							goto error_exit;
 | 
				
			||||||
| 
						 | 
					@ -247,20 +259,15 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_node = iface;
 | 
						spa_node = iface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (properties != NULL) {
 | 
						if ((res = setup_props(context, spa_node, properties)) < 0)
 | 
				
			||||||
		if ((res = setup_props(context, spa_node, properties)) < 0) {
 | 
					 | 
				
			||||||
		pw_log_warn("can't setup properties: %s", spa_strerror(res));
 | 
							pw_log_warn("can't setup properties: %s", spa_strerror(res));
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this = pw_spa_node_new(context, flags,
 | 
						this = pw_spa_node_new(context, flags,
 | 
				
			||||||
			       spa_node, handle, properties, user_data_size);
 | 
								       spa_node, handle, spa_steal_ptr(properties), user_data_size);
 | 
				
			||||||
	if (this == NULL) {
 | 
						if (this == NULL) {
 | 
				
			||||||
		res = -errno;
 | 
							res = -errno;
 | 
				
			||||||
		properties = NULL;
 | 
					 | 
				
			||||||
		goto error_exit_unload;
 | 
							goto error_exit_unload;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return this;
 | 
						return this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
error_exit_unload:
 | 
					error_exit_unload:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -700,7 +700,8 @@ static struct pw_data_loop *acquire_data_loop(struct impl *impl, const char *nam
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_info("using name:'%s' class:'%s' ref:%d", best_loop->impl->loop->name,
 | 
						pw_log_info("%p: using name:'%s' class:'%s' ref:%d", impl,
 | 
				
			||||||
 | 
								best_loop->impl->loop->name,
 | 
				
			||||||
			best_loop->impl->class, best_loop->ref);
 | 
								best_loop->impl->class, best_loop->ref);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return best_loop->impl;
 | 
						return best_loop->impl;
 | 
				
			||||||
| 
						 | 
					@ -723,12 +724,12 @@ struct pw_loop *pw_context_acquire_loop(struct pw_context *context, const struct
 | 
				
			||||||
	name = props ? spa_dict_lookup(props, PW_KEY_NODE_LOOP_NAME) : NULL;
 | 
						name = props ? spa_dict_lookup(props, PW_KEY_NODE_LOOP_NAME) : NULL;
 | 
				
			||||||
	klass = props ? spa_dict_lookup(props, PW_KEY_NODE_LOOP_CLASS) : NULL;
 | 
						klass = props ? spa_dict_lookup(props, PW_KEY_NODE_LOOP_CLASS) : NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_info("looking for name:'%s' class:'%s'", name, klass);
 | 
						pw_log_info("%p: looking for name:'%s' class:'%s'", context, name, klass);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((impl->n_data_loops == 0) ||
 | 
						if ((impl->n_data_loops == 0) ||
 | 
				
			||||||
	    (name && fnmatch(name, context->main_loop->name, FNM_EXTMATCH) == 0) ||
 | 
						    (name && fnmatch(name, context->main_loop->name, FNM_EXTMATCH) == 0) ||
 | 
				
			||||||
	    (klass && fnmatch(klass, "main", FNM_EXTMATCH) == 0)) {
 | 
						    (klass && fnmatch(klass, "main", FNM_EXTMATCH) == 0)) {
 | 
				
			||||||
		pw_log_info("using main loop num-data-loops:%d", impl->n_data_loops);
 | 
							pw_log_info("%p: using main loop num-data-loops:%d", context, impl->n_data_loops);
 | 
				
			||||||
		return context->main_loop;
 | 
							return context->main_loop;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1561,7 +1561,7 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
 | 
				
			||||||
					SPA_FD_CLOEXEC | SPA_FD_NONBLOCK)) < 0)
 | 
										SPA_FD_CLOEXEC | SPA_FD_NONBLOCK)) < 0)
 | 
				
			||||||
		goto error_clean;
 | 
							goto error_clean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_debug("%p: new fd:%d", this, res);
 | 
						pw_log_debug("%p: new fd:%d loop:%s", this, res, this->data_loop->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->source.fd = res;
 | 
						this->source.fd = res;
 | 
				
			||||||
	this->source.func = node_on_fd_events;
 | 
						this->source.func = node_on_fd_events;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -894,7 +894,7 @@ static int setup_mixer(struct pw_impl_port *port, const struct spa_pod *param)
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	const char *fallback_lib, *factory_name;
 | 
						const char *fallback_lib, *factory_name;
 | 
				
			||||||
	struct spa_handle *handle;
 | 
						struct spa_handle *handle;
 | 
				
			||||||
	struct spa_dict_item items[2];
 | 
						struct spa_dict_item items[3];
 | 
				
			||||||
	char quantum_limit[16];
 | 
						char quantum_limit[16];
 | 
				
			||||||
	void *iface;
 | 
						void *iface;
 | 
				
			||||||
	struct pw_context *context = port->node->context;
 | 
						struct pw_context *context = port->node->context;
 | 
				
			||||||
| 
						 | 
					@ -902,7 +902,7 @@ static int setup_mixer(struct pw_impl_port *port, const struct spa_pod *param)
 | 
				
			||||||
	if ((res = spa_format_parse(param, &media_type, &media_subtype)) < 0)
 | 
						if ((res = spa_format_parse(param, &media_type, &media_subtype)) < 0)
 | 
				
			||||||
		return res;
 | 
							return res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_debug("%p: %s/%s", port,
 | 
						pw_log_debug("%p/%p: %s/%s", port->node, port,
 | 
				
			||||||
			spa_debug_type_find_name(spa_type_media_type, media_type),
 | 
								spa_debug_type_find_name(spa_type_media_type, media_type),
 | 
				
			||||||
			spa_debug_type_find_name(spa_type_media_subtype, media_subtype));
 | 
								spa_debug_type_find_name(spa_type_media_subtype, media_subtype));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -950,6 +950,7 @@ static int setup_mixer(struct pw_impl_port *port, const struct spa_pod *param)
 | 
				
			||||||
	spa_scnprintf(quantum_limit, sizeof(quantum_limit), "%u",
 | 
						spa_scnprintf(quantum_limit, sizeof(quantum_limit), "%u",
 | 
				
			||||||
			context->settings.clock_quantum_limit);
 | 
								context->settings.clock_quantum_limit);
 | 
				
			||||||
	items[1] = SPA_DICT_ITEM_INIT("clock.quantum-limit", quantum_limit);
 | 
						items[1] = SPA_DICT_ITEM_INIT("clock.quantum-limit", quantum_limit);
 | 
				
			||||||
 | 
						items[2] = SPA_DICT_ITEM_INIT(PW_KEY_NODE_LOOP_NAME, port->node->data_loop->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handle = pw_context_load_spa_handle(context, factory_name,
 | 
						handle = pw_context_load_spa_handle(context, factory_name,
 | 
				
			||||||
			&SPA_DICT_INIT_ARRAY(items));
 | 
								&SPA_DICT_INIT_ARRAY(items));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue