ALSA project - the C library reference: Runtime arguments in configuration files

ALSA project - the C library reference

- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Runtime arguments in configuration files

The ALSA library can accept runtime arguments for some configuration blocks. This extension is built on top of the basic configuration file syntax.

# Defining arguments

Arguments are defined using the id (key) `@args` and array values containing the string names of the arguments:

@args [ CARD ] # or
@args.0 CARD

# Defining argument types and default values

An argument's type is specified with the id (key) `@args` and the argument name. The type and the default value are specified in the compound block:

@args.CARD {
type string
default "abcd"
}

# Referring to arguments

Arguments are referred to with a dollar-sign ($) and the name of the argument:

card $CARD

# Usage

To use a block with arguments, write the argument values after the key, separated with a colon (:). For example, all these names for PCM interfaces give the same result:

hw:0,1
hw:CARD=0,DEV=1
hw:{CARD 0 DEV 1}
plug:"hw:0,1"
plug:{SLAVE="hw:{CARD 0 DEV 1}"}

As you see, arguments can be specified in their proper order or by name. Note that arguments enclosed in braces are parsed in the same way as in configuration files, but using the override method by default.

# Example

pcm.demo {
@args [ CARD DEVICE ]
@args.CARD {
type string
default "supersonic"
}
@args.DEVICE {
type integer
default 0
}
type hw
card $CARD
device $DEVICE
}