mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: improve module id in instrospect
For the modules that we load internally, place a pulse.module.id property on the nodes. If there is no module.id property on nodes, try to use the pulse.module.id when introspecting. We should not remap those to serial numbers. Fixes #2101
This commit is contained in:
parent
3b26af32d0
commit
27a8c4ad13
14 changed files with 51 additions and 26 deletions
|
|
@ -270,6 +270,7 @@ static void manager_added(void *d, struct pw_manager_object *o)
|
|||
pw_properties_set(props, PW_KEY_NODE_DONT_RECONNECT, "true");
|
||||
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
||||
pw_properties_set(props, PW_KEY_NODE_PASSIVE, "true");
|
||||
pw_properties_setf(props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
cstream->data = data;
|
||||
cstream->stream = pw_stream_new(data->core, NULL, props);
|
||||
|
|
@ -354,6 +355,7 @@ static int module_combine_sink_load(struct client *client, struct module *module
|
|||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "combine_sink-%u", data->module->index);
|
||||
pw_properties_setf(props, PW_KEY_NODE_LINK_GROUP, "combine_sink-%u", data->module->index);
|
||||
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
||||
pw_properties_setf(props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
if ((str = pw_properties_get(module->props, "sink_properties")) != NULL)
|
||||
module_args_add_props(props, str);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ static int module_ladspa_sink_load(struct client *client, struct module *module)
|
|||
|
||||
pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "ladspa-sink-%u", module->index);
|
||||
pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "ladspa-sink-%u", module->index);
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ static int module_ladspa_source_load(struct client *client, struct module *modul
|
|||
|
||||
pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "ladspa-source-%u", module->index);
|
||||
pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "ladspa-source-%u", module->index);
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ static int module_loopback_load(struct client *client, struct module *module)
|
|||
|
||||
pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "loopback-%u", module->index);
|
||||
pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "loopback-%u", module->index);
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ static int module_null_sink_load(struct client *client, struct module *module)
|
|||
|
||||
pw_core_add_listener(d->core, &d->core_listener, &core_events, module);
|
||||
|
||||
pw_properties_setf(module->props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
d->proxy = pw_core_create_object(d->core,
|
||||
"adapter", PW_TYPE_INTERFACE_Node, PW_VERSION_NODE,
|
||||
module->props ? &module->props->dict : NULL, 0);
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ static int module_pipesink_load(struct client *client, struct module *module)
|
|||
&data->core_listener,
|
||||
&core_events, data);
|
||||
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
data->capture = pw_stream_new(data->core,
|
||||
"pipesink capture", data->capture_props);
|
||||
data->capture_props = NULL;
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ static int module_pipesource_load(struct client *client, struct module *module)
|
|||
&data->core_listener,
|
||||
&core_events, data);
|
||||
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id",
|
||||
"%u", module->index);
|
||||
|
||||
data->playback = pw_stream_new(data->core,
|
||||
"pipesource playback", data->playback_props);
|
||||
data->playback_props = NULL;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ static int module_remap_sink_load(struct client *client, struct module *module)
|
|||
|
||||
pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "remap-sink-%u", module->index);
|
||||
pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "remap-sink-%u", module->index);
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ static int module_remap_source_load(struct client *client, struct module *module
|
|||
|
||||
pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "remap-source-%u", module->index);
|
||||
pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "remap-source-%u", module->index);
|
||||
pw_properties_setf(data->capture_props, "pulse.module.id", "%u", module->index);
|
||||
pw_properties_setf(data->playback_props, "pulse.module.id", "%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
|
|
|
|||
|
|
@ -71,18 +71,12 @@ static int module_roc_sink_load(struct client *client, struct module *module)
|
|||
char *args;
|
||||
size_t size;
|
||||
|
||||
pw_properties_setf(data->sink_props, "pulse.module.id",
|
||||
"%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
/* Can't just serialise this dict because the "null" method gets
|
||||
* interpreted as a JSON null */
|
||||
if ((str = pw_properties_get(data->roc_props, "local.ip")))
|
||||
fprintf(f, " local.ip = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "remote.ip")))
|
||||
fprintf(f, " remote.ip = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "remote.source.port")))
|
||||
fprintf(f, " remote.source.port = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "remote.repair.port")))
|
||||
fprintf(f, " remote.repair.port = \"%s\"", str);
|
||||
pw_properties_serialize_dict(f, &data->roc_props->dict, 0);
|
||||
fprintf(f, " } sink.props = {");
|
||||
pw_properties_serialize_dict(f, &data->sink_props->dict, 0);
|
||||
fprintf(f, " } }");
|
||||
|
|
|
|||
|
|
@ -71,20 +71,12 @@ static int module_roc_source_load(struct client *client, struct module *module)
|
|||
char *args;
|
||||
size_t size;
|
||||
|
||||
pw_properties_setf(data->source_props, "pulse.module.id",
|
||||
"%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
/* Can't just serialise this dict because the "null" method gets
|
||||
* interpreted as a JSON null */
|
||||
if ((str = pw_properties_get(data->roc_props, "local.ip")))
|
||||
fprintf(f, " local.ip = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "local.source.port")))
|
||||
fprintf(f, " local.source.port = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "local.repair.port")))
|
||||
fprintf(f, " local.repair.port = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "sess.latency.msec")))
|
||||
fprintf(f, " sess.latency.msec = \"%s\"", str);
|
||||
if ((str = pw_properties_get(data->roc_props, "resampler.profile")))
|
||||
fprintf(f, " resampler.profile = \"%s\"", str);
|
||||
pw_properties_serialize_dict(f, &data->roc_props->dict, 0);
|
||||
fprintf(f, " } source.props = {");
|
||||
pw_properties_serialize_dict(f, &data->source_props->dict, 0);
|
||||
fprintf(f, " } }");
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ static int module_tunnel_sink_load(struct client *client, struct module *module)
|
|||
|
||||
server = pw_properties_get(module->props, "server");
|
||||
|
||||
pw_properties_setf(data->stream_props, "pulse.module.id",
|
||||
"%u", module->index);
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
fprintf(f, "{");
|
||||
pw_properties_serialize_dict(f, &module->props->dict, 0);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ static int module_tunnel_source_load(struct client *client, struct module *modul
|
|||
size_t size;
|
||||
const char *server;
|
||||
|
||||
pw_properties_setf(data->stream_props, "pulse.module.id",
|
||||
"%u", module->index);
|
||||
|
||||
server = pw_properties_get(module->props, "server");
|
||||
|
||||
f = open_memstream(&args, &size);
|
||||
|
|
|
|||
|
|
@ -3555,6 +3555,9 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
snprintf(monitor_name, size, "%s.monitor", name);
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
module_id = id_to_index(manager, (uint32_t)atoi(str));
|
||||
if (module_id == SPA_ID_INVALID &&
|
||||
(str = spa_dict_lookup(info->props, "pulse.module.id")) != NULL)
|
||||
module_id = (uint32_t)atoi(str);
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_ID)) != NULL)
|
||||
card_id = (uint32_t)atoi(str);
|
||||
|
|
@ -3600,7 +3603,7 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
TAG_STRING, desc,
|
||||
TAG_SAMPLE_SPEC, &dev_info.ss,
|
||||
TAG_CHANNEL_MAP, &dev_info.map,
|
||||
TAG_U32, id_to_index(manager, module_id), /* module index */
|
||||
TAG_U32, module_id, /* module index */
|
||||
TAG_CVOLUME, &dev_info.volume_info.volume,
|
||||
TAG_BOOLEAN, dev_info.volume_info.mute,
|
||||
TAG_U32, o->index, /* monitor source index */
|
||||
|
|
@ -3759,6 +3762,9 @@ static int fill_source_info(struct client *client, struct message *m,
|
|||
snprintf(monitor_desc, size, "Monitor of %s", desc);
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
module_id = id_to_index(manager, (uint32_t)atoi(str));
|
||||
if (module_id == SPA_ID_INVALID &&
|
||||
(str = spa_dict_lookup(info->props, "pulse.module.id")) != NULL)
|
||||
module_id = (uint32_t)atoi(str);
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_ID)) != NULL)
|
||||
card_id = (uint32_t)atoi(str);
|
||||
|
|
@ -3803,7 +3809,7 @@ static int fill_source_info(struct client *client, struct message *m,
|
|||
TAG_STRING, is_monitor ? monitor_desc : desc,
|
||||
TAG_SAMPLE_SPEC, &dev_info.ss,
|
||||
TAG_CHANNEL_MAP, &dev_info.map,
|
||||
TAG_U32, id_to_index(manager, module_id), /* module index */
|
||||
TAG_U32, module_id, /* module index */
|
||||
TAG_CVOLUME, &dev_info.volume_info.volume,
|
||||
TAG_BOOLEAN, dev_info.volume_info.mute,
|
||||
TAG_U32, is_monitor ? o->index : SPA_ID_INVALID,/* monitor of sink */
|
||||
|
|
@ -3907,7 +3913,11 @@ static int fill_sink_input_info(struct client *client, struct message *m,
|
|||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
module_id = id_to_index(manager, (uint32_t)atoi(str));
|
||||
if (module_id == SPA_ID_INVALID &&
|
||||
(str = spa_dict_lookup(info->props, "pulse.module.id")) != NULL)
|
||||
module_id = (uint32_t)atoi(str);
|
||||
|
||||
if (!pw_manager_object_is_virtual(o) &&
|
||||
(str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
|
||||
client_id = (uint32_t)atoi(str);
|
||||
|
|
@ -3928,7 +3938,7 @@ static int fill_sink_input_info(struct client *client, struct message *m,
|
|||
message_put(m,
|
||||
TAG_U32, o->index, /* sink_input index */
|
||||
TAG_STRING, get_media_name(info),
|
||||
TAG_U32, id_to_index(manager, module_id), /* module index */
|
||||
TAG_U32, module_id, /* module index */
|
||||
TAG_U32, id_to_index(manager, client_id), /* client index */
|
||||
TAG_U32, peer_index, /* sink index */
|
||||
TAG_SAMPLE_SPEC, &dev_info.ss,
|
||||
|
|
@ -3983,7 +3993,11 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
|||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
module_id = id_to_index(manager, (uint32_t)atoi(str));
|
||||
if (module_id == SPA_ID_INVALID &&
|
||||
(str = spa_dict_lookup(info->props, "pulse.module.id")) != NULL)
|
||||
module_id = (uint32_t)atoi(str);
|
||||
|
||||
if (!pw_manager_object_is_virtual(o) &&
|
||||
(str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
|
||||
client_id = (uint32_t)atoi(str);
|
||||
|
|
@ -4004,7 +4018,7 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
|||
message_put(m,
|
||||
TAG_U32, o->index, /* source_output index */
|
||||
TAG_STRING, get_media_name(info),
|
||||
TAG_U32, id_to_index(manager, module_id), /* module index */
|
||||
TAG_U32, module_id, /* module index */
|
||||
TAG_U32, id_to_index(manager, client_id), /* client index */
|
||||
TAG_U32, peer_index, /* source index */
|
||||
TAG_SAMPLE_SPEC, &dev_info.ss,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue