Porting ALSA audio library

Source: Internet
Author: User
Porting ALSA audio library
Category: Linux Embedded driver development ()
5244 reading comments (1)
Favorites
Report
Playbackaudio embedded test linuxtimer

Andrew Huang Bluedrum@163.comALSA is a late audio processing library in Linux, which is mainly used to improve the original OSS library. better performance, supporting multiple playback sources, etc. but correspondingly, the programming complexity is increased. the old OSS uses the standard file I/O interface, the device opens open, the sound broadcasting uses the data I/O interface (read/write), and the device parameters are controlled by IOCTL. therefore, no additional libraries or configuration files are required to operate the device. however, ALSA eventually adopts open/read/write/ioctl, but there are more operation nodes. more complex. therefore, additional libraries are used in programming. ALSA ArchitectureThe official homepage is http://www.alsa-project.org /.
  • ALSA-Lib. ALSA application library (most commonly used)

    • Ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.22.tar.bz2
  • The ALSA driver code of some common chips. Generally, the kernel is integrated.
    • Ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.22.1.tar.bz2
  • ALSA-firmware: some specific microcodes of the DSP or ASIC (these are carried on the chip and loaded into the hardware by Linux at startup ).

    • Ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.20.tar.bz2
  • ALSA-utils is generally a small ALSA testing tool, such as aplay/arecord playing and recording applets.

    • 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
Among them, ALSA-driver and ALSA-firwware are the things that kernel developers are exposed to. For hardware that is already running normally, this Part has been integrated into the kernel and does not need to be modified. ALSA-utils is mainly used to test some gadgets. therefore, an application developer or embedded application developer is exposed to libraries compiled by ALSA-lib. Libasound. Linux ALSA driver testThe following is the result of testing ALSA on RHEL 5. If ALSA is installed on an arm or MIPS Development Board, the corresponding device is displayed 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
Under normal circumstances, you can see the following device nodes in your/dev/SND (except that the kernel driver adjusts the node location ). Ls-L/dev/SND
[Root @ hxy alsa-lib-1.0.22] #Ls-L/dev/SND
Total 0
CrW ------- 1 Root 116, 8 Mar 2 controlc0
CrW ------- 1 Root 116, 4 Mar 2 midic0d0
CrW ------- 1 Root 116, 7 Mar 2 pcmc0d0c
CrW ------- 1 Root 116, 6 Mar 2 pcmc0d0p
CrW ------- 1 Root 116, 5 Mar 2 pcmc0d1p
CrW ------- 1 Root 116, 3 Mar 2 0:41 seq
CrW ------- 1 Root 116, 2 Mar 2 Timer
Generally, ALSA-utils is installed on the desktop. run aplay-h to test whether the output is correct. if you can input a WAV file to test whether the entire environment works properly. below are some examples of ALSA-utils Testing
  • Play a wave file

    •  Aplay/mnt/nfs/test.wav
  • Variable-Frequency playback (the audio is played at 44 kHz)
    • Aplay-D rate_44k/mnt/nfs/test.wav
  • Recording, recording in the wave format at an interval of 20 seconds (-D 20), stereo (-C 2), and a frequency of Hz

    • Arecord-D 20-C 2-T wav-r 8000-F "signed 16 Bit little endian"/mnt/nfs/test.wav
  • Test the mixed audio (first test1.wav, then test2.wav at the same time)
    • Aplay-D plug: dmix_44k/mnt/nfs/test1.wav &
    • Aplay-D plug: dmix_44k/mnt/nfs/test2.wav
  • Set the sound playback gain (0 to 3)
    • Amixer set master 1
  • Set the recording volume (0-31)
    •  Amixer set line 10
Port the Alsa library in embedded Linux.In ARM-LINUX/MIPS Linux port ALSA library, first save the device driver node is correct, and then the main transplantation ALSA-lib Port ALSA-lib.Decompress tar xvjf alsa-lib-1.0.22.tar.bz2 CD alsa-lib-1.0.22 to 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 include/config. alsa_config_dir directory in H. it is your -- prefix directory by default. in this way, the embedded cross-compilation will be a desktop path in libasoud. so run. will prompt, if this prompt is displayed, it is generally caused by alsa_config_dir path error.

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 also true. It is set to alsa_plugin_dir macro. Compile make to install make install Development Board release notes:Release the Alsa library on the Development Board. except libasound. in addition to the so library, the ALSA. conf is published to the Alsa directory under the directory pointed to by -- With-configdir on the board. Otherwise, "audio open error: no such file or directory" is reported ". after make install, find the Alsa directory in the share directory under your installation directory and copy the entire directory to the Development Board. Port ALSA-utilsDecompress: Tar xvjf alsa-utils-1.0.22.tar.bz2 CD alsa-utils-1.0.22 to 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 is required. Otherwise, the libasound cannot be found. in addition, alsamixer is an ncurses program, which is basically hard to be transplanted on embedded terminals. so cancel it here. -- disable-xmlto is also because the library cannot be found. compile make to install make install my summary: Friends who use virtual machines should not perform cross-compilation in the shared directory; otherwise, unexpected situations may occur, such as the inability to establish soft connections.

Andrew Huang Bluedrum@163.comALSA is a late audio processing library in Linux, which is mainly used to improve the original OSS library. better performance, supporting multiple playback sources, etc. but correspondingly, the programming complexity is increased. the old OSS uses the standard file I/O interface, the device opens open, the sound broadcasting uses the data I/O interface (read/write), and the device parameters are controlled by IOCTL. therefore, no additional libraries or configuration files are required to operate the device. however, ALSA eventually adopts open/read/write/ioctl, but there are more operation nodes. more complex. therefore, additional libraries are used in programming. ALSA ArchitectureThe official homepage is http://www.alsa-project.org /.
  • ALSA-Lib. ALSA application library (most commonly used)

    • Ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.22.tar.bz2
  • The ALSA driver code of some common chips. Generally, the kernel is integrated.
    • Ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.22.1.tar.bz2
  • ALSA-firmware: some specific microcodes of the DSP or ASIC (these are carried on the chip and loaded into the hardware by Linux at startup ).

    • Ftp://ftp.alsa-project.org/pub/firmware/alsa-firmware-1.0.20.tar.bz2
  • ALSA-utils is generally a small ALSA testing tool, such as aplay/arecord playing and recording applets.

    • 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
Among them, ALSA-driver and ALSA-firwware are the things that kernel developers are exposed to. For hardware that is already running normally, this Part has been integrated into the kernel and does not need to be modified. ALSA-utils is mainly used to test some gadgets. therefore, an application developer or embedded application developer is exposed to libraries compiled by ALSA-lib. Libasound. Linux ALSA driver testThe following is the result of testing ALSA on RHEL 5. If ALSA is installed on an arm or MIPS Development Board, the corresponding device is displayed 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
Under normal circumstances, you can see the following device nodes in your/dev/SND (except that the kernel driver adjusts the node location ). Ls-L/dev/SND
[Root @ hxy alsa-lib-1.0.22] #Ls-L/dev/SND
Total 0
CrW ------- 1 Root 116, 8 Mar 2 controlc0
CrW ------- 1 Root 116, 4 Mar 2 midic0d0
CrW ------- 1 Root 116, 7 Mar 2 pcmc0d0c
CrW ------- 1 Root 116, 6 Mar 2 pcmc0d0p
CrW ------- 1 Root 116, 5 Mar 2 pcmc0d1p
CrW ------- 1 Root 116, 3 Mar 2 0:41 seq
CrW ------- 1 Root 116, 2 Mar 2 Timer
Generally, ALSA-utils is installed on the desktop. run aplay-h to test whether the output is correct. if you can input a WAV file to test whether the entire environment works properly. below are some examples of ALSA-utils Testing
  • Play a wave file

    •  Aplay/mnt/nfs/test.wav
  • Variable-Frequency playback (the audio is played at 44 kHz)
    • Aplay-D rate_44k/mnt/nfs/test.wav
  • Recording, recording in the wave format at an interval of 20 seconds (-D 20), stereo (-C 2), and a frequency of Hz

    • Arecord-D 20-C 2-T wav-r 8000-F "signed 16 Bit little endian"/mnt/nfs/test.wav
  • Test the mixed audio (first test1.wav, then test2.wav at the same time)
    • Aplay-D plug: dmix_44k/mnt/nfs/test1.wav &
    • Aplay-D plug: dmix_44k/mnt/nfs/test2.wav
  • Set the sound playback gain (0 to 3)
    • Amixer set master 1
  • Set the recording volume (0-31)
    •  Amixer set line 10
Port the Alsa library in embedded Linux.In ARM-LINUX/MIPS Linux port ALSA library, first save the device driver node is correct, and then the main transplantation ALSA-lib Port ALSA-lib.Decompress tar xvjf alsa-lib-1.0.22.tar.bz2 CD alsa-lib-1.0.22 to 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 include/config. alsa_config_dir directory in H. it is your -- prefix directory by default. in this way, the embedded cross-compilation will be a desktop path in libasoud. so run. will prompt, if this prompt is displayed, it is generally caused by alsa_config_dir path error.

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 also true. It is set to alsa_plugin_dir macro. Compile make to install make install Development Board release notes:Release the Alsa library on the Development Board. except libasound. in addition to the so library, the ALSA. conf is published to the Alsa directory under the directory pointed to by -- With-configdir on the board. Otherwise, "audio open error: no such file or directory" is reported ". after make install, find the Alsa directory in the share directory under your installation directory and copy the entire directory to the Development Board. Port ALSA-utilsDecompress: Tar xvjf alsa-utils-1.0.22.tar.bz2 CD alsa-utils-1.0.22 to 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 is required. Otherwise, the libasound cannot be found. in addition, alsamixer is an ncurses program, which is basically hard to be transplanted on embedded terminals. so cancel it here. -- disable-xmlto is also because the library cannot be found. compile make to install make install my summary: Friends who use virtual machines should not perform cross-compilation in the shared directory; otherwise, unexpected situations may occur, such as the inability to establish soft connections.

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.