Advanced Linux sound architecture (ALSA) Study Notes

Source: Internet
Author: User

Please indicate the source when reprint: http://blog.csdn.net/absurd
 
ALSA is not a new thing that has appeared recently. It has been developing for many years,
2.6. ALSA provides not only a few sound card drivers, but a complete set of solutions from drivers to upper-layer applications. It took me some time to read
ALSA-related materials and code. This article records some notes taken during the study.
According to the Alsa official website, it has the following features:
1. effectively supports all types of audio interfaces, from normal sound cards to professional audio devices.
2. Fully modular sound card driver.
3. SMP and thread security design.
4. A user space function library provides high-level programming interfaces to simplify application development.
5. Supports older OSS APIs and is compatible with most OSS applications.
Why is ALSA more promising than OSS? Some people once said that ALSA has better performance and less latency. However, the well-designed OSS driver is not inferior to the Alsa driver in terms of performance, so we do not compare the performance, but ALSA has the following advantages:
1. the kernel code and user space code are separated. Only necessary code is put in the kernel, and other code is implemented in alsalib.
2. The architecture of ALSA-kernel/ALSA-driver is better designed, and more code can be shared between different drivers. The driver behavior is also more unified, which is also good for applications.
3. ALSA-lib provides easier-to-use APIs to simplify application development.
However, the OSS does not seem to be convinced, and it is unwilling to let ALSA grab the limelight. On the opensound website, there is an article about audio myth and legend.
It is highly inflammatory and persuasive, and can be considered as a counterargument to ALSA's supporters. I personally think that ALSA's advantages above can be achieved by improving OSS, without re-engineering or
The focus is that the OSS does not have open source code, so Linux enthusiasts decide to develop their own set. In any case, OSS will not become history so quickly, because it supports all UNIX systems, and
ALSA focuses on Linux systems.
ALSA consists of the following parts:
1. Driver kernel driver, including hardware-related and some public code. There are nearly 0.3 million lines of code, which is too huge. I only read some code in core selectively. For example, after a rough view of writing an ALSA driver, it is well written.
2. Library user space function library, which is used for applications. To include the header file asoundlib. H, link to the shared library libasound. So.
3. Lib-plugins provide two plug-ins. One uses Jack to simulate the Alsa interface and the other uses OSS to simulate the Alsa interface. High! ALSA can be used as Jack's backend, or as ALSA's backend. ALSA can simulate OSS, OSS can also simulate ALSA.
4. Utilities some ALSA-based command line applets can be used as sample code reference.
5. Some tools, such as vxloader, can be used to load firmware.
 
6. Firmware
Firmware of some devices. These firmware are loaded by the kernel through hotplug when appropriate. Firmware is actually a program, and every device is actually
Independent embedded systems, sound cards, and their own programs. However, to save costs and facilitate upgrades, these devices may only have Ram and no rom. when the device is started)
The device can run only when firmware is loaded into the device's Ram.
7. OSS compat code compatible with OSS.
Currently, the Alsa Kernel provides the following interfaces to the user space:
1. Information interface (/proc/asound)
2. Control Interface (/dev/snd/controlcx)
3. mixer interface (/dev/snd/mixercxdx)
4. PCM Interface (/dev/snd/pcmcxdx)
5. Raw MIDI interface (/dev/snd/midicxdx)
6. sequencer interface (/dev/snd/SEQ)
7. Timer interface (/dev/snd/timer)
Similar to OSS, OSS also provides files, but these interfaces are used by alsalib rather than applications. Applications should use alsalib or more advanced interfaces, such as interfaces provided by Jack.
ALSA Programming
When developing an application based on ALSA, do not directly use the interface provided by ALSA-driver, but use the alsalib function. Alsalib provides a wide range of functions. It is estimated that there are hundreds of functions. Fortunately, there are not many commonly used functions. ALSA's howto provides a simple example of playback and recording, which is worth your reference.
Todo:
Continue to read the Alsa-driver and alsalib code.
Study Jack's architecture.
~~ End ~~

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.