media-session: only replace : with space for node.nick

This commit is contained in:
Wim Taymans 2021-02-13 07:17:55 +01:00
parent 3b5e040659
commit b23e33c99f

View file

@ -203,6 +203,27 @@ static const struct sm_object_methods node_methods = {
.release = node_release, .release = node_release,
}; };
static SPA_PRINTF_FUNC(4,5) char *sanitize_nick(char *name, int size,
char sub, const char *fmt, ...)
{
char *p;
va_list varargs;
va_start(varargs, fmt);
if (vsnprintf(name, size, fmt, varargs) < 0)
return NULL;
va_end(varargs);
for (p = name; *p; p++) {
switch(*p) {
case ':':
*p = sub;
break;
}
}
return name;
}
static struct node *alsa_create_node(struct device *device, uint32_t id, static struct node *alsa_create_node(struct device *device, uint32_t id,
const struct spa_device_object_info *info) const struct spa_device_object_info *info)
{ {
@ -291,8 +312,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id,
s = pw_properties_get(device->props, "alsa.card_name"); s = pw_properties_get(device->props, "alsa.card_name");
pw_properties_set(node->props, PW_KEY_NODE_NICK, pw_properties_set(node->props, PW_KEY_NODE_NICK,
sm_media_session_sanitize_name(name, sizeof(name), sanitize_nick(name, sizeof(name), ' ', "%s", s));
' ', "%s", s));
} }
if (pw_properties_get(node->props, SPA_KEY_NODE_NAME) == NULL) { if (pw_properties_get(node->props, SPA_KEY_NODE_NAME) == NULL) {