ALSA is a relatively late audio processing library in Linux, mainly for the original OSS library to improve. Better performance, support for multiple playback sources, etc. but correspondingly, the complexity of programming is increased.
The old OSS is the standard file IO interface, the device opens with open, the audio broadcast is using the Data IO Interface (read/write), the parameters of the device are controlled by the IOCTL. It's all system calls, so no additional libraries and configuration files are required to operate the device. But Alsa was eventually adopted open/ Read/write/ioctl, but the operation node is more complex. Therefore, in programming, additional libraries are used to operate.
Architecture of the ALSA
Official Homepage http://www.alsa-project.org/
Mainly related to programming is
Alsa-lib. ALSA Application Library (most commonly used)
ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.22.tar.bz2
Alsa-driver Some common chip Alsa driver code, the general kernel will be integrated.
ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.22.1.tar.bz2
Alsa-firmware some DSP or ASIC dedicated microcode (shipped on the chip, boot up by Linux loaded into the hardware).
ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.20.tar.bz2
Alsa-utils General ALSA Small test tools. such as Aplay/arecord playback and recording applet.
ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.22.tar.bz2
The Alsa-oss uses the Alsa interface to emulate the old OSS interface.
ftp://ftp.alsa-project.org/pub/oss-lib/alsa-oss-1.0.17.tar.bz2
Where Alsa-driver,alsa-firwware is something that the kernel developer touches, it usually means that the part has been integrated into the kernel without modification for the hardware that is already running properly.
And alsa-utils is mainly testing some gadgets.
So for an application developer, or an embedded application developer, it is primarily Alsa-lib compiled library Libasound.
Linux ALSA Drive Test
Here are the results of my test alsa on Rhel 5, similar to those on the arm or MIPS Development Board
If you install ALSA, you will see the appropriate device in/proc:
With Cat/proc/asound/devices
[Root@hxy alsa-lib-1.0.22]# Cat/proc/asound/devices
2:: Timer
3:: Sequencer
4: [0-0]: Raw MIDI
5: [0-1]: Digital audio playback
6: [0-0]: Digital audio playback
7: [0-0]: Digital audio capture
8: [0]: Control
Under normal circumstances, you will see the following device nodes in your/DEV/SND (with the exception that the kernel driver adjusts the endpoint location).
With Ls-l/dev/snd
[Root@hxy alsa-lib-1.0.22]# ls-l/dev/snd
Total 0
CRW-------1 root root, 8 Mar 2 02:41 controlC0
CRW-------1 root root, 4 Mar 2 02:41 midic0d0
CRW-------1 root root, 7 Mar 2 02:41 pcmc0d0c
CRW-------1 root root, 6 Mar 2 02:41 pcmc0d0p
CRW-------1 root root, 5 Mar 2 02:41 pcmc0d1p
CRW-------1 root root, 3 Mar 2 02:41 seq
CRW-------1 root root, 2 Mar 2 02:41 Timer
Usually the desktop version already has Alsa-utils installed. You can perform a aplay-h to test for output. If you can play a WAV file to test whether the entire environment is working properly.
Here are some examples of testing with Alsa-utils
Play wave files
Aplay/mnt/nfs/test.wav
Variable frequency playback, (to play audio with a few khz)
Aplay-d Rate_44k/mnt/nfs/test.wav
Recording, at 20-second intervals (-D 20), Stereo (-C 2), frequency 8000Hz to record wave format audio
arecord-d 20-c 2-t wav-r 8000-f "signed-bit Little Endian"/mnt/nfs/test.wav
Test mix playback (first play test1.wav, then play Test2.wav)
Aplay-d Plug:dmix_44k/mnt/nfs/test1.wav &
Aplay-d Plug:dmix_44k/mnt/nfs/test2.wav
Set playback gain (0 to 3)
Amixer Set Master 1
Set recording volume (0-31)
Amixer Set Line 10
Embedded Linux under ALSA Library migration.
To migrate the ALSA library under Arm-linux/mips LINUX, first save the device driver node correctly.
Then the main transplant alsa-lib
Transplantation of Alsa-lib.
Unzip the tar xvjf alsa-lib-1.0.22.tar.bz2
CD alsa-lib-1.0.22
Generate makefile
./configure--host=arm-linux--prefix= $PWD/.. /.. /output/arm-linux--enable-static--enable-shared--disable-python--with-configdir=/usr/local/share-- With-plugindir=/usr/local/lib/alsa_lib
Note the--with--configdir option here. It will affect the Alsa_config_dir directory in Include/config.h.
It defaults to your--prefix directory. This way the embedded cross-compilation will be a desktop path that runs in libasoud.so. Will prompt, if come out this hint, generally are alsa_config_dir path error caused.
ALSA Lib pcm.c:2145: (snd_pcm_open_noupdate) Unknown PCM default
Aplay:main:546:audio open error:no such file or directory
--with-plugindir is the same thing. It is set to ALSA_PLUGIN_DIR macro.
Compiling make
Install make install
Development Board Release Note:
Publish the ALSA Library on the Development Board. In addition to the Libasound.so library, you must also publish the alsa.conf to the ALSA directory on the board where--with-configdir points to the directory, otherwise it will be reported as "audio open error:no such File or directory.
This file can be found in the share directory in your installation directory after make install, and the entire directory will be copied to the Development Board ALSA.
Alsa-utils Transplant
Decompression: Tar xvjf alsa-utils-1.0.22.tar.bz2
CD alsa-utils-1.0.22
Generate makefile
./configure--host=arm-linux--prefix= $PWD/.. /.. /output/arm-linux--enable-static--enable-shared--with-configdir=/usr/local/share--with-libiconv-prefix= $PWD/... /.. /output/arm-linux cflags= "-i$pwd/. /.. /output/arm-linux/include "ldflags="-l$pwd/. /.. /output/arm-linux/lib-lasound-liconv "--disable-alsamixer--disable-xmlto
Note that ldflags here is a must, otherwise you will not find Libasound. In addition Alsamixer is a ncurses program, which is basically difficult to transplant on embedded terminals. So this is canceled.--disable-xmlto is also because the library is not found.
Compiling make
Install make install