impl-port: add port.group property

Can be used to group ports together. Mostly because they are all from
the same stream and split into multiple ports by audioconvert/adapter.

Also useful for the alsa sequence to group client ports together.

Also interesting when pw-filter would be able to handle streams in the
future to find out what ports belong to what streams.
This commit is contained in:
Wim Taymans 2024-06-24 12:34:38 +02:00
parent 54c3fa06ed
commit 9d1d1fcbef
13 changed files with 62 additions and 23 deletions

View file

@ -176,6 +176,9 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
if ((str = pw_properties_get(props, PW_KEY_NODE_ID)) != NULL)
pw_properties_set(props, PW_KEY_NODE_SESSION, str);
if (pw_properties_get(props, PW_KEY_PORT_GROUP) == NULL)
pw_properties_setf(props, PW_KEY_PORT_GROUP, "stream.0");
if ((res = find_format(follower, direction, &media_type, &media_subtype)) < 0)
goto error;

View file

@ -1793,6 +1793,9 @@ void *pw_filter_add_port(struct pw_filter *filter,
if ((p = alloc_port(impl, direction, port_data_size)) == NULL)
goto error_cleanup;
if (pw_properties_get(props, PW_KEY_PORT_GROUP) == NULL)
pw_properties_setf(props, PW_KEY_PORT_GROUP, "stream.%u", p->id);
p->props = props;
p->flags = flags;

View file

@ -1148,6 +1148,7 @@ int pw_impl_port_register(struct pw_impl_port *port,
PW_KEY_PORT_ALIAS,
PW_KEY_PORT_EXTRA,
PW_KEY_PORT_IGNORE_LATENCY,
PW_KEY_PORT_GROUP,
NULL
};

View file

@ -231,6 +231,7 @@ extern "C" {
* should be prefixed. "jack:flags:56" */
#define PW_KEY_PORT_PASSIVE "port.passive" /**< the ports wants passive links, since 0.3.67 */
#define PW_KEY_PORT_IGNORE_LATENCY "port.ignore-latency" /**< latency ignored by peers, since 0.3.71 */
#define PW_KEY_PORT_GROUP "port.group" /**< the port group of the port 1.2.0 */
/** link properties */
#define PW_KEY_LINK_ID "link.id" /**< a link id */

View file

@ -1993,6 +1993,8 @@ pw_stream_connect(struct pw_stream *stream,
else if (impl->media_type == SPA_MEDIA_TYPE_application &&
impl->media_subtype == SPA_MEDIA_SUBTYPE_control)
pw_properties_set(impl->port_props, PW_KEY_FORMAT_DSP, "8 bit raw midi");
if (pw_properties_get(impl->port_props, PW_KEY_PORT_GROUP) == NULL)
pw_properties_set(impl->port_props, PW_KEY_PORT_GROUP, "stream.0");
if ((str = pw_properties_get(stream->properties, PW_KEY_NODE_ASYNC)) != NULL && spa_atob(str))
SPA_FLAG_SET(impl->info.flags, SPA_NODE_FLAG_ASYNC);
@ -2028,8 +2030,6 @@ pw_stream_connect(struct pw_stream *stream,
if ((str = pw_properties_get(stream->properties, "mem.allow-mlock")) != NULL)
impl->allow_mlock = pw_properties_parse_bool(str);
impl->port_info.props = &impl->port_props->dict;
if (stream->core == NULL) {
stream->core = pw_context_connect(impl->context,
pw_properties_copy(stream->properties), 0);
@ -2056,6 +2056,8 @@ pw_stream_connect(struct pw_stream *stream,
pw_properties_set(props, "channelmix.normalize", "true");
pw_properties_set(props, PW_KEY_PORT_IGNORE_LATENCY, "true");
}
if (pw_properties_get(props, PW_KEY_PORT_GROUP) == NULL)
pw_properties_set(props, PW_KEY_PORT_GROUP, "stream.0");
if (impl->media_type == SPA_MEDIA_TYPE_audio
|| (impl->media_type == SPA_MEDIA_TYPE_video