diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 01a5af475..f14921486 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -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); + 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) res = set_card_volume_mute(card, dev_info.active_port, 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) return res; +done: 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); + if (dev_info.have_volume && + dev_info.volume_info.mute == mute) + goto done; + if (card != NULL && dev_info.active_port != SPA_ID_INVALID) res = set_card_volume_mute(card, dev_info.active_port, 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) return res; - +done: return reply_simple_ack(client, tag); } diff --git a/src/modules/module-protocol-pulse/volume.c b/src/modules/module-protocol-pulse/volume.c index 020b63220..cb72f780d 100644 --- a/src/modules/module-protocol-pulse/volume.c +++ b/src/modules/module-protocol-pulse/volume.c @@ -46,6 +46,22 @@ static inline void volume_make(struct volume *vol, uint8_t 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 volume; struct channel_map map;