Advanced Linux sound architecture (ALSA) Study Notes

Source: Internet
Author: User

Advanced Linux sound architecture (ALSA) Study Notes

 

Reprinted please indicate the source and the author contact: http://blog.csdn.net/absurd

Contact information: Li xianjing <xianjimli at Hotmail dot com>

Last Updated: 2006-12-19

 

ALSA is not a new thing that has just emerged recently. It has actually been developing for many years. However, it has not become a proper replacement for OSS names until it is in kernel 2.6. ALSA provides not only a few sound card drivers, but a complete set of solutions from drivers to upper-layer applications. I recently spent some time reading ALSA related materials and code. This article records some notes during the study.

 

According to ALSAThe statement on the official website 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 the myth and legend of audio, which is highly inflammatory and persuasive and can be considered as a counterargument to ALSA supporters. I personally think that ALSA's advantages above can be achieved by improving the OSS without re-engineering, or the real focus is that the OSS does not have open source code, so Linux enthusiasts decide to develop their own solutions. In any case, the 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 each device is actually an independent embedded system. The sound card is also the same and has its own program. However, to save costs and facilitate upgrades, these devices may only have ram instead of Rom. when starting a device, the system (such as Linux) loads the firmware of the device into the device's Ram, the device can run.

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.