Each audio concurrency management context defined in your system has an associated mixer device created under an audio management card. The mixer device for your audio concurrency management context contains mixer groups for each audio type defined in the context’s audio policy configuration file. You can use the standard snd_mixer_group_*() APIs to read and write volume and mute settings of these mixer groups, which allows for synchronous adjustments of the volume and mute levels of all audio streams of the specified audio type.
If you have two multimedia subchannels running, adjusting the volume level of the multimedia mixer group synchronously affects the volume levels of both multimedia subchannels.
Audio type volume controls are in series with their respective subchannels volume controls, so the levels of both volume controls are factored together to determine the overall user volume level applied to a given audio stream. For example if the volume level for an audio type is set to 50% and the individual subchannel’s volume level is set to 25%, the overall volume level of the audio stream would be 12%.
It's important to note that the ducking level applied to a subchannel is scaled by the overall volume level of the ducking subchannel. For example, if the user used the audio type volume controls to reduce the overall volume level of the ducking subchannel by 50% and the configured ducking level was 50%, the final ducking level applied to the ducked subchannels would be 25%.
To illustrate how the various volume levels (subchannel, audio type, and audio ducking) work together, you can use the mix_ctl utility as shown below and cat the state of the card. In this example, there are two audio streams of audio type default and multimedia running with the user volume controls (Subchn and AudioType) configured to full volume (100%). The multimedia audio type is ducking the default audio type to 50%, so if you use the cat command to see the output, you see that the subchannel of default audio type has its Ducking and Current volume level at 50%, while the multimedia subchannel is at 100%.
# cat /dev/snd/stateC1 McASP @ 0x48468000, McASP pcmC1D0p ocb = 0x10141c38 - subchn = 0x1014ed30 pid = 1773597 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=default Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 100% 100% 100% 50% 50% Channel 0 100% 100% 100% 50% 50% ocb = 0x10150528 - subchn = 0x1014eb78 pid = 380962 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=multimedia Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 100% 100% 100% 100% 100% Channel 0 100% 100% 100% 100% 100%
Now, if you configure the multimedia volume level to 50%, you'll see the AudioType, Control and Current values of the multimedia subchannel go to 50% and the Ducking and Current values of the default subchannel scaled down to 25%.
# mix_ctl -a0:0 group "multimedia" volume=50% # cat /dev/snd/stateC1 McASP @ 0x48468000, McASP pcmC1D0p ocb = 0x10141c38 - subchn = 0x1014ed30 pid = 1773597 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=default Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 100% 100% 100% 25% 25% Channel 0 100% 100% 100% 25% 25% ocb = 0x10150528 - subchn = 0x1014eb78 pid = 380962 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=multimedia Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 100% 50% 50% 100% 50% Channel 0 100% 50% 50% 100% 50%
Lastly, if you configure the subchannel volume level of the multimedia subchn to 50%, you'll see its Subchn value go to 50%, and the Control and Current values of the multimedia subchannel go to 25%. The Ducking and Current values of the default subchannel are further scaled down to 12%, maintaining the overall system audio policy of default audio types not exceeding 50% of the multimedia volume level.
# mix_ctl -a1:0 group "Wave Playback Channel,2" volume=50% # cat /dev/snd/stateC1 McASP @ 0x48468000, McASP pcmC1D0p ocb = 0x10141c38 - subchn = 0x1014ed30 pid = 1773597 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=default Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 100% 100% 100% 12% 12% Channel 0 100% 100% 100% 12% 12% ocb = 0x10150528 - subchn = 0x1014eb78 pid = 380962 wave @ localhost RUNNING - not block - not block - not block scount=7483392 used=258048 free=0 frag_size=64512 frags_total=4 Rate=48000 Format=s16l Voices=2 NOT MMAPED CACHED INTERLEAVED pcm_link mode: ASYNC Audio Type=multimedia Ducking State=ACTIVE Volume Ramp Parameters: Subchn AudioType Control Ducking Current Channel 0 50% 50% 25% 100% 25% Channel 0 50% 50% 25% 100% 25%