diff --git a/src/modules/module-audio-dsp.c b/src/modules/module-audio-dsp.c index 278c4ccac..6263df1f3 100644 --- a/src/modules/module-audio-dsp.c +++ b/src/modules/module-audio-dsp.c @@ -98,9 +98,7 @@ static void *create_object(void *_data, struct factory_data *d = _data; struct pw_client *client; struct pw_node *dsp; - int res, maxbuffer; - const char *str; - enum pw_direction direction; + int res; struct node_data *nd; struct pw_resource *bound_resource; @@ -109,24 +107,16 @@ static void *create_object(void *_data, 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), properties, - direction, - maxbuffer, sizeof(struct node_data)); - if (dsp == NULL) - goto no_mem; + if (dsp == NULL) { + if (errno == ENOMEM) + goto no_mem; + else + goto usage; + } nd = pw_audio_dsp_get_user_data(dsp); nd->data = d; @@ -157,9 +147,9 @@ static void *create_object(void *_data, pw_log_error("audio-dsp needs a resource"); pw_resource_error(resource, -EINVAL, "no resource"); goto done; - no_props: - pw_log_error("audio-dsp needs a property"); - pw_resource_error(resource, -EINVAL, "no property"); + usage: + pw_log_error("usage: "AUDIO_DSP_USAGE); + pw_resource_error(resource, -EINVAL, "usage: "AUDIO_DSP_USAGE); goto done; no_mem: 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", PW_TYPE_INTERFACE_Node, PW_VERSION_NODE_PROXY, - NULL, + pw_properties_new( + PW_KEY_FACTORY_USAGE, AUDIO_DSP_USAGE, + NULL), sizeof(*data)); if (factory == NULL) return -ENOMEM; diff --git a/src/modules/module-audio-dsp/audio-dsp.c b/src/modules/module-audio-dsp/audio-dsp.c index 9ce459ee3..d9f0a70fc 100644 --- a/src/modules/module-audio-dsp/audio-dsp.c +++ b/src/modules/module-audio-dsp/audio-dsp.c @@ -258,8 +258,6 @@ static const struct pw_node_events node_events = { struct pw_node *pw_audio_dsp_new(struct pw_core *core, const struct pw_properties *props, - enum pw_direction direction, - uint32_t max_buffer_size, size_t user_data_size) { 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; char node_name[128]; struct pw_properties *pr; + enum pw_direction direction; + uint32_t max_buffer_size; int i; 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) { pw_log_error("missing "PW_KEY_DEVICE_API" property"); goto error; diff --git a/src/modules/module-audio-dsp/audio-dsp.h b/src/modules/module-audio-dsp/audio-dsp.h index 24cdb9bc7..ce5e863ae 100644 --- a/src/modules/module-audio-dsp/audio-dsp.h +++ b/src/modules/module-audio-dsp/audio-dsp.h @@ -32,11 +32,15 @@ extern "C" { #endif +#define AUDIO_DSP_USAGE "audio-dsp.direction= " \ + "audio-dsp.maxbuffer= " \ + "audio-dsp.name= " \ + PW_KEY_DEVICE_API"= " \ + "["PW_KEY_NODE_ID"=]" + struct pw_node * pw_audio_dsp_new(struct pw_core *core, const struct pw_properties *properties, - enum pw_direction direction, - uint32_t max_buffer_size, size_t user_data_size); void *pw_audio_dsp_get_user_data(struct pw_node *node); diff --git a/src/modules/module-client-device.c b/src/modules/module-client-device.c index c440eb4d1..0302ffc31 100644 --- a/src/modules/module-client-device.c +++ b/src/modules/module-client-device.c @@ -123,7 +123,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie "client-device", SPA_TYPE_INTERFACE_Device, SPA_VERSION_DEVICE, - NULL, + pw_properties_new( + PW_KEY_FACTORY_USAGE, CLIENT_DEVICE_USAGE, + NULL), sizeof(*data)); if (factory == NULL) return -ENOMEM; diff --git a/src/modules/module-client-device/client-device.h b/src/modules/module-client-device/client-device.h index 9dd702753..818c5c463 100644 --- a/src/modules/module-client-device/client-device.h +++ b/src/modules/module-client-device/client-device.h @@ -31,6 +31,8 @@ extern "C" { #endif +#define CLIENT_DEVICE_USAGE "["PW_KEY_DEVICE_NAME"=]" + struct pw_device * pw_client_device_new(struct pw_resource *resource, struct pw_global *parent, diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index a9c3b04b5..8ed6b427a 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -320,7 +320,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie "link-factory", PW_TYPE_INTERFACE_Link, PW_VERSION_LINK_PROXY, - NULL, + pw_properties_new( + PW_KEY_FACTORY_USAGE, FACTORY_USAGE, + NULL), sizeof(*data)); if (factory == NULL) return -ENOMEM; diff --git a/src/modules/spa/module-device-factory.c b/src/modules/spa/module-device-factory.c index 7f09ea552..dadb7cd10 100644 --- a/src/modules/spa/module-device-factory.c +++ b/src/modules/spa/module-device-factory.c @@ -91,7 +91,7 @@ static void *create_object(void *_data, if (factory_name == NULL) goto no_properties; - name = pw_properties_get(properties, "name"); + name = pw_properties_get(properties, PW_KEY_DEVICE_NAME); if (name == NULL) name = "spa-device"; diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index c2de801a3..ec666dc71 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -91,7 +91,7 @@ static void *create_object(void *_data, if (factory_name == NULL) goto no_properties; - name = pw_properties_get(properties, "name"); + name = pw_properties_get(properties, PW_KEY_NODE_NAME); if (name == NULL) name = "spa-node"; diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index b0750761c..2b91d2e87 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -180,6 +180,7 @@ extern "C" { /** Factory properties */ #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_VERSION "factory.type.version" /**< the version of the type created by a factory */