slimserver icon indicating copy to clipboard operation
slimserver copied to clipboard

How to fix broken volume management

Open philippe44 opened this issue 3 years ago • 0 comments

I was looking again at volume management as I had some issues with my plugins and I'm not sure what to do: the new issues I faced with volume is that when an un-mute happens and while volume is (slowly) ramping up, if the user (or a CLI) set a new value, then we end up setting a negative volume and muting again on the UI, although the volume command sent to the player is correct.

There is no good (or easy) fix to that as IMHO, the volume itself is broken. There are two ways to represent a muted device: a negative value and a "mute" prefs. As usual, when values represent the same entity, they get de-sync and crap happens. For example, the volume() sub of SqueezeBox2.pm sets gain to 0 for negative volume command but the "mute" boolean is not set and the mute() sub will set a negative value if volume is >0 but "mute" is not set.

The logic would be to get rid of the negative volume and use the mute boolean, but that means a potential loss of compatibility with plugins that might look at client's volume and rely on a negative value for mute.

Keeping the current situation and even if I can fix the "ramp-up interruption case" 'which is not obvious) means more spaghetti code as there will be other cases where this dual representation will bite.

Sigh...

philippe44 avatar Dec 27 '22 16:12 philippe44