module-loopback: make unique media name per stream

If not otherwise set, the media.name will be the name used when
pw_stream_new(), which is the same for all loopback streams.
This makes the session manager restore the same volume for all
loopback streams.

Do something more clever and use the node.name + suffix to make
the name unique per stream if no media.name was given.

Fixes #1942
This commit is contained in:
Wim Taymans 2022-01-03 13:00:15 +01:00
parent 35cbe4e939
commit 81f1a6c511

View file

@ -485,6 +485,16 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
parse_audio_info(impl->capture_props, &impl->capture_info); parse_audio_info(impl->capture_props, &impl->capture_info);
parse_audio_info(impl->playback_props, &impl->playback_info); parse_audio_info(impl->playback_props, &impl->playback_info);
if (pw_properties_get(impl->capture_props, PW_KEY_MEDIA_NAME) == NULL)
pw_properties_setf(impl->capture_props, PW_KEY_MEDIA_NAME,
"%s.loopback-capture",
pw_properties_get(impl->capture_props, PW_KEY_NODE_NAME));
if (pw_properties_get(impl->playback_props, PW_KEY_MEDIA_NAME) == NULL)
pw_properties_setf(impl->playback_props, PW_KEY_MEDIA_NAME,
"%s.loopback-playback",
pw_properties_get(impl->playback_props, PW_KEY_NODE_NAME));
impl->core = pw_context_get_object(impl->context, PW_TYPE_INTERFACE_Core); impl->core = pw_context_get_object(impl->context, PW_TYPE_INTERFACE_Core);
if (impl->core == NULL) { if (impl->core == NULL) {
str = pw_properties_get(props, PW_KEY_REMOTE_NAME); str = pw_properties_get(props, PW_KEY_REMOTE_NAME);