Transplantation of ALSA Audio Library

Source: Internet
Author: User
Tags bz2

Andrew Huang bluedrum@163.comALSA is a late audio processing library in Linux, mainly for improvements to the existing OSS libraries. Better performance, support for multiple playback sources, and so on. But correspondingly, increased programming complexity. The old OSS is a standard file IO interface, the device is opened with open, the audio recording is the data IO interface (read/write), the parameters of the device are controlled by IOCTL. They're all system calls. This eliminates the need for additional libraries and configuration files to operate the device. But Alsa is also the ultimate use of open/ Read/write/ioctl, but more operation nodes. More complex. Therefore, in the programming is the use of additional libraries to operate.architecture of the ALSAThe 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 Specialized microcode for some DSP or ASIC (shipped on top of the chip, Linux is loaded into the hardware at startup. 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 Alsa-oss uses the ALSA interface to simulate 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,    For already running hardware, it usually means that this part has been integrated into the kernel without modification.    And alsa-utils is mainly testing some gadgets. So for an application developer, or embedded application developer, access to a library that is primarily Alsa-lib compiledLibasound.Linux ALSA Drive testThe following are the results of my test alsa on Rhel 5, similar to the one on ARM or MIPS Development Board if you install ALSA, you will see the corresponding device in/proc: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
Normally, in your/dev/snd you will see the following device nodes (with the exception that the kernel drive adjusts the endpoint position) ls-l/dev/snd

[Root@hxy alsa-lib-1.0.22]# ls-l/dev/snd
Total 0
CRW-------1 root 116, 8 Mar 2 02:41 controlC0
CRW-------1 root 116, 4 Mar 2 02:41 midic0d0
CRW-------1 root 116, 7 Mar 2 02:41 pcmc0d0c
CRW-------1 root 116, 6 Mar 2 02:41 pcmc0d0p
CRW-------1 root 116, 5 Mar 2 02:41 pcmc0d1p
CRW-------1 root 116, 3 Mar 2 02:41 seq
CRW-------1 root 116, 2 Mar 2 02:41 Timer
Typically, the desktop version already has Alsa-utils installed. You can perform a aplay-h test to see if the output will be tested. If you can come up with a WAV file to test whether the entire environment is working properly. Here are some examples of using the Alsa-utils test sample to play the wave file Aplay/mnt/nfs/test.wavFrequency conversion playback, (in order to play the audio with a khz) aplay-d rate_44k/mnt/nfs/test.wavRecording in 20-second interval (-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.wavTest mix playback (first play test1.wav and then play Test2.wav) aplay-d Plug:dmix_44k/mnt/nfs/test1.wav & aplay-d plug:dmix_44k/mnt/nfs/test2.wavSet playback gain (0 to 3) amixer set Master 1Set recording volume (0-31) Amixer Set line Embedded Linux under Alsa Library porting.Porting the ALSA library under Arm-linux/mips LINUX first saves the device-driven node correctly. Then the main transplant alsa-lib the transplant of Alsa-lib.Extract tar xvjf alsa-lib-1.0.22.tar.bz2 cd alsa-lib-1.0.22 build 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
Notice the--with--configdir option here. It will affect the Alsa_config_dir directory in Include/config.h. It defaults to your--prefix directory. So in-embedded cross compilation will be a desktop path, run in libasoud.so. Will prompt, if comes out this prompt, generally is the Alsa_config_dir path error causes.

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 macros. Compiling make installation 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 alsa.conf to the ALSA directory on the board--with-configdir to the directory, or it will be reported "audio open error:no such File or directory. This file can find the ALSA directory after make install the share in your installation directory, and copy the entire directory to the Development Board. alsa-utils TransplantDecompression: Tar xvjf alsa-utils-1.0.22.tar.bz2 CD alsa-utils-1.0.22 generation 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 very difficult to transplant in the embedded terminal. So it's canceled.--disable-xmlto is also because the library is not found. Compiling make installation make install

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.