File: //usr/share/doc/alsa-lib-devel-1.0.17/lib64/html/confarg.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ALSA project - the C library reference: Runtime arguments in configuration files</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1><a class="anchor" name="confarg">Runtime arguments in configuration files</a></h1>The ALSA library can accept runtime arguments for some configuration blocks. This extension is built on top of the basic configuration file syntax.<h2><a class="anchor" name="confarg_define">
Defining arguments</a></h2>
Arguments are defined using the id (key) <code>@args</code> and array values containing the string names of the arguments:<p>
<div class="fragment"><pre class="fragment">@args [ CARD ] # or
@args.0 CARD
</pre></div><h2><a class="anchor" name="confarg_type">
Defining argument types and default values</a></h2>
An argument's type is specified with the id (key) <code>@args</code> and the argument name. The type and the default value are specified in the compound block:<p>
<div class="fragment"><pre class="fragment">@args.CARD {
type string
<span class="keywordflow">default</span> <span class="stringliteral">"abcd"</span>
}
</pre></div><h2><a class="anchor" name="confarg_refer">
Referring to arguments</a></h2>
Arguments are referred to with a dollar-sign ($) and the name of the argument:<p>
<div class="fragment"><pre class="fragment"> card $CARD
</pre></div><h2><a class="anchor" name="confarg_usage">
Usage</a></h2>
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:<p>
<div class="fragment"><pre class="fragment">hw:0,1
hw:CARD=0,DEV=1
hw:{CARD 0 DEV 1}
plug:<span class="stringliteral">"hw:0,1"</span>
plug:{SLAVE=<span class="stringliteral">"hw:{CARD 0 DEV 1}"</span>}
</pre></div><p>
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.<h2><a class="anchor" name="confarg_example">
Example</a></h2>
<div class="fragment"><pre class="fragment">pcm.demo {
@args [ CARD DEVICE ]
@args.CARD {
type string
<span class="keywordflow">default</span> <span class="stringliteral">"supersonic"</span>
}
@args.DEVICE {
type integer
<span class="keywordflow">default</span> 0
}
type hw
card $CARD
device $DEVICE
}
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Tue Jan 20 22:42:10 2009 for ALSA project - the C library reference by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>