pulse-server: Surface volume control flags as properties

We could udpate the libpulse protocol to add more flag types, but this
seems simpler than requiring a protocol and ABI update.
This commit is contained in:
Arun Raghavan 2026-03-04 18:52:06 -08:00
parent e863e71f6b
commit 3ef6618ce2
3 changed files with 55 additions and 2 deletions

View file

@ -3692,7 +3692,7 @@ static int fill_card_info(struct client *client, struct message *m,
}
static int fill_sink_info_proplist(struct message *m, const struct spa_dict *sink_props,
const struct pw_manager_object *card)
const struct device_info *dev_info, const struct pw_manager_object *card)
{
struct pw_device_info *card_info = card ? card->info : NULL;
spa_autoptr(pw_properties) props = NULL;
@ -3706,6 +3706,26 @@ static int fill_sink_info_proplist(struct message *m, const struct spa_dict *sin
sink_props = &props->dict;
}
if (dev_info->volume_info.flags & VOLUME_CONTROL_MASK) {
props = pw_properties_new_dict(sink_props);
if (props == NULL)
return -ENOMEM;
#define SET_PROP(k, f) pw_properties_set(props, k, dev_info->volume_info.flags & (f) ? "true" : "false")
SET_PROP("device.volume.read-volume", VOLUME_READ);
SET_PROP("device.volume.write-volume-value", VOLUME_WRITE);
SET_PROP("device.volume.write-volume-updown", VOLUME_UPDOWN);
SET_PROP("device.volume.read-mute", VOLUME_READ_MUTE);
SET_PROP("device.volume.write-mute-value", VOLUME_WRITE_MUTE);
SET_PROP("device.volume.write-mute-toggle", VOLUME_TOGGLE_MUTE);
SET_PROP("device.volume.read-balance", VOLUME_READ_BALANCE);
SET_PROP("device.volume.write-balance", VOLUME_WRITE_BALANCE);
pw_properties_add(props, card_info->props);
sink_props = &props->dict;
}
message_put(m, TAG_PROPLIST, sink_props, TAG_INVALID);
return 0;
@ -3804,7 +3824,7 @@ static int fill_sink_info(struct client *client, struct message *m,
if (client->version >= 13) {
int res;
if ((res = fill_sink_info_proplist(m, info->props, card)) < 0)
if ((res = fill_sink_info_proplist(m, info->props, &dev_info, card)) < 0)
return res;
message_put(m,
TAG_USEC, 0LL, /* requested latency */