mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: try to avoid setting the same volume/mute
This commit is contained in:
parent
c3c6dcf53f
commit
c140a573be
2 changed files with 26 additions and 1 deletions
|
|
@ -2998,6 +2998,10 @@ static int do_set_volume(struct client *client, uint32_t command, uint32_t tag,
|
||||||
}
|
}
|
||||||
collect_device_info(o, card, &dev_info);
|
collect_device_info(o, card, &dev_info);
|
||||||
|
|
||||||
|
if (dev_info.have_volume &&
|
||||||
|
volume_compare(&dev_info.volume_info.volume, &volume) == 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
if (card != NULL && dev_info.active_port != SPA_ID_INVALID)
|
if (card != NULL && dev_info.active_port != SPA_ID_INVALID)
|
||||||
res = set_card_volume_mute(card, dev_info.active_port,
|
res = set_card_volume_mute(card, dev_info.active_port,
|
||||||
dev_info.device, &volume, NULL);
|
dev_info.device, &volume, NULL);
|
||||||
|
|
@ -3007,6 +3011,7 @@ static int do_set_volume(struct client *client, uint32_t command, uint32_t tag,
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
done:
|
||||||
return reply_simple_ack(client, tag);
|
return reply_simple_ack(client, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3058,6 +3063,10 @@ static int do_set_mute(struct client *client, uint32_t command, uint32_t tag, st
|
||||||
}
|
}
|
||||||
collect_device_info(o, card, &dev_info);
|
collect_device_info(o, card, &dev_info);
|
||||||
|
|
||||||
|
if (dev_info.have_volume &&
|
||||||
|
dev_info.volume_info.mute == mute)
|
||||||
|
goto done;
|
||||||
|
|
||||||
if (card != NULL && dev_info.active_port != SPA_ID_INVALID)
|
if (card != NULL && dev_info.active_port != SPA_ID_INVALID)
|
||||||
res = set_card_volume_mute(card, dev_info.active_port,
|
res = set_card_volume_mute(card, dev_info.active_port,
|
||||||
dev_info.device, NULL, &mute);
|
dev_info.device, NULL, &mute);
|
||||||
|
|
@ -3066,7 +3075,7 @@ static int do_set_mute(struct client *client, uint32_t command, uint32_t tag, st
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
|
done:
|
||||||
return reply_simple_ack(client, tag);
|
return reply_simple_ack(client, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,22 @@ static inline void volume_make(struct volume *vol, uint8_t channels)
|
||||||
vol->channels = channels;
|
vol->channels = channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int volume_compare(struct volume *vol, struct volume *other)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
if (vol->channels != other->channels) {
|
||||||
|
pw_log_info("channels %d<>%d", vol->channels, other->channels);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < vol->channels; i++) {
|
||||||
|
if (vol->values[i] != other->values[i]) {
|
||||||
|
pw_log_info("val %f<>%f", vol->values[i], other->values[i]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct volume_info {
|
struct volume_info {
|
||||||
struct volume volume;
|
struct volume volume;
|
||||||
struct channel_map map;
|
struct channel_map map;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue