From aa7223cd8c483db1606e5890360cb33763437d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 21 Aug 2022 21:41:52 +0200 Subject: [PATCH] ao_pipewire: create is_sink_node helper --- audio/out/ao_pipewire.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index 1f9fe44e1e..c94d411262 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -276,6 +276,21 @@ struct registry_event_global_ctx { void *sink_cb_ctx; }; +static bool is_sink_node(const char *type, const struct spa_dict *props) +{ + if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0) + return false; + + if (!props) + return false; + + const char *class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); + if (!class || strcmp(class, "Audio/Sink") != 0) + return false; + + return true; +} + static void for_each_sink_registry_event_global(void *data, uint32_t id, uint32_t permissions, const char *type, uint32_t version, @@ -283,14 +298,7 @@ static void for_each_sink_registry_event_global(void *data, uint32_t id, { struct registry_event_global_ctx *ctx = data; - if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0) - return; - - if (!props) - return; - - const char *class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); - if (!class || strcmp(class, "Audio/Sink") != 0) + if (!is_sink_node(type, props)) return; ctx->sink_cb(ctx->ao, id, props, ctx->sink_cb_ctx);