pulse-server: apply node.name to all streams

Pass properties as global properties so that they are applied
to both streams. Make sure node.name is set on both streams so that
they look good in tools like carla.
This commit is contained in:
Wim Taymans 2021-04-25 10:37:51 +02:00
parent 5d104994c0
commit 53cd601869
2 changed files with 10 additions and 12 deletions

View file

@ -65,7 +65,6 @@ static const struct pw_impl_module_events module_events = {
static void serialize_dict(FILE *f, const struct spa_dict *dict) static void serialize_dict(FILE *f, const struct spa_dict *dict)
{ {
const struct spa_dict_item *it; const struct spa_dict_item *it;
fprintf(f, "{");
spa_dict_for_each(it, dict) { spa_dict_for_each(it, dict) {
size_t len = it->value ? strlen(it->value) : 0; size_t len = it->value ? strlen(it->value) : 0;
fprintf(f, " \"%s\" = ", it->key); fprintf(f, " \"%s\" = ", it->key);
@ -82,7 +81,6 @@ static void serialize_dict(FILE *f, const struct spa_dict *dict)
fprintf(f, "%s", str); fprintf(f, "%s", str);
} }
} }
fprintf(f, " }");
} }
static int module_remap_sink_load(struct client *client, struct module *module) static int module_remap_sink_load(struct client *client, struct module *module)
@ -97,11 +95,12 @@ static int module_remap_sink_load(struct client *client, struct module *module)
f = open_memstream(&args, &size); f = open_memstream(&args, &size);
fprintf(f, "{"); fprintf(f, "{");
fprintf(f, " capture.props = "); serialize_dict(f, &module->props->dict);
fprintf(f, " capture.props = {");
serialize_dict(f, &data->capture_props->dict); serialize_dict(f, &data->capture_props->dict);
fprintf(f, " playback.props = "); fprintf(f, " } playback.props = {");
serialize_dict(f, &data->playback_props->dict); serialize_dict(f, &data->playback_props->dict);
fprintf(f, " }"); fprintf(f, " } }");
fclose(f); fclose(f);
data->mod = pw_context_load_module(module->impl->context, data->mod = pw_context_load_module(module->impl->context,
@ -192,7 +191,7 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument)
module_args_add_props(props, argument); module_args_add_props(props, argument);
if ((str = pw_properties_get(props, "sink_name")) != NULL) { if ((str = pw_properties_get(props, "sink_name")) != NULL) {
pw_properties_set(capture_props, PW_KEY_NODE_NAME, str); pw_properties_set(props, PW_KEY_NODE_NAME, str);
pw_properties_set(props, "sink_name", NULL); pw_properties_set(props, "sink_name", NULL);
} else { } else {
pw_properties_set(props, PW_KEY_NODE_NAME, "null"); pw_properties_set(props, PW_KEY_NODE_NAME, "null");

View file

@ -65,7 +65,6 @@ static const struct pw_impl_module_events module_events = {
static void serialize_dict(FILE *f, const struct spa_dict *dict) static void serialize_dict(FILE *f, const struct spa_dict *dict)
{ {
const struct spa_dict_item *it; const struct spa_dict_item *it;
fprintf(f, "{");
spa_dict_for_each(it, dict) { spa_dict_for_each(it, dict) {
size_t len = it->value ? strlen(it->value) : 0; size_t len = it->value ? strlen(it->value) : 0;
fprintf(f, " \"%s\" = ", it->key); fprintf(f, " \"%s\" = ", it->key);
@ -82,7 +81,6 @@ static void serialize_dict(FILE *f, const struct spa_dict *dict)
fprintf(f, "%s", str); fprintf(f, "%s", str);
} }
} }
fprintf(f, " }");
} }
static int module_remap_source_load(struct client *client, struct module *module) static int module_remap_source_load(struct client *client, struct module *module)
@ -97,11 +95,12 @@ static int module_remap_source_load(struct client *client, struct module *module
f = open_memstream(&args, &size); f = open_memstream(&args, &size);
fprintf(f, "{"); fprintf(f, "{");
fprintf(f, " capture.props = "); serialize_dict(f, &module->props->dict);
fprintf(f, " capture.props = { ");
serialize_dict(f, &data->capture_props->dict); serialize_dict(f, &data->capture_props->dict);
fprintf(f, " playback.props = "); fprintf(f, " } playback.props = { ");
serialize_dict(f, &data->playback_props->dict); serialize_dict(f, &data->playback_props->dict);
fprintf(f, " }"); fprintf(f, " } }");
fclose(f); fclose(f);
data->mod = pw_context_load_module(module->impl->context, data->mod = pw_context_load_module(module->impl->context,
@ -192,7 +191,7 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen
module_args_add_props(props, argument); module_args_add_props(props, argument);
if ((str = pw_properties_get(props, "source_name")) != NULL) { if ((str = pw_properties_get(props, "source_name")) != NULL) {
pw_properties_set(playback_props, PW_KEY_NODE_NAME, str); pw_properties_set(props, PW_KEY_NODE_NAME, str);
pw_properties_set(props, "source_name", NULL); pw_properties_set(props, "source_name", NULL);
} else { } else {
pw_properties_set(props, PW_KEY_NODE_NAME, "null"); pw_properties_set(props, PW_KEY_NODE_NAME, "null");