pulse: use monitor endpoints as monitor

This commit is contained in:
Wim Taymans 2019-11-18 13:12:28 +01:00
parent aef04961aa
commit b432bda109
3 changed files with 22 additions and 24 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;
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));