summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2020-08-04 18:16:02 +0200
committerWim Taymans <wtaymans@redhat.com>2020-08-04 18:16:02 +0200
commit377b3f9d425c7a33c14fe1d8e43379d08d9eaef1 (patch)
treef42d7be160a81697891ef413b47b06c35d823c1f
parent653465a1b1a1b362ff3e35e36c1951cfbd6be2b5 (diff)
pulse: always load the registry
Always get the registry, even if we're not using the introspect API we still need it to keep track of the linked devices.
-rw-r--r--pipewire-pulseaudio/src/context.c24
-rw-r--r--pipewire-pulseaudio/src/internal.h1
-rw-r--r--pipewire-pulseaudio/src/introspect.c87
3 files changed, 7 insertions, 105 deletions
diff --git a/pipewire-pulseaudio/src/context.c b/pipewire-pulseaudio/src/context.c
index 35414cec..7366ac58 100644
--- a/pipewire-pulseaudio/src/context.c
+++ b/pipewire-pulseaudio/src/context.c
@@ -1353,18 +1353,6 @@ static void on_success(pa_operation *o, void *userdata)
pa_operation_done(o);
}
-void pa_context_ensure_registry(pa_context *c)
-{
- if (c->registry != NULL)
- return;
-
- c->registry = pw_core_get_registry(c->core,
- PW_VERSION_REGISTRY, 0);
- pw_registry_add_listener(c->registry,
- &c->registry_listener,
- &registry_events, c);
-}
-
SPA_EXPORT
pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_context_success_cb_t cb, void *userdata)
{
@@ -1378,8 +1366,6 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
c->subscribe_mask = m;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, on_success, sizeof(struct success_data));
d = o->userdata;
d->cb = cb;
@@ -1561,6 +1547,12 @@ int pa_context_connect(pa_context *c, const char *server, pa_context_flags_t fla
}
pw_core_add_listener(c->core, &c->core_listener, &core_events, c);
+ c->registry = pw_core_get_registry(c->core,
+ PW_VERSION_REGISTRY, 0);
+ pw_registry_add_listener(c->registry,
+ &c->registry_listener,
+ &registry_events, c);
+
exit:
pa_context_unref(c);
@@ -1677,8 +1669,6 @@ pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_co
pa_operation *o;
struct default_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_default_node, sizeof(*d));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -1697,8 +1687,6 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_
pa_operation *o;
struct default_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_default_node, sizeof(*d));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
diff --git a/pipewire-pulseaudio/src/internal.h b/pipewire-pulseaudio/src/internal.h
index 21847ce7..f7f9042f 100644
--- a/pipewire-pulseaudio/src/internal.h
+++ b/pipewire-pulseaudio/src/internal.h
@@ -364,7 +364,6 @@ struct global *pa_context_find_global(pa_context *c, uint32_t id);
const char *pa_context_find_global_name(pa_context *c, uint32_t id);
struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name);
struct global *pa_context_find_linked(pa_context *c, uint32_t id);
-void pa_context_ensure_registry(pa_context *c);
struct pa_mem {
struct spa_list link;
diff --git a/pipewire-pulseaudio/src/introspect.c b/pipewire-pulseaudio/src/introspect.c
index c9c1e6d0..e4cbb803 100644
--- a/pipewire-pulseaudio/src/introspect.c
+++ b/pipewire-pulseaudio/src/introspect.c
@@ -220,8 +220,6 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name,
pw_log_debug("%p", c);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, sink_info, sizeof(struct sink_data));
d = o->userdata;
d->cb = cb;
@@ -245,8 +243,6 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, sink_info, sizeof(struct sink_data));
d = o->userdata;
d->cb = cb;
@@ -284,8 +280,6 @@ pa_operation* pa_context_get_sink_info_list(pa_context *c, pa_sink_info_cb_t cb,
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, sink_info_list, sizeof(struct sink_data));
d = o->userdata;
d->cb = cb;
@@ -507,8 +501,6 @@ pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, c
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -537,8 +529,6 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name
pw_log_debug("context %p: name %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->cb = cb;
@@ -566,8 +556,6 @@ pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int
pw_log_debug("context %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -593,8 +581,6 @@ pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name,
pw_log_debug("context %p: name %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -745,8 +731,6 @@ pa_operation* pa_context_set_sink_port_by_index(pa_context *c, uint32_t idx, con
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_device_route, sizeof(struct device_route));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -768,8 +752,6 @@ pa_operation* pa_context_set_sink_port_by_name(pa_context *c, const char*name, c
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_device_route, sizeof(struct device_route));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SINK;
@@ -963,8 +945,6 @@ pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
d = o->userdata;
d->cb = cb;
@@ -989,8 +969,6 @@ 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);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, source_info, sizeof(struct source_data));
d = o->userdata;
d->cb = cb;
@@ -1028,8 +1006,6 @@ pa_operation* pa_context_get_source_info_list(pa_context *c, pa_source_info_cb_t
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, source_info_list, sizeof(struct source_data));
d = o->userdata;
d->cb = cb;
@@ -1054,8 +1030,6 @@ pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx,
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1084,8 +1058,6 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na
pw_log_debug("context %p: name %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1113,8 +1085,6 @@ pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, i
pw_log_debug("context %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1141,8 +1111,6 @@ pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name
pw_log_debug("context %p: name %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_node_volume_mute, sizeof(struct volume_data));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1200,8 +1168,6 @@ pa_operation* pa_context_set_source_port_by_index(pa_context *c, uint32_t idx, c
pw_log_debug("context %p: idx %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_device_route, sizeof(struct device_route));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1225,8 +1191,6 @@ pa_operation* pa_context_set_source_port_by_name(pa_context *c, const char*name,
pw_log_debug("context %p: name %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_device_route, sizeof(struct device_route));
d = o->userdata;
d->mask = PA_SUBSCRIPTION_MASK_SOURCE;
@@ -1251,6 +1215,7 @@ static const char *get_default_name(pa_context *c, uint32_t mask)
const char *str;
uint32_t id = SPA_ID_INVALID;
+
if (c->metadata) {
if (mask & PA_SUBSCRIPTION_MASK_SINK)
id = c->default_sink;
@@ -1311,8 +1276,6 @@ pa_operation* pa_context_get_server_info(pa_context *c, pa_server_info_cb_t cb,
pa_assert(c->refcount >= 1);
pa_assert(cb);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, server_info, sizeof(struct server_data));
d = o->userdata;
d->cb = cb;
@@ -1368,8 +1331,6 @@ pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, module_info, sizeof(struct module_data));
d = o->userdata;
d->idx = idx;
@@ -1407,8 +1368,6 @@ pa_operation* pa_context_get_module_info_list(pa_context *c, pa_module_info_cb_t
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, module_info_list, sizeof(struct module_data));
d = o->userdata;
d->cb = cb;
@@ -1488,8 +1447,6 @@ pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, client_info, sizeof(struct client_data));
d = o->userdata;
d->idx = idx;
@@ -1527,8 +1484,6 @@ pa_operation* pa_context_get_client_info_list(pa_context *c, pa_client_info_cb_t
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, client_info_list, sizeof(struct client_data));
d = o->userdata;
d->cb = cb;
@@ -1575,8 +1530,6 @@ pa_operation* pa_context_kill_client(pa_context *c, uint32_t idx, pa_context_suc
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_kill_client, sizeof(struct kill_client));
d = o->userdata;
d->idx = idx;
@@ -1643,8 +1596,6 @@ pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
pw_log_debug("context %p: %u", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, card_info, sizeof(struct card_data));
d = o->userdata;
d->idx = idx;
@@ -1668,8 +1619,6 @@ pa_operation* pa_context_get_card_info_by_name(pa_context *c, const char *name,
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
pw_log_debug("context %p: %s", c, name);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, card_info, sizeof(struct card_data));
d = o->userdata;
d->name = pa_xstrdup(name);
@@ -1707,8 +1656,6 @@ pa_operation* pa_context_get_card_info_list(pa_context *c, pa_card_info_cb_t cb,
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
pw_log_debug("context %p", c);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, card_info_list, sizeof(struct card_data));
d = o->userdata;
d->cb = cb;
@@ -1794,8 +1741,6 @@ pa_operation* pa_context_set_card_profile_by_index(pa_context *c, uint32_t idx,
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
pw_log_debug("Card set profile %s", profile);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, card_profile, sizeof(struct card_data));
d = o->userdata;
d->idx = idx;
@@ -1820,8 +1765,6 @@ pa_operation* pa_context_set_card_profile_by_name(pa_context *c, const char*name
PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
pw_log_debug("Card set profile %s", profile);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, card_profile, sizeof(struct card_data));
d = o->userdata;
d->name = pa_xstrdup(name);
@@ -1988,8 +1931,6 @@ pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sin
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
pw_log_debug("context %p: info for %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, sink_input_info, sizeof(struct sink_input_data));
d = o->userdata;
d->idx = idx;
@@ -2028,8 +1969,6 @@ pa_operation* pa_context_get_sink_input_info_list(pa_context *c, pa_sink_input_i
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
pw_log_debug("context %p", c);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, sink_input_info_list, sizeof(struct sink_input_data));
d = o->userdata;
d->cb = cb;
@@ -2100,8 +2039,6 @@ pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, co
pa_operation *o;
struct target_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_target_node, sizeof(struct target_node));
d = o->userdata;
d->idx = idx;
@@ -2122,8 +2059,6 @@ pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, u
pa_operation *o;
struct target_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_target_node, sizeof(struct target_node));
d = o->userdata;
d->idx = idx;
@@ -2187,8 +2122,6 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons
struct stream_volume *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_stream_volume_mute, sizeof(struct stream_volume));
d = o->userdata;
d->idx = idx;
@@ -2209,8 +2142,6 @@ pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mu
struct stream_volume *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_stream_volume_mute, sizeof(struct stream_volume));
d = o->userdata;
d->idx = idx;
@@ -2264,8 +2195,6 @@ pa_operation* pa_context_kill_sink_input(pa_context *c, uint32_t idx, pa_context
struct kill_stream *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_kill_stream, sizeof(struct kill_stream));
d = o->userdata;
d->idx = idx;
@@ -2402,8 +2331,6 @@ pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_
PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, source_output_info, sizeof(struct source_output_data));
d = o->userdata;
d->idx = idx;
@@ -2441,8 +2368,6 @@ pa_operation* pa_context_get_source_output_info_list(pa_context *c, pa_source_ou
PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, source_output_info_list, sizeof(struct source_output_data));
d = o->userdata;
d->cb = cb;
@@ -2458,8 +2383,6 @@ pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx,
pa_operation *o;
struct target_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_target_node, sizeof(struct target_node));
d = o->userdata;
d->idx = idx;
@@ -2480,8 +2403,6 @@ pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx
pa_operation *o;
struct target_node *d;
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_target_node, sizeof(struct target_node));
d = o->userdata;
d->idx = idx;
@@ -2503,8 +2424,6 @@ pa_operation* pa_context_set_source_output_volume(pa_context *c, uint32_t idx, c
struct stream_volume *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_stream_volume_mute, sizeof(struct stream_volume));
d = o->userdata;
d->idx = idx;
@@ -2525,8 +2444,6 @@ pa_operation* pa_context_set_source_output_mute(pa_context *c, uint32_t idx, int
struct stream_volume *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_stream_volume_mute, sizeof(struct stream_volume));
d = o->userdata;
d->idx = idx;
@@ -2546,8 +2463,6 @@ pa_operation* pa_context_kill_source_output(pa_context *c, uint32_t idx, pa_cont
struct kill_stream *d;
pw_log_debug("contex %p: index %d", c, idx);
- pa_context_ensure_registry(c);
-
o = pa_operation_new(c, NULL, do_kill_stream, sizeof(struct kill_stream));
d = o->userdata;
d->idx = idx;