[pulseaudio-discuss] [PATCH 4/4] alsa-mixer: Attempt to detect and then drop redundant paths in the path set.

David Henningsson david.henningsson at canonical.com
Mon Jul 4 02:40:57 PDT 2011

On 2011-07-04 10:45, Colin Guthrie wrote:
> 'Twas brillig, and David Henningsson at 04/07/11 08:19 did gyre and gimble:
>> On 2011-07-03 14:48, Colin Guthrie wrote:
>>> So really the path to be nuked should also have a volume_use of OFF, and
>>> all it's other volume_uses should be OFF too...
>>> Should there be anything else checked? The other variations are the
>>> "required" flag, the mask and the override_map. Are these relevant for
>>> the working out which one to nuke?
>> I think we have different ideas to how this should be solved in the
>> first place: Your idea is to check for equality and if so drop the one
>> with least priority, my idea is to check for subset and if so drop the
>> one that is the subset of another (and ignore priority).
> Well that was my original thought, but that's just because it was sunny
> outside and this was the last bit of the puzzle and I didn't really
> think about it much :D
>> Given some thought, I believe the "subset" idea would solve this case as
>> well, if you consider "off" and "zero" being subsets of "merge". (And
>> that makes sense, really: if an element is "merge", you can set it to
>> both "off" and "zero" by moving the slider to the corresponding place.)
> Right, that seems OK for volume_use, but what about the others? Do we
> just state that any enumerations we encounter have to be equal for our
> "subset off" comparison to succeed? I guess the same for switches?
> Obviously if any volume, switch or enumeration is IGNORE, then we don't
> check further for that element type.

Hopefully this won't sound too abstract or academic, but here we go:

We have two paths A and B, and want to determine if A is a subset of B. 
Put in another way, A is a subset of B if and only if you for every 
state you can put ALSA in with the help of A, you can also put ALSA in 
that state with the help of B.

So the rules would then be:

Every state is a subset of itself.
"Ignore" is subset of every other state.

"Constant" is a subset of "Merge", if there is not a "volume-limit" in 
"Merge" below the actual constant.
"Merge" with a "volume-limit" is a subset of "Merge" without a 
"volume-limit" or with a higher "volume-limit".
"Zero" and "Off" are just special cases of "Constant".

"On" is a subset of "Mute".
"Off" is a subset of "Mute".
"On" is a subset of "Select", if there is an "Option:On" in B.
"Off" is a subset of "Select", if there is an "Option:Off" in B.

Here you have to go through all the options. If there is an option A 
offers that B does not, then A is not a subset of B.

> I'm just trying to get it straight in my head as I'm not super familiar
> with all the numerous and varying alsa kcontrol stuff as you, so being
> able to get a clear understanding of the rules will allow me to actually
> implement the algorithm!

Hopefully the above makes sense.

It feels a little over-engineered, and might be sunny outside today as 
well, but otherwise I think it'll work :-)

David Henningsson, Canonical Ltd.

More information about the pulseaudio-discuss mailing list