mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	modules: add usage to factories
Improve audio-dsp properties Fix some keys
This commit is contained in:
		
							parent
							
								
									d4def56bcb
								
							
						
					
					
						commit
						a672a9ee67
					
				
					 9 changed files with 44 additions and 29 deletions
				
			
		| 
						 | 
					@ -98,9 +98,7 @@ static void *create_object(void *_data,
 | 
				
			||||||
	struct factory_data *d = _data;
 | 
						struct factory_data *d = _data;
 | 
				
			||||||
	struct pw_client *client;
 | 
						struct pw_client *client;
 | 
				
			||||||
	struct pw_node *dsp;
 | 
						struct pw_node *dsp;
 | 
				
			||||||
	int res, maxbuffer;
 | 
						int res;
 | 
				
			||||||
	const char *str;
 | 
					 | 
				
			||||||
	enum pw_direction direction;
 | 
					 | 
				
			||||||
	struct node_data *nd;
 | 
						struct node_data *nd;
 | 
				
			||||||
	struct pw_resource *bound_resource;
 | 
						struct pw_resource *bound_resource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,24 +107,16 @@ static void *create_object(void *_data,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	client = pw_resource_get_client(resource);
 | 
						client = pw_resource_get_client(resource);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((str = pw_properties_get(properties, "audio-dsp.direction")) == NULL)
 | 
					 | 
				
			||||||
		goto no_props;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	direction = pw_properties_parse_int(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((str = pw_properties_get(properties, "audio-dsp.maxbuffer")) == NULL)
 | 
					 | 
				
			||||||
		goto no_props;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	maxbuffer = pw_properties_parse_int(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dsp = pw_audio_dsp_new(pw_module_get_core(d->module),
 | 
						dsp = pw_audio_dsp_new(pw_module_get_core(d->module),
 | 
				
			||||||
			properties,
 | 
								properties,
 | 
				
			||||||
			direction,
 | 
					 | 
				
			||||||
			maxbuffer,
 | 
					 | 
				
			||||||
			sizeof(struct node_data));
 | 
								sizeof(struct node_data));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dsp == NULL)
 | 
						if (dsp == NULL) {
 | 
				
			||||||
		goto no_mem;
 | 
							if (errno == ENOMEM)
 | 
				
			||||||
 | 
								goto no_mem;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								goto usage;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nd = pw_audio_dsp_get_user_data(dsp);
 | 
						nd = pw_audio_dsp_get_user_data(dsp);
 | 
				
			||||||
	nd->data = d;
 | 
						nd->data = d;
 | 
				
			||||||
| 
						 | 
					@ -157,9 +147,9 @@ static void *create_object(void *_data,
 | 
				
			||||||
	pw_log_error("audio-dsp needs a resource");
 | 
						pw_log_error("audio-dsp needs a resource");
 | 
				
			||||||
	pw_resource_error(resource, -EINVAL, "no resource");
 | 
						pw_resource_error(resource, -EINVAL, "no resource");
 | 
				
			||||||
	goto done;
 | 
						goto done;
 | 
				
			||||||
      no_props:
 | 
					      usage:
 | 
				
			||||||
	pw_log_error("audio-dsp needs a property");
 | 
						pw_log_error("usage: "AUDIO_DSP_USAGE);
 | 
				
			||||||
	pw_resource_error(resource, -EINVAL, "no property");
 | 
						pw_resource_error(resource, -EINVAL, "usage: "AUDIO_DSP_USAGE);
 | 
				
			||||||
	goto done;
 | 
						goto done;
 | 
				
			||||||
      no_mem:
 | 
					      no_mem:
 | 
				
			||||||
	pw_log_error("can't create node");
 | 
						pw_log_error("can't create node");
 | 
				
			||||||
| 
						 | 
					@ -210,7 +200,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
 | 
				
			||||||
				 "audio-dsp",
 | 
									 "audio-dsp",
 | 
				
			||||||
				 PW_TYPE_INTERFACE_Node,
 | 
									 PW_TYPE_INTERFACE_Node,
 | 
				
			||||||
				 PW_VERSION_NODE_PROXY,
 | 
									 PW_VERSION_NODE_PROXY,
 | 
				
			||||||
				 NULL,
 | 
									 pw_properties_new(
 | 
				
			||||||
 | 
										 PW_KEY_FACTORY_USAGE, AUDIO_DSP_USAGE,
 | 
				
			||||||
 | 
										 NULL),
 | 
				
			||||||
				 sizeof(*data));
 | 
									 sizeof(*data));
 | 
				
			||||||
	if (factory == NULL)
 | 
						if (factory == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,8 +258,6 @@ static const struct pw_node_events node_events = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pw_node *pw_audio_dsp_new(struct pw_core *core,
 | 
					struct pw_node *pw_audio_dsp_new(struct pw_core *core,
 | 
				
			||||||
		const struct pw_properties *props,
 | 
							const struct pw_properties *props,
 | 
				
			||||||
		enum pw_direction direction,
 | 
					 | 
				
			||||||
		uint32_t max_buffer_size,
 | 
					 | 
				
			||||||
		size_t user_data_size)
 | 
							size_t user_data_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_node *node;
 | 
						struct pw_node *node;
 | 
				
			||||||
| 
						 | 
					@ -267,10 +265,24 @@ struct pw_node *pw_audio_dsp_new(struct pw_core *core,
 | 
				
			||||||
	const char *api, *alias, *str, *factory;
 | 
						const char *api, *alias, *str, *factory;
 | 
				
			||||||
	char node_name[128];
 | 
						char node_name[128];
 | 
				
			||||||
	struct pw_properties *pr;
 | 
						struct pw_properties *pr;
 | 
				
			||||||
 | 
						enum pw_direction direction;
 | 
				
			||||||
 | 
						uint32_t max_buffer_size;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr = pw_properties_copy(props);
 | 
						pr = pw_properties_copy(props);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((str = pw_properties_get(pr, "audio-dsp.direction")) == NULL) {
 | 
				
			||||||
 | 
							pw_log_error("missing audio-dsp.direction property");
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						direction = pw_properties_parse_int(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((str = pw_properties_get(pr, "audio-dsp.maxbuffer")) == NULL) {
 | 
				
			||||||
 | 
							pw_log_error("missing audio-dsp.maxbuffer property");
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						max_buffer_size = pw_properties_parse_int(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((api = pw_properties_get(pr, PW_KEY_DEVICE_API)) == NULL) {
 | 
						if ((api = pw_properties_get(pr, PW_KEY_DEVICE_API)) == NULL) {
 | 
				
			||||||
		pw_log_error("missing "PW_KEY_DEVICE_API" property");
 | 
							pw_log_error("missing "PW_KEY_DEVICE_API" property");
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,11 +32,15 @@
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define AUDIO_DSP_USAGE	"audio-dsp.direction=<enum spa_direction> "	\
 | 
				
			||||||
 | 
								"audio-dsp.maxbuffer=<int> "			\
 | 
				
			||||||
 | 
								"audio-dsp.name=<string> "			\
 | 
				
			||||||
 | 
								PW_KEY_DEVICE_API"=<string> "			\
 | 
				
			||||||
 | 
								"["PW_KEY_NODE_ID"=<int>]"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pw_node *
 | 
					struct pw_node *
 | 
				
			||||||
pw_audio_dsp_new(struct pw_core *core,
 | 
					pw_audio_dsp_new(struct pw_core *core,
 | 
				
			||||||
		 const struct pw_properties *properties,
 | 
							 const struct pw_properties *properties,
 | 
				
			||||||
		 enum pw_direction direction,
 | 
					 | 
				
			||||||
		 uint32_t max_buffer_size,
 | 
					 | 
				
			||||||
		 size_t user_data_size);
 | 
							 size_t user_data_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void *pw_audio_dsp_get_user_data(struct pw_node *node);
 | 
					void *pw_audio_dsp_get_user_data(struct pw_node *node);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +123,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
 | 
				
			||||||
				 "client-device",
 | 
									 "client-device",
 | 
				
			||||||
				 SPA_TYPE_INTERFACE_Device,
 | 
									 SPA_TYPE_INTERFACE_Device,
 | 
				
			||||||
				 SPA_VERSION_DEVICE,
 | 
									 SPA_VERSION_DEVICE,
 | 
				
			||||||
				 NULL,
 | 
									 pw_properties_new(
 | 
				
			||||||
 | 
										 PW_KEY_FACTORY_USAGE, CLIENT_DEVICE_USAGE,
 | 
				
			||||||
 | 
										 NULL),
 | 
				
			||||||
				 sizeof(*data));
 | 
									 sizeof(*data));
 | 
				
			||||||
	if (factory == NULL)
 | 
						if (factory == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,8 @@
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CLIENT_DEVICE_USAGE	"["PW_KEY_DEVICE_NAME"=<string>]"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pw_device *
 | 
					struct pw_device *
 | 
				
			||||||
pw_client_device_new(struct pw_resource *resource,
 | 
					pw_client_device_new(struct pw_resource *resource,
 | 
				
			||||||
		   struct pw_global *parent,
 | 
							   struct pw_global *parent,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,7 +320,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
 | 
				
			||||||
				 "link-factory",
 | 
									 "link-factory",
 | 
				
			||||||
				 PW_TYPE_INTERFACE_Link,
 | 
									 PW_TYPE_INTERFACE_Link,
 | 
				
			||||||
				 PW_VERSION_LINK_PROXY,
 | 
									 PW_VERSION_LINK_PROXY,
 | 
				
			||||||
				 NULL,
 | 
									 pw_properties_new(
 | 
				
			||||||
 | 
										 PW_KEY_FACTORY_USAGE, FACTORY_USAGE,
 | 
				
			||||||
 | 
										 NULL),
 | 
				
			||||||
				 sizeof(*data));
 | 
									 sizeof(*data));
 | 
				
			||||||
	if (factory == NULL)
 | 
						if (factory == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ static void *create_object(void *_data,
 | 
				
			||||||
	if (factory_name == NULL)
 | 
						if (factory_name == NULL)
 | 
				
			||||||
		goto no_properties;
 | 
							goto no_properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	name = pw_properties_get(properties, "name");
 | 
						name = pw_properties_get(properties, PW_KEY_DEVICE_NAME);
 | 
				
			||||||
	if (name == NULL)
 | 
						if (name == NULL)
 | 
				
			||||||
		name = "spa-device";
 | 
							name = "spa-device";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ static void *create_object(void *_data,
 | 
				
			||||||
	if (factory_name == NULL)
 | 
						if (factory_name == NULL)
 | 
				
			||||||
		goto no_properties;
 | 
							goto no_properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	name = pw_properties_get(properties, "name");
 | 
						name = pw_properties_get(properties, PW_KEY_NODE_NAME);
 | 
				
			||||||
	if (name == NULL)
 | 
						if (name == NULL)
 | 
				
			||||||
		name = "spa-node";
 | 
							name = "spa-node";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -180,6 +180,7 @@ extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Factory properties */
 | 
					/** Factory properties */
 | 
				
			||||||
#define PW_KEY_FACTORY_NAME		"factory.name"		/**< the name of the factory */
 | 
					#define PW_KEY_FACTORY_NAME		"factory.name"		/**< the name of the factory */
 | 
				
			||||||
 | 
					#define PW_KEY_FACTORY_USAGE		"factory.usage"		/**< the usage of the factory */
 | 
				
			||||||
#define PW_KEY_FACTORY_TYPE_NAME	"factory.type.name"	/**< the name of the type created by a factory */
 | 
					#define PW_KEY_FACTORY_TYPE_NAME	"factory.type.name"	/**< the name of the type created by a factory */
 | 
				
			||||||
#define PW_KEY_FACTORY_TYPE_VERSION	"factory.type.version"	/**< the version of the type created by a factory */
 | 
					#define PW_KEY_FACTORY_TYPE_VERSION	"factory.type.version"	/**< the version of the type created by a factory */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue