mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
pulse-server: optimize property allocations
Only allocate a new properties object when we actually need to change something.
This commit is contained in:
parent
a31989b46d
commit
8b649c4510
1 changed files with 20 additions and 14 deletions
|
|
@ -3689,15 +3689,17 @@ static int fill_sink_info_proplist(struct message *m, const struct spa_dict *sin
|
||||||
const struct pw_manager_object *card)
|
const struct pw_manager_object *card)
|
||||||
{
|
{
|
||||||
struct pw_device_info *card_info = card ? card->info : NULL;
|
struct pw_device_info *card_info = card ? card->info : NULL;
|
||||||
|
struct pw_properties *props = NULL;
|
||||||
|
|
||||||
struct pw_properties *props = pw_properties_new_dict(sink_props);
|
if (card_info && card_info->props) {
|
||||||
|
props = pw_properties_new_dict(sink_props);
|
||||||
if (props == NULL)
|
if (props == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (card_info && card_info->props)
|
|
||||||
pw_properties_add(props, card_info->props);
|
pw_properties_add(props, card_info->props);
|
||||||
|
sink_props = &props->dict;
|
||||||
message_put(m, TAG_PROPLIST, &props->dict, TAG_INVALID);
|
}
|
||||||
|
message_put(m, TAG_PROPLIST, sink_props, TAG_INVALID);
|
||||||
|
|
||||||
pw_properties_free(props);
|
pw_properties_free(props);
|
||||||
|
|
||||||
|
|
@ -3892,8 +3894,10 @@ static int fill_source_info_proplist(struct message *m, const struct spa_dict *s
|
||||||
const struct pw_manager_object *card, const bool is_monitor)
|
const struct pw_manager_object *card, const bool is_monitor)
|
||||||
{
|
{
|
||||||
struct pw_device_info *card_info = card ? card->info : NULL;
|
struct pw_device_info *card_info = card ? card->info : NULL;
|
||||||
|
struct pw_properties *props = NULL;
|
||||||
|
|
||||||
struct pw_properties *props = pw_properties_new_dict(source_props);
|
if ((card_info && card_info->props) || is_monitor) {
|
||||||
|
props = pw_properties_new_dict(source_props);
|
||||||
if (props == NULL)
|
if (props == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
@ -3903,7 +3907,9 @@ static int fill_source_info_proplist(struct message *m, const struct spa_dict *s
|
||||||
if (is_monitor)
|
if (is_monitor)
|
||||||
pw_properties_set(props, PW_KEY_DEVICE_CLASS, "monitor");
|
pw_properties_set(props, PW_KEY_DEVICE_CLASS, "monitor");
|
||||||
|
|
||||||
message_put(m, TAG_PROPLIST, &props->dict, TAG_INVALID);
|
source_props = &props->dict;
|
||||||
|
}
|
||||||
|
message_put(m, TAG_PROPLIST, source_props, TAG_INVALID);
|
||||||
|
|
||||||
pw_properties_free(props);
|
pw_properties_free(props);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue