From edc4c856b7cc78de602644225357ab0d0daa7480 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 17 Apr 2024 09:53:54 +0200 Subject: [PATCH] stream: log a warning when media.class and direction mismatch Fixes #2493 --- src/pipewire/stream.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 8b64635e8..25df78a96 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -2027,11 +2027,25 @@ pw_stream_connect(struct pw_stream *stream, pw_properties_set(stream->properties, PW_KEY_NODE_TRIGGER, "true"); impl->trigger = true; } - if ((pw_properties_get(stream->properties, PW_KEY_MEDIA_CLASS) == NULL)) { + if (((str = pw_properties_get(stream->properties, PW_KEY_MEDIA_CLASS)) == NULL)) { const char *media_type = pw_properties_get(stream->properties, PW_KEY_MEDIA_TYPE); pw_properties_setf(stream->properties, PW_KEY_MEDIA_CLASS, "Stream/%s/%s", direction == PW_DIRECTION_INPUT ? "Input" : "Output", media_type ? media_type : get_media_class(impl)); + } else { + enum pw_direction expected; + + if (strstr(str, "Input") || strstr(str, "Sink")) + expected = PW_DIRECTION_INPUT; + else if (strstr(str, "Output") || strstr(str, "Source")) + expected = PW_DIRECTION_OUTPUT; + else + expected = direction; + + if (direction != expected) + pw_log_warn("media.class %s does not expect %s stream direction", str, + direction == PW_DIRECTION_INPUT ? "Input" : "Output"); + } if ((str = pw_properties_get(stream->properties, PW_KEY_FORMAT_DSP)) != NULL) pw_properties_set(impl->port_props, PW_KEY_FORMAT_DSP, str);