From b432bda1091a227f685521214aad8d3d9d984c6e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 18 Nov 2019 13:12:28 +0100 Subject: [PATCH] pulse: use monitor endpoints as monitor --- pipewire-pulseaudio/src/context.c | 23 +++++++++++------------ pipewire-pulseaudio/src/internal.h | 3 --- pipewire-pulseaudio/src/introspect.c | 20 +++++++++++--------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c index dec05b03c..c84fba14f 100644 --- a/pipewire-pulseaudio/src/context.c +++ b/pipewire-pulseaudio/src/context.c @@ -139,7 +139,7 @@ struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, cons (str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL && strcmp(str, name) == 0) return g; - if (g->id == id || (g->id == (id & PA_IDX_MASK_DSP))) + if (g->id == id) return g; } return NULL; @@ -182,15 +182,6 @@ static void emit_event(pa_context *c, struct global *g, pa_subscription_event_ty event | g->event, g->id, c->subscribe_userdata); - - if (g->mask == (PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE)) { - pw_log_debug("context %p: obj %d: emit %d:%d", c, g->endpoint_info.monitor, - event, PA_SUBSCRIPTION_EVENT_SOURCE); - c->subscribe_callback(c, - event | PA_SUBSCRIPTION_EVENT_SOURCE, - g->endpoint_info.monitor, - c->subscribe_userdata); - } } } @@ -615,18 +606,26 @@ static int set_mask(pa_context *c, struct global *g) pw_log_warn("endpoint %d without "PW_KEY_MEDIA_CLASS, g->id); return 0; } + g->endpoint_info.monitor = SPA_ID_INVALID; /* endpoints get transformed into sink/source or sink_input/source_output */ if (strcmp(str, "Audio/Sink") == 0) { pw_log_debug("found sink %d", g->id); - g->mask = PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE; + g->mask = PA_SUBSCRIPTION_MASK_SINK; g->event = PA_SUBSCRIPTION_EVENT_SINK; - g->endpoint_info.monitor = g->id | PA_IDX_FLAG_DSP; } else if (strcmp(str, "Audio/Source") == 0) { pw_log_debug("found source %d", g->id); g->mask = PA_SUBSCRIPTION_MASK_SOURCE; g->event = PA_SUBSCRIPTION_EVENT_SOURCE; + if ((str = pw_properties_get(g->props, PW_KEY_ENDPOINT_MONITOR)) != NULL) { + struct global *f; + f = pa_context_find_global(c, pw_properties_parse_int(str)); + if (f != NULL) { + g->endpoint_info.monitor = f->id; + f->endpoint_info.monitor = g->id; + } + } } else if (strcmp(str, "Stream/Output/Audio") == 0) { pw_log_debug("found sink input %d", g->id); diff --git a/pipewire-pulseaudio/src/internal.h b/pipewire-pulseaudio/src/internal.h index c9bdc1064..79e60b7ee 100644 --- a/pipewire-pulseaudio/src/internal.h +++ b/pipewire-pulseaudio/src/internal.h @@ -219,9 +219,6 @@ struct param { void *param; }; -#define PA_IDX_FLAG_DSP 0x800000U -#define PA_IDX_MASK_DSP 0x7fffffU - struct global { struct spa_list link; uint32_t id; diff --git a/pipewire-pulseaudio/src/introspect.c b/pipewire-pulseaudio/src/introspect.c index 870055c42..f20b7d361 100644 --- a/pipewire-pulseaudio/src/introspect.c +++ b/pipewire-pulseaudio/src/introspect.c @@ -121,8 +121,13 @@ static void sink_callback(struct sink_data *d) for (n = 0; n < i.volume.channels; n++) i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM; i.mute = g->endpoint_info.mute; - i.monitor_source = g->endpoint_info.monitor; - i.monitor_source_name = "unknown"; + if (g->endpoint_info.monitor != SPA_ID_INVALID) { + i.monitor_source = g->endpoint_info.monitor; + i.monitor_source_name = "unknown"; + } else { + i.monitor_source = PA_INVALID_INDEX; + i.monitor_source_name = NULL; + } i.latency = 0; i.driver = "PipeWire"; i.flags = PA_SINK_HARDWARE | @@ -567,10 +572,9 @@ static void source_callback(struct source_data *d) for (n = 0; n < i.volume.channels; n++) i.volume.values[n] = g->endpoint_info.volume * g->endpoint_info.channel_volumes[n] * PA_VOLUME_NORM; i.mute = g->endpoint_info.mute; - if (g->mask & PA_SUBSCRIPTION_MASK_SINK) { - i.monitor_of_sink = g->id; + if (g->endpoint_info.monitor != SPA_ID_INVALID) { + i.monitor_of_sink = g->endpoint_info.monitor; i.monitor_of_sink_name = "unknown"; - i.index = g->endpoint_info.monitor; } else { i.monitor_of_sink = PA_INVALID_INDEX; i.monitor_of_sink_name = NULL; @@ -651,10 +655,8 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p pw_log_debug("context %p: index %d", c, idx); - if (((g = pa_context_find_global(c, idx)) == NULL || - !(g->mask & PA_SUBSCRIPTION_MASK_SOURCE)) && - (((g = pa_context_find_global(c, idx & PA_IDX_MASK_DSP)) == NULL || - !(g->mask & PA_SUBSCRIPTION_MASK_SOURCE)))) + if ((g = pa_context_find_global(c, idx)) == NULL || + !(g->mask & PA_SUBSCRIPTION_MASK_SOURCE)) return NULL; o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));