Audio policy configuration files have a specific syntax.
The following sections are valid:
The first entry you define has the highest priority and forces any lower priority audio streams to duck (lower their volume).
A single value (between 0 or 100) specifies the percentage to reduce the volume by for active streams at the same priority level, for all channels. For example, if you specify duck_same_prio_percent=50, it means adjust to 50% of current volume level. To configure no ducking, either specify 100 or the string noducking. To understand what happens when multiple percentages are applied, see the Understanding the mix policy with multiple audio types with the same priority section.
To specify percentage values for multiple channels, use the following syntax to specify the channel and the percentage to duck, which delimits each channel with a comma (,):
chX:ducking_percentage, chX:ducking_percentage
where X represents the channel number.
It's important to mention that if you don't specify a percentage for an active channel, ducking defaults to 100 (or no ducking).
For example, the following entry specifies that channel 0 adjusts to 50% of its volume level and channel 1 adjusts to 80% of its volume level. Because no value is specified for channel 2, ducking isn't applied to it:Use the following syntax, which delimits each channel with a comma (,):
chX:ducking_percentage, chX:ducking_percentage
where X represents the channel number.
It's important to mention that if you don't specify a percentage for an active channel, ducking defaults to 100 (or no ducking).
For example, the following specifies that channel 0 adjusts to 50% of its volume level and channel 1 adjusts to 80% of its volume level. Because no value is specified for channel 2, ducking isn't applied to it (effectively 100):
duck_same_prio_percent=ch0:50,ch1:80
It's important to remember that when the audio stream is ducked to zero (that is, muted), the audio stream remains in the RUNNING (SND_PCM_STATUS_RUNNING) state.
It's important to mention that when this key is set to false, but the preemptable key is set to true:suspend, the audio stream that was preempted moves back to its original state when preemption is lifted (no longer ducked to zero).
This section permits you to define volume ramping for audio concurrency management scenarios based on specific names. The name and duration are required key-value pairs, and profile is optional. If you don't define ramping for an audio concurrency management scenario, the default duration is 20 milliseconds with a linear volume ramp (i.e., 100:100).
For each volume ramp ([vol_ramp]) section, you can use the following key-value pairs to describe the audio type.
profile=20:10,60:80,20:10In the example above, there are three ramp segments, which create a non-linear volume ramp. The segments mean:
[audio_type] # section defining an audio type
name=voice # Audio type name string
prio=same # Priority directive of the audio type,
# possible value is "same" or "decr"
duck_same_prio_policy=last_wins # Ducking policy of the same priority type,
# Possible values are "last_wins",
# "first_wins", or "mix"
duck_same_prio_percent=0 # Ducking percentage applied to same
# priority audio types
duck_lower_prio_percent=0 # Ducking percentage applied to lower
# priority audio types
transient=false # Cause lower preemptable types to suspend
[audio_type]
name=ringtone
prio=decr # Priority of the audio type is decreased
# by one from previous audio type
duck_same_prio_policy=last_wins # Last active audio stream that can duck
# previous audio streams of same priority
duck_same_prio_percent=50 # all channels of active streams at the
# same priority level are ducked to 50 percent
duck_lower_prio_percent=50 # all channels of active streams at lower
# priority levels are ducked to 50 percent
[audio_type]
name=nav
prio=decr
duck_same_prio_policy=last_wins
duck_same_prio_percent=ch0:50,ch1:100 # Channel/Voice 0 ducked to 50 percent,
# Channel/Voice 1 remains at 100 percent
duck_lower_prio_percent=ch0:50,ch1:100 # Ducking values will default to 100
# (no ducking) for channels not listed
[audio_type]
name=tts_front
prio=decr
duck_same_prio_policy=last_wins
duck_same_prio_percent=80
duck_lower_prio_percent=80
[audio_type]
name=tts_back
prio=same # Priority of the audio type is the
# same as the previously defined type
duck_same_prio_policy=last_wins
duck_same_prio_percent=0
duck_lower_prio_percent=50
# To allow games and media to play concurrently, define the game type one above
# media with duck_lower_prio_percent=100/noducking
# Note: This means that if there are other lower priority types
#defined they will also not be ducked by the game type.
[audio_type]
name=game
prio=decr
duck_same_prio_policy=mix # Mix audio streams at same priority with
# the below ducking configuration
duck_same_prio_percent=100 # 100 percent
duck_lower_prio_percent=noducking
preemptable=true:suspend # Suspend only if preempted or ducked to 0
# Live media is not pausable,
# so preemption is not enabled
[audio_type]
name=live_multimedia
prio=decr
duck_same_prio_policy=last_wins
duck_same_prio_percent=0
duck_lower_prio_percent=70
# The only difference between the live_multimedia and multimedia types
# is that multimedia can be paused so that preemption is enabled
[audio_type]
name=multimedia
prio=same
duck_same_prio_policy=last_wins
duck_same_prio_percent=0
duck_lower_prio_percent=70
preemptable=true #pause or suspend when preempted
[audio_type]
name=default
prio=decr
duck_same_prio_policy=mix # Mix audio streams at same priority
# with the below ducking configuration
duck_same_prio_percent=100 # 100 percent of volume (no ducking)
duck_lower_prio_percent=noducking
preemptable=true:suspend # Audio stream is suspended when
# ducked to 0 percent by higher priority
# types
[vol_ramp]
name=volume_mute # When mixer API calls are made,
# such as snd_pcm_mixer_write(),
duration=20 # ramp in the span of 20 milliseconds
profile=20:10,60:80,20:10 # Three linear segments are defined:
# Segment 1 specifies 20% of the duration
# and increases the volume by 10% of the
# volume ramp. Segment 2 specifies 60% of
# the duration and 80% of the volume
# increase. Segment 3 specifies the
# remaining 20% duration and to increase
# the volume by the remaining 10%.
[vol_ramp]
name=pause_resume # Whenever the user calls snd_pcm_*_resume() or
# snd_pcm_*_pause()
duration=30 # duration of 30 milliseconds
# No profile key-value is specified, so
# it's a linear ramp
[vol_ramp]
name=ducking # When ducking policies and preemption is used
duration=60 # Ramp time is 60 milliseconds