Syntax of the audio policy configuration file
Audio policy configuration files have a specific syntax.
- The name is case-insensitive.
- White space within a key or value causes the key-value pair to be discarded, resulting in an invalid configuration file.
- Each key must have a value; a value must have a key.
- The value of the prio for the first audio type defined in the configuration doesn't matter since its key has meaning relative to the audio type before it. When you want two audio types to have equal ducking priority, specify same for prio.
- For each audio type that you define, you must specify all the key-value pairs. If you don't, the configuration isn't valid.
- In general, the first audio type defined in the file is assigned the highest priority.
- If the configuration file isn't valid (e.g., it's missing a required key-value pair for an audio type or an invalid value is specified), io-audio fails to start with the resulting information about the failure in the system log.
The following sections are valid:
- audio_type: Audio types
- vol_ramp: Volume ramping
- vol_tbl: Volume multiplier table
[audio_type] section
audio_type section, you must use the following
key-value pairs to describe the audio type. Every required key must be defined
in the audio type section with valid values.
- Key: (Required) name
- A string that specifies the name of the audio type. For example, phone or ringtone.
- Key: (Required) prio
- The priority directive of the audio type defined as a String value. These are the valid values:
- same — the audio type has the same priority as previous audio type. If all the audio_types have the prio key set to same, then all audio types are at the same priority (including the first entry). An entry needs to define prio=decr for the priority to change.
- decr — the priority of the audio type is one lower than
the previously defined audio type.
The first entry you define has the highest priority and forces any lower priority audio streams to duck (lower their volume).
- Key: (Required) duck_same_prio_policy
- The ducking policy applied to audio types of the same priority, defined as a
String value. You cannot have different policies
configured for audio types with the same priority. These are the
valid values:
- last_wins — The last added stream ducks previously added audio streams with the same priority.
- first_wins — The first added stream ducks other audio streams with the same priority.
- mix — The added audio stream ducks all or specific
channels of other streams with the same priority. When you use this
policy for audio types with the same priority, those streams are
ducked according to the duck_same_prio_percent setting. If
there are multiple ducking settings are applied, then the strictest
(lowest ducking volume) configuration applies. For more information
on duck_same_prio_policy and
duck_same_prio_percent, see
Understanding the mix policy when using multiple audio types with the same priority.
Note:All audio types with the same priority level and that have duck_same_prio_policy=mix must have the same values set for the duck_lower_prio_percent.
CAUTION:Don't set duck_same_prio_policy to mix if you want to use enable preemption_by_same. If you do, io-audio fails to start. - Key: (Required) duck_same_prio_percent
- Integer or String:Integer
- Key: (Required) duck_lower_prio_percent
- Integer or String:Integer
- Key: (Optional) preemptable
- String (true, true:suspend, or false)
- Key: (Optional) transient
- Boolean (true or false)
(Optional) [vol_ramp] section
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.
- Key: (Required) name
- String(ducking, pause_resume, volume_mute)
- Key: (Required) duration
- Integer
- Key: (Optional) profile
- Integer:Integer(sample percentage, volume increase percentage)
(Optional) [vol_tbl] section
If you do not specify this section, the default values described below are used.
- Key: min_dB
- Integer
- Key: min_mute
- String (true, false)
Example of an audio policy configuration file
[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
[vol_tbl]
min_db=-60 # The minimum value for the multiplier table is
# -60 decibels
min_mute=true # Index 0 of the table is a multiplier value of
# 0 to achieve full mute at 0 volume
