mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
Update for new adapter nodes
This commit is contained in:
parent
d00b9f1635
commit
67c1dca897
5 changed files with 52 additions and 38 deletions
|
|
@ -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 &&
|
(str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL &&
|
||||||
strcmp(str, name) == 0)
|
strcmp(str, name) == 0)
|
||||||
return g;
|
return g;
|
||||||
if (g->id == id)
|
if (g->id == id || (g->id == (id & PA_IDX_MASK_DSP)))
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -163,14 +163,8 @@ struct global *pa_context_find_linked(pa_context *c, uint32_t idx)
|
||||||
f = pa_context_find_global(c, g->link_info.src->parent_id);
|
f = pa_context_find_global(c, g->link_info.src->parent_id);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (f->mask & PA_SUBSCRIPTION_MASK_DSP) {
|
|
||||||
if (!(f->mask & PA_SUBSCRIPTION_MASK_SOURCE) ||
|
|
||||||
g->link_info.dst->parent_id != idx)
|
|
||||||
f = pa_context_find_global(c, f->dsp_info.session);
|
|
||||||
}
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -178,13 +172,20 @@ struct global *pa_context_find_linked(pa_context *c, uint32_t idx)
|
||||||
|
|
||||||
static void emit_event(pa_context *c, struct global *g, pa_subscription_event_type_t event)
|
static void emit_event(pa_context *c, struct global *g, pa_subscription_event_type_t event)
|
||||||
{
|
{
|
||||||
if (c->subscribe_mask & g->mask) {
|
if (c->subscribe_callback && (c->subscribe_mask & g->mask)) {
|
||||||
if (c->subscribe_callback) {
|
|
||||||
pw_log_debug("context %p: obj %d: emit %d:%d", c, g->id, event, g->event);
|
pw_log_debug("context %p: obj %d: emit %d:%d", c, g->id, event, g->event);
|
||||||
c->subscribe_callback(c,
|
c->subscribe_callback(c,
|
||||||
event | g->event,
|
event | g->event,
|
||||||
g->id,
|
g->id,
|
||||||
c->subscribe_userdata);
|
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->node_info.monitor,
|
||||||
|
event, PA_SUBSCRIPTION_EVENT_SOURCE);
|
||||||
|
c->subscribe_callback(c,
|
||||||
|
event | PA_SUBSCRIPTION_EVENT_SOURCE,
|
||||||
|
g->node_info.monitor,
|
||||||
|
c->subscribe_userdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -518,31 +519,28 @@ static int set_mask(pa_context *c, struct global *g)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strcmp(str, "Audio/Sink") == 0) {
|
if (strcmp(str, "Audio/Sink") == 0) {
|
||||||
|
return 0;
|
||||||
pw_log_debug("found sink %d", g->id);
|
pw_log_debug("found sink %d", g->id);
|
||||||
g->mask = PA_SUBSCRIPTION_MASK_SINK;
|
g->mask = PA_SUBSCRIPTION_MASK_SINK;
|
||||||
g->event = PA_SUBSCRIPTION_EVENT_SINK;
|
g->event = PA_SUBSCRIPTION_EVENT_SINK;
|
||||||
g->node_info.monitor = SPA_ID_INVALID;
|
g->node_info.monitor = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
else if (strcmp(str, "Audio/DSP/Playback") == 0) {
|
else if (strcmp(str, "Audio/DSP/Playback") == 0) {
|
||||||
if ((str = pw_properties_get(g->props, PW_KEY_NODE_SESSION)) == NULL)
|
pw_log_debug("found playback/monitor DSP %d", g->id);
|
||||||
return 0;
|
g->mask = PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE;
|
||||||
pw_log_debug("found monitor %d", g->id);
|
g->event = PA_SUBSCRIPTION_EVENT_SINK;
|
||||||
g->mask = PA_SUBSCRIPTION_MASK_DSP_SINK | PA_SUBSCRIPTION_MASK_SOURCE;
|
g->node_info.monitor = g->id | PA_IDX_FLAG_DSP;
|
||||||
g->event = PA_SUBSCRIPTION_EVENT_SOURCE;
|
|
||||||
g->dsp_info.session = pw_properties_parse_int(str);
|
|
||||||
if ((f = pa_context_find_global(c, g->dsp_info.session)) != NULL)
|
|
||||||
f->node_info.monitor = g->id;
|
|
||||||
}
|
}
|
||||||
else if (strcmp(str, "Audio/Source") == 0) {
|
else if (strcmp(str, "Audio/Source") == 0) {
|
||||||
|
return 0;
|
||||||
pw_log_debug("found source %d", g->id);
|
pw_log_debug("found source %d", g->id);
|
||||||
g->mask = PA_SUBSCRIPTION_MASK_SOURCE;
|
g->mask = PA_SUBSCRIPTION_MASK_SOURCE;
|
||||||
g->event = PA_SUBSCRIPTION_EVENT_SOURCE;
|
g->event = PA_SUBSCRIPTION_EVENT_SOURCE;
|
||||||
}
|
}
|
||||||
else if (strcmp(str, "Audio/DSP/Capture") == 0) {
|
else if (strcmp(str, "Audio/DSP/Capture") == 0) {
|
||||||
if ((str = pw_properties_get(g->props, PW_KEY_NODE_SESSION)) == NULL)
|
pw_log_debug("found capture DSP %d", g->id);
|
||||||
return 0;
|
g->mask = PA_SUBSCRIPTION_MASK_SOURCE;
|
||||||
g->mask = PA_SUBSCRIPTION_MASK_DSP_SOURCE;
|
g->event = PA_SUBSCRIPTION_EVENT_SOURCE;
|
||||||
g->dsp_info.session = pw_properties_parse_int(str);
|
|
||||||
}
|
}
|
||||||
else if (strcmp(str, "Stream/Output/Audio") == 0) {
|
else if (strcmp(str, "Stream/Output/Audio") == 0) {
|
||||||
pw_log_debug("found sink input %d", g->id);
|
pw_log_debug("found sink input %d", g->id);
|
||||||
|
|
|
||||||
|
|
@ -210,9 +210,8 @@ struct param {
|
||||||
void *param;
|
void *param;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PA_SUBSCRIPTION_MASK_DSP_SINK 0x1000U
|
#define PA_IDX_FLAG_DSP 0x800000U
|
||||||
#define PA_SUBSCRIPTION_MASK_DSP_SOURCE 0x2000U
|
#define PA_IDX_MASK_DSP 0x7fffffU
|
||||||
#define PA_SUBSCRIPTION_MASK_DSP (PA_SUBSCRIPTION_MASK_DSP_SINK | PA_SUBSCRIPTION_MASK_DSP_SOURCE)
|
|
||||||
|
|
||||||
struct global {
|
struct global {
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
|
|
@ -242,10 +241,6 @@ struct global {
|
||||||
struct global *src;
|
struct global *src;
|
||||||
struct global *dst;
|
struct global *dst;
|
||||||
} link_info;
|
} link_info;
|
||||||
/* for dsp source and sink */
|
|
||||||
struct {
|
|
||||||
uint32_t session;
|
|
||||||
} dsp_info;
|
|
||||||
/* for sink/source */
|
/* for sink/source */
|
||||||
struct {
|
struct {
|
||||||
uint32_t monitor;
|
uint32_t monitor;
|
||||||
|
|
|
||||||
|
|
@ -507,9 +507,10 @@ static void source_callback(struct source_data *d)
|
||||||
i.owner_module = g->parent_id;
|
i.owner_module = g->parent_id;
|
||||||
pa_cvolume_set(&i.volume, 2, g->node_info.volume * PA_VOLUME_NORM);
|
pa_cvolume_set(&i.volume, 2, g->node_info.volume * PA_VOLUME_NORM);
|
||||||
i.mute = g->node_info.mute;
|
i.mute = g->node_info.mute;
|
||||||
if (g->mask & PA_SUBSCRIPTION_MASK_DSP_SINK) {
|
if (g->mask & PA_SUBSCRIPTION_MASK_SINK) {
|
||||||
i.monitor_of_sink = g->dsp_info.session;
|
i.monitor_of_sink = g->id;
|
||||||
i.monitor_of_sink_name = "unknown";
|
i.monitor_of_sink_name = "unknown";
|
||||||
|
i.index = g->node_info.monitor;
|
||||||
} else {
|
} else {
|
||||||
i.monitor_of_sink = PA_INVALID_INDEX;
|
i.monitor_of_sink = PA_INVALID_INDEX;
|
||||||
i.monitor_of_sink_name = NULL;
|
i.monitor_of_sink_name = NULL;
|
||||||
|
|
@ -588,9 +589,12 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p
|
||||||
|
|
||||||
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
|
||||||
|
|
||||||
if ((g = pa_context_find_global(c, idx)) == NULL)
|
pw_log_debug("context %p: index %d", c, idx);
|
||||||
return NULL;
|
|
||||||
if (!(g->mask & PA_SUBSCRIPTION_MASK_SOURCE))
|
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))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
|
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
|
||||||
|
|
|
||||||
|
|
@ -286,10 +286,18 @@ int pa_mainloop_prepare(pa_mainloop *m, int timeout)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pa_mainloop_poll(pa_mainloop *m)
|
int pa_mainloop_poll(pa_mainloop *m)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
if (m->quit)
|
if (m->quit)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
return m->n_events = pw_loop_iterate(m->loop, m->timeout);
|
res = pw_loop_iterate(m->loop, m->timeout);
|
||||||
|
if (res < 0) {
|
||||||
|
if (res == -EINTR)
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
m->n_events = res;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,16 @@ static void configure_device(pa_stream *s)
|
||||||
s->device_name = NULL;
|
s->device_name = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (s->direction == PA_STREAM_RECORD) {
|
||||||
|
if (g->mask == (PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE))
|
||||||
|
s->device_index = g->node_info.monitor;
|
||||||
|
else
|
||||||
s->device_index = g->id;
|
s->device_index = g->id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s->device_index = g->id;
|
||||||
|
}
|
||||||
|
|
||||||
if ((str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL)
|
if ((str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL)
|
||||||
s->device_name = strdup("unknown");
|
s->device_name = strdup("unknown");
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue