modules: ensure node.name and description are set

Most apps need this and some even crash when they are not set.
This commit is contained in:
Wim Taymans 2021-08-20 09:26:17 +02:00
parent bb2f637839
commit abf37f618e
5 changed files with 31 additions and 0 deletions

View file

@ -383,6 +383,7 @@ SPA_EXPORT
int pipewire__module_init(struct pw_impl_module *module, const char *args)
{
struct pw_context *context = pw_impl_module_get_context(module);
uint32_t id = pw_global_get_id(pw_impl_module_get_global(module));
struct pw_properties *props = NULL;
struct impl *impl;
const char *str;
@ -429,6 +430,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL)
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Source");
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL)
pw_properties_setf(props, PW_KEY_NODE_NAME, "example-source-%u", id);
if (pw_properties_get(props, PW_KEY_NODE_DESCRIPTION) == NULL)
pw_properties_set(props, PW_KEY_NODE_DESCRIPTION,
pw_properties_get(props, PW_KEY_NODE_NAME));
if ((str = pw_properties_get(props, "stream.props")) != NULL)
pw_properties_update_string(impl->stream_props, str, strlen(str));