From 35bec2c7c4217aedf73ba38a8a8dd6578972442e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 18 Aug 2020 12:11:24 +0200 Subject: [PATCH] context: also find monitor names --- pipewire-pulseaudio/src/context.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c index a8b062722..67bfeaff6 100644 --- a/pipewire-pulseaudio/src/context.c +++ b/pipewire-pulseaudio/src/context.c @@ -155,6 +155,14 @@ const char *pa_context_find_global_name(pa_context *c, uint32_t id) return name; } +static inline bool pa_endswith(const char *s, const char *sfx) +{ + size_t l1, l2; + l1 = strlen(s); + l2 = strlen(sfx); + return l1 >= l2 && pa_streq(s + l1 - l2, sfx); +} + struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name) { struct global *g; @@ -165,9 +173,13 @@ struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, cons if ((g->mask & mask) == 0) continue; if (g->props != NULL && - (str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL && - strcmp(str, name) == 0) - return g; + (str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL) { + if (strcmp(str, name) == 0) + return g; + if (pa_endswith(name, ".monitor") && + strncmp(str, name, strlen(name) - 8) == 0) + return g; + } if (g->id == id || (g->id == (id & PA_IDX_MASK_DSP))) return g; }