mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
improve update_properties
Make _update_properties return the number of changed properties and only emit info when something changed.
This commit is contained in:
parent
d5c894cfd8
commit
1f5fec5983
4 changed files with 36 additions and 26 deletions
|
|
@ -196,7 +196,7 @@ struct pw_client *pw_client_new(struct pw_core *core,
|
||||||
|
|
||||||
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
|
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
|
||||||
|
|
||||||
this->info.props = this->properties ? &this->properties->dict : NULL;
|
this->info.props = &this->properties->dict;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +323,6 @@ void pw_client_destroy(struct pw_client *client)
|
||||||
pw_map_clear(&client->types);
|
pw_map_clear(&client->types);
|
||||||
pw_array_clear(&impl->permissions);
|
pw_array_clear(&impl->permissions);
|
||||||
|
|
||||||
if (client->properties)
|
|
||||||
pw_properties_free(client->properties);
|
pw_properties_free(client->properties);
|
||||||
|
|
||||||
free(impl);
|
free(impl);
|
||||||
|
|
@ -356,21 +355,19 @@ const struct pw_client_info *pw_client_get_info(struct pw_client *client)
|
||||||
int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
|
int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
uint32_t i, changed = 0;
|
||||||
if (client->properties == NULL) {
|
|
||||||
if (dict)
|
|
||||||
client->properties = pw_properties_new_dict(dict);
|
|
||||||
} else {
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < dict->n_items; i++)
|
for (i = 0; i < dict->n_items; i++)
|
||||||
pw_properties_set(client->properties,
|
changed += pw_properties_set(client->properties,
|
||||||
dict->items[i].key, dict->items[i].value);
|
dict->items[i].key, dict->items[i].value);
|
||||||
}
|
|
||||||
|
pw_log_debug("client %p: updated %d properties", client, changed);
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
client->info.change_mask |= PW_CLIENT_CHANGE_MASK_PROPS;
|
client->info.change_mask |= PW_CLIENT_CHANGE_MASK_PROPS;
|
||||||
client->info.props = client->properties ? &client->properties->dict : NULL;
|
client->info.props = &client->properties->dict;
|
||||||
|
|
||||||
pw_client_events_info_changed(client, &client->info);
|
pw_client_events_info_changed(client, &client->info);
|
||||||
|
|
||||||
spa_list_for_each(resource, &client->resource_list, link)
|
spa_list_for_each(resource, &client->resource_list, link)
|
||||||
|
|
@ -378,7 +375,7 @@ int pw_client_update_properties(struct pw_client *client, const struct spa_dict
|
||||||
|
|
||||||
client->info.change_mask = 0;
|
client->info.change_mask = 0;
|
||||||
|
|
||||||
return 0;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct permissions_update {
|
struct permissions_update {
|
||||||
|
|
|
||||||
|
|
@ -557,10 +557,15 @@ const struct pw_properties *pw_core_get_properties(struct pw_core *core)
|
||||||
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
uint32_t i;
|
uint32_t i, changed = 0;
|
||||||
|
|
||||||
for (i = 0; i < dict->n_items; i++)
|
for (i = 0; i < dict->n_items; i++)
|
||||||
pw_properties_set(core->properties, dict->items[i].key, dict->items[i].value);
|
changed += pw_properties_set(core->properties, dict->items[i].key, dict->items[i].value);
|
||||||
|
|
||||||
|
pw_log_debug("core %p: updated %d properties", core, changed);
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
core->info.change_mask = PW_CORE_CHANGE_MASK_PROPS;
|
core->info.change_mask = PW_CORE_CHANGE_MASK_PROPS;
|
||||||
core->info.props = &core->properties->dict;
|
core->info.props = &core->properties->dict;
|
||||||
|
|
@ -572,7 +577,7 @@ int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
||||||
|
|
||||||
core->info.change_mask = 0;
|
core->info.change_mask = 0;
|
||||||
|
|
||||||
return 0;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pw_core_for_each_global(struct pw_core *core,
|
int pw_core_for_each_global(struct pw_core *core,
|
||||||
|
|
|
||||||
|
|
@ -477,15 +477,19 @@ const struct pw_properties *pw_node_get_properties(struct pw_node *node)
|
||||||
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
|
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
uint32_t i;
|
uint32_t i, changed = 0;
|
||||||
|
|
||||||
for (i = 0; i < dict->n_items; i++)
|
for (i = 0; i < dict->n_items; i++)
|
||||||
pw_properties_set(node->properties, dict->items[i].key, dict->items[i].value);
|
changed += pw_properties_set(node->properties, dict->items[i].key, dict->items[i].value);
|
||||||
|
|
||||||
|
pw_log_debug("node %p: updated %d properties", node, changed);
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
check_properties(node);
|
check_properties(node);
|
||||||
|
|
||||||
node->info.props = &node->properties->dict;
|
node->info.props = &node->properties->dict;
|
||||||
|
|
||||||
node->info.change_mask |= PW_NODE_CHANGE_MASK_PROPS;
|
node->info.change_mask |= PW_NODE_CHANGE_MASK_PROPS;
|
||||||
pw_node_events_info_changed(node, &node->info);
|
pw_node_events_info_changed(node, &node->info);
|
||||||
|
|
||||||
|
|
@ -494,7 +498,7 @@ int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
|
||||||
|
|
||||||
node->info.change_mask = 0;
|
node->info.change_mask = 0;
|
||||||
|
|
||||||
return 0;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_done(void *data, int seq, int res)
|
static void node_done(void *data, int seq, int res)
|
||||||
|
|
|
||||||
|
|
@ -247,13 +247,17 @@ const struct pw_properties *pw_port_get_properties(struct pw_port *port)
|
||||||
int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
|
int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
uint32_t i;
|
uint32_t i, changed = 0;
|
||||||
|
|
||||||
for (i = 0; i < dict->n_items; i++)
|
for (i = 0; i < dict->n_items; i++)
|
||||||
pw_properties_set(port->properties, dict->items[i].key, dict->items[i].value);
|
changed += pw_properties_set(port->properties, dict->items[i].key, dict->items[i].value);
|
||||||
|
|
||||||
|
pw_log_debug("port %p: updated %d properties", port, changed);
|
||||||
|
|
||||||
|
if (!changed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
port->info.props = &port->properties->dict;
|
port->info.props = &port->properties->dict;
|
||||||
|
|
||||||
port->info.change_mask |= PW_PORT_CHANGE_MASK_PROPS;
|
port->info.change_mask |= PW_PORT_CHANGE_MASK_PROPS;
|
||||||
pw_port_events_info_changed(port, &port->info);
|
pw_port_events_info_changed(port, &port->info);
|
||||||
|
|
||||||
|
|
@ -262,7 +266,7 @@ int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
|
||||||
|
|
||||||
port->info.change_mask = 0;
|
port->info.change_mask = 0;
|
||||||
|
|
||||||
return 0;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pw_node *pw_port_get_node(struct pw_port *port)
|
struct pw_node *pw_port_get_node(struct pw_port *port)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue