Make volume changes to apply to disabled software mixers.

Move audio output state check ahead of mixer check and force volume
applying even for disabled software mixed outputs.

This fixes incorrect software mixer volume that used to occur when
volume was changed while output being disabled.

This is easily reproduced with following sequence of commands on
multi-output software mixed MPD setup.

 mpc volume 38; mpc disable 3; mpc volume 88; mpc enable 3

On current MPD, following commands would result in output 3 playing at
volume 38, while all other enabled outputs would play at volume
88. Moreover, global volume would display average of outputs real
volumes. In my case, it's 75.

After applying this patch, following commands would produce expected
behavior. All outputs play at expected (88) volume. And volume is
correctly displayed as 88.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1423

Signed-off-by: Vitaly Ostrosablin tmp6154@yandex.ru


Signed-off-by: Vitaly Ostrosablin <tmp6154@yandex.ru>
This commit is contained in:
Vitaly Ostrosablin 2022-03-19 13:34:12 +03:00 committed by Max Kellermann
parent a757eebfbb
commit ac06088948
2 changed files with 12 additions and 6 deletions

2
NEWS
View File

@ -1,6 +1,8 @@
ver 0.23.7 (not yet released)
* decoder
- opus: fix missing song length on high-latency files
* mixer
- software: update volume of disabled outputs
ver 0.23.6 (2022/03/14)
* protocol

View File

@ -34,13 +34,15 @@ gcc_pure
static int
output_mixer_get_volume(const AudioOutputControl &ao) noexcept
{
if (!ao.IsEnabled())
return -1;
auto *mixer = ao.GetMixer();
if (mixer == nullptr)
return -1;
/* software mixers are always considered, even if they are
disabled */
if (!ao.IsEnabled() && !mixer->IsPlugin(software_mixer_plugin))
return -1;
try {
return mixer_get_volume(mixer);
} catch (...) {
@ -76,13 +78,15 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) noexcept
{
assert(volume <= 100);
if (!ao.IsEnabled())
return false;
auto *mixer = ao.GetMixer();
if (mixer == nullptr)
return false;
/* software mixers are always updated, even if they are
disabled */
if (!ao.IsEnabled() && !mixer->IsPlugin(software_mixer_plugin))
return false;
try {
mixer_set_volume(mixer, volume);
return true;