mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
ALSA: doc: Recommend the use of snd_ctl_elem_info()
Instead of the open code for the info call back of enum elements, recommend the use of snd_ctl_elem_info(), which will reduce lots of codes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
f114040e3e
commit
be93709cb1
1 changed files with 23 additions and 0 deletions
|
@ -3657,6 +3657,29 @@ struct _snd_pcm_runtime {
|
||||||
</informalexample>
|
</informalexample>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The above callback can be simplified with a helper function,
|
||||||
|
<function>snd_ctl_enum_info</function>. The final code
|
||||||
|
looks like below.
|
||||||
|
(You can pass ARRAY_SIZE(texts) instead of 4 in the third
|
||||||
|
argument; it's a matter of taste.)
|
||||||
|
|
||||||
|
<informalexample>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
static int snd_myctl_enum_info(struct snd_kcontrol *kcontrol,
|
||||||
|
struct snd_ctl_elem_info *uinfo)
|
||||||
|
{
|
||||||
|
static char *texts[4] = {
|
||||||
|
"First", "Second", "Third", "Fourth"
|
||||||
|
};
|
||||||
|
return snd_ctl_enum_info(uinfo, 1, 4, texts);
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</informalexample>
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Some common info callbacks are available for your convenience:
|
Some common info callbacks are available for your convenience:
|
||||||
<function>snd_ctl_boolean_mono_info()</function> and
|
<function>snd_ctl_boolean_mono_info()</function> and
|
||||||
|
|
Loading…
Add table
Reference in a new issue