mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: don't pass library around
Don't pass the library in the methods, we use the factory_name to find the object. Make it possible to override the default library with a property.
This commit is contained in:
		
							parent
							
								
									1d1f035e78
								
							
						
					
					
						commit
						d4def56bcb
					
				
					 13 changed files with 99 additions and 86 deletions
				
			
		| 
						 | 
				
			
			@ -33,6 +33,9 @@
 | 
			
		|||
 | 
			
		||||
#include "spa-device.h"
 | 
			
		||||
 | 
			
		||||
#define FACTORY_USAGE	"spa.factory.name=<factory-name> " \
 | 
			
		||||
			"[spa.library.name=<library-name>]"
 | 
			
		||||
 | 
			
		||||
static const struct spa_dict_item module_props[] = {
 | 
			
		||||
	{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
 | 
			
		||||
	{ PW_KEY_MODULE_DESCRIPTION, "Provide a factory to make SPA devices" },
 | 
			
		||||
| 
						 | 
				
			
			@ -78,28 +81,23 @@ static void *create_object(void *_data,
 | 
			
		|||
	struct factory_data *data = _data;
 | 
			
		||||
	struct pw_core *core = data->core;
 | 
			
		||||
	struct pw_device *device;
 | 
			
		||||
	const char *lib, *factory_name, *name;
 | 
			
		||||
	const char *factory_name, *name;
 | 
			
		||||
	struct device_data *nd;
 | 
			
		||||
 | 
			
		||||
	if (properties == NULL)
 | 
			
		||||
		goto no_properties;
 | 
			
		||||
 | 
			
		||||
	lib = pw_properties_get(properties, "spa.library.name");
 | 
			
		||||
	factory_name = pw_properties_get(properties, "spa.factory.name");
 | 
			
		||||
	name = pw_properties_get(properties, "name");
 | 
			
		||||
 | 
			
		||||
	if (lib == NULL && factory_name != NULL)
 | 
			
		||||
		lib = pw_core_find_spa_lib(core, factory_name);
 | 
			
		||||
	if (lib == NULL || factory_name == NULL)
 | 
			
		||||
	if (factory_name == NULL)
 | 
			
		||||
		goto no_properties;
 | 
			
		||||
 | 
			
		||||
	name = pw_properties_get(properties, "name");
 | 
			
		||||
	if (name == NULL)
 | 
			
		||||
		name = "spa-device";
 | 
			
		||||
 | 
			
		||||
	device = pw_spa_device_load(core,
 | 
			
		||||
				NULL,
 | 
			
		||||
				pw_factory_get_global(data->this),
 | 
			
		||||
				lib,
 | 
			
		||||
				factory_name,
 | 
			
		||||
				name,
 | 
			
		||||
				0,
 | 
			
		||||
| 
						 | 
				
			
			@ -123,12 +121,9 @@ static void *create_object(void *_data,
 | 
			
		|||
	return device;
 | 
			
		||||
 | 
			
		||||
      no_properties:
 | 
			
		||||
	pw_log_error("needed properties: [spa.library.name=<library-name>] spa.factory.name=<factory-name>");
 | 
			
		||||
	pw_log_error("factory %p: usage: " FACTORY_USAGE, data->this);
 | 
			
		||||
	if (resource) {
 | 
			
		||||
		pw_resource_error(resource, -EINVAL,
 | 
			
		||||
					"needed properties: "
 | 
			
		||||
						"[spa.library.name=<library-name>] "
 | 
			
		||||
						"spa.factory.name=<factory-name>");
 | 
			
		||||
		pw_resource_error(resource, -EINVAL, "usage: " FACTORY_USAGE);
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
      no_mem:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue