mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-21 08:56:56 -05:00
pulse-server: skip objects being created
Skip iterating over objects that still have pending updates. Make sure we have all info and properties before we process objects. Fixes #376
This commit is contained in:
parent
041d1a142d
commit
22cec7823e
4 changed files with 24 additions and 26 deletions
|
|
@ -129,6 +129,8 @@ static struct pw_manager_object *select_object(struct pw_manager *m,
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
spa_list_for_each(o, &m->object_list, link) {
|
spa_list_for_each(o, &m->object_list, link) {
|
||||||
|
if (o->creating)
|
||||||
|
continue;
|
||||||
if (s->type != NULL && !s->type(o))
|
if (s->type != NULL && !s->type(o))
|
||||||
continue;
|
continue;
|
||||||
if (o->id == s->id)
|
if (o->id == s->id)
|
||||||
|
|
@ -150,6 +152,8 @@ static struct pw_manager_object *find_linked(struct pw_manager *m, uint32_t obj_
|
||||||
uint32_t in_node, out_node;
|
uint32_t in_node, out_node;
|
||||||
|
|
||||||
spa_list_for_each(o, &m->object_list, link) {
|
spa_list_for_each(o, &m->object_list, link) {
|
||||||
|
if (o->creating)
|
||||||
|
continue;
|
||||||
if (o->props == NULL || !is_link(o))
|
if (o->props == NULL || !is_link(o))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,6 @@ struct object {
|
||||||
|
|
||||||
struct spa_hook proxy_listener;
|
struct spa_hook proxy_listener;
|
||||||
struct spa_hook object_listener;
|
struct spa_hook object_listener;
|
||||||
|
|
||||||
unsigned int new:1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void core_sync(struct manager *m)
|
static void core_sync(struct manager *m)
|
||||||
|
|
@ -116,6 +114,8 @@ static struct object *find_object(struct manager *m, uint32_t id)
|
||||||
{
|
{
|
||||||
struct object *o;
|
struct object *o;
|
||||||
spa_list_for_each(o, &m->this.object_list, this.link) {
|
spa_list_for_each(o, &m->this.object_list, this.link) {
|
||||||
|
if (o->this.creating)
|
||||||
|
continue;
|
||||||
if (o->this.id == id)
|
if (o->this.id == id)
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
@ -470,7 +470,7 @@ static void registry_event_global(void *data, uint32_t id,
|
||||||
o->this.version = version;
|
o->this.version = version;
|
||||||
o->this.props = props ? pw_properties_new_dict(props) : NULL;
|
o->this.props = props ? pw_properties_new_dict(props) : NULL;
|
||||||
o->this.proxy = proxy;
|
o->this.proxy = proxy;
|
||||||
o->new = true;
|
o->this.creating = true;
|
||||||
spa_list_init(&o->this.param_list);
|
spa_list_init(&o->this.param_list);
|
||||||
|
|
||||||
o->manager = m;
|
o->manager = m;
|
||||||
|
|
@ -527,8 +527,8 @@ static void on_core_done(void *data, uint32_t id, int seq)
|
||||||
manager_emit_sync(m);
|
manager_emit_sync(m);
|
||||||
|
|
||||||
spa_list_for_each(o, &m->this.object_list, this.link) {
|
spa_list_for_each(o, &m->this.object_list, this.link) {
|
||||||
if (o->new) {
|
if (o->this.creating) {
|
||||||
o->new = false;
|
o->this.creating = false;
|
||||||
manager_emit_added(m, &o->this);
|
manager_emit_added(m, &o->this);
|
||||||
} else if (o->this.changed > 0) {
|
} else if (o->this.changed > 0) {
|
||||||
manager_emit_updated(m, &o->this);
|
manager_emit_updated(m, &o->this);
|
||||||
|
|
@ -620,6 +620,8 @@ int pw_manager_for_each_object(struct pw_manager *manager,
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
spa_list_for_each(o, &m->this.object_list, this.link) {
|
spa_list_for_each(o, &m->this.object_list, this.link) {
|
||||||
|
if (o->this.creating)
|
||||||
|
continue;
|
||||||
if ((res = callback(data, &o->this)) != 0)
|
if ((res = callback(data, &o->this)) != 0)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ struct pw_manager_object {
|
||||||
int changed;
|
int changed;
|
||||||
void *info;
|
void *info;
|
||||||
struct spa_list param_list;
|
struct spa_list param_list;
|
||||||
|
unsigned int creating:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pw_manager *pw_manager_new(struct pw_core *core);
|
struct pw_manager *pw_manager_new(struct pw_core *core);
|
||||||
|
|
|
||||||
|
|
@ -2339,10 +2339,7 @@ static int do_set_volume(struct client *client, uint32_t command, uint32_t tag,
|
||||||
direction = PW_DIRECTION_INPUT;
|
direction = PW_DIRECTION_INPUT;
|
||||||
|
|
||||||
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
||||||
if (o == NULL || o->info == NULL)
|
if (o == NULL || (info = o->info) == NULL || info->props == NULL)
|
||||||
return -ENOENT;
|
|
||||||
info = o->info;
|
|
||||||
if (info == NULL)
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
dev_info = DEVICE_INFO_INIT(direction);
|
dev_info = DEVICE_INFO_INIT(direction);
|
||||||
|
|
@ -2401,10 +2398,7 @@ static int do_set_mute(struct client *client, uint32_t command, uint32_t tag, st
|
||||||
direction = PW_DIRECTION_INPUT;
|
direction = PW_DIRECTION_INPUT;
|
||||||
|
|
||||||
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
||||||
if (o == NULL || o->info == NULL)
|
if (o == NULL || (info = o->info) == NULL || info->props == NULL)
|
||||||
return -ENOENT;
|
|
||||||
info = o->info;
|
|
||||||
if (info == NULL)
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
dev_info = DEVICE_INFO_INIT(direction);
|
dev_info = DEVICE_INFO_INIT(direction);
|
||||||
|
|
@ -2463,10 +2457,7 @@ static int do_set_port(struct client *client, uint32_t command, uint32_t tag, st
|
||||||
direction = PW_DIRECTION_INPUT;
|
direction = PW_DIRECTION_INPUT;
|
||||||
|
|
||||||
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
o = find_device(client, id, name, direction == PW_DIRECTION_OUTPUT);
|
||||||
if (o == NULL || o->info == NULL)
|
if (o == NULL || (info = o->info) == NULL || info->props == NULL)
|
||||||
return -ENOENT;
|
|
||||||
info = o->info;
|
|
||||||
if (info == NULL)
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_ID)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_ID)) != NULL)
|
||||||
|
|
@ -2660,7 +2651,7 @@ static int do_get_server_info(struct client *client, uint32_t command, uint32_t
|
||||||
ss = SAMPLE_SPEC_INIT;
|
ss = SAMPLE_SPEC_INIT;
|
||||||
map = CHANNEL_MAP_INIT;
|
map = CHANNEL_MAP_INIT;
|
||||||
|
|
||||||
if (manager->info != NULL) {
|
if (info != NULL) {
|
||||||
if (info->props &&
|
if (info->props &&
|
||||||
(str = spa_dict_lookup(info->props, "default.clock.rate")) != NULL)
|
(str = spa_dict_lookup(info->props, "default.clock.rate")) != NULL)
|
||||||
ss.rate = atoi(str);
|
ss.rate = atoi(str);
|
||||||
|
|
@ -2768,7 +2759,7 @@ static int fill_client_info(struct client *client, struct message *m,
|
||||||
const char *str;
|
const char *str;
|
||||||
uint32_t module_id = SPA_ID_INVALID;
|
uint32_t module_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
if (o == NULL || !is_client(o))
|
if (info == NULL || info->props == NULL || !is_client(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||||
|
|
@ -2782,7 +2773,7 @@ static int fill_client_info(struct client *client, struct message *m,
|
||||||
TAG_INVALID);
|
TAG_INVALID);
|
||||||
if (client->version >= 13) {
|
if (client->version >= 13) {
|
||||||
message_put(m,
|
message_put(m,
|
||||||
TAG_PROPLIST, info ? info->props : NULL,
|
TAG_PROPLIST, info->props,
|
||||||
TAG_INVALID);
|
TAG_INVALID);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -2793,7 +2784,7 @@ static int fill_module_info(struct client *client, struct message *m,
|
||||||
{
|
{
|
||||||
struct pw_module_info *info = o->info;
|
struct pw_module_info *info = o->info;
|
||||||
|
|
||||||
if (o == NULL || info == NULL || !is_module(o))
|
if (info == NULL || info->props == NULL || !is_module(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
message_put(m,
|
message_put(m,
|
||||||
|
|
@ -2825,7 +2816,7 @@ static int fill_card_info(struct client *client, struct message *m,
|
||||||
struct card_info card_info = CARD_INFO_INIT;
|
struct card_info card_info = CARD_INFO_INIT;
|
||||||
struct profile_info *profile_info;
|
struct profile_info *profile_info;
|
||||||
|
|
||||||
if (o == NULL || info == NULL || info->props == NULL || !is_card(o))
|
if (info == NULL || info->props == NULL || !is_card(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||||
|
|
@ -2944,7 +2935,7 @@ static int fill_sink_info(struct client *client, struct message *m,
|
||||||
struct card_info card_info = CARD_INFO_INIT;
|
struct card_info card_info = CARD_INFO_INIT;
|
||||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
||||||
|
|
||||||
if (o == NULL || info == NULL || info->props == NULL || !is_sink(o))
|
if (info == NULL || info->props == NULL || !is_sink(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((name = spa_dict_lookup(info->props, PW_KEY_NODE_NAME)) != NULL) {
|
if ((name = spa_dict_lookup(info->props, PW_KEY_NODE_NAME)) != NULL) {
|
||||||
|
|
@ -3067,7 +3058,7 @@ static int fill_source_info(struct client *client, struct message *m,
|
||||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
||||||
|
|
||||||
is_monitor = is_sink(o);
|
is_monitor = is_sink(o);
|
||||||
if (o == NULL || info == NULL || info->props == NULL ||
|
if (info == NULL || info->props == NULL ||
|
||||||
(!is_source(o) && !is_monitor))
|
(!is_source(o) && !is_monitor))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
|
|
@ -3190,7 +3181,7 @@ static int fill_sink_input_info(struct client *client, struct message *m,
|
||||||
uint32_t module_id = SPA_ID_INVALID, client_id = SPA_ID_INVALID;
|
uint32_t module_id = SPA_ID_INVALID, client_id = SPA_ID_INVALID;
|
||||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
||||||
|
|
||||||
if (o == NULL || info == NULL || info->props == NULL || !is_sink_input(o))
|
if (info == NULL || info->props == NULL || !is_sink_input(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||||
|
|
@ -3255,7 +3246,7 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
||||||
uint32_t peer_id;
|
uint32_t peer_id;
|
||||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
||||||
|
|
||||||
if (o == NULL || info == NULL || info->props == NULL || !is_source_output(o))
|
if (info == NULL || info->props == NULL || !is_source_output(o))
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue