Linux audio driver (1)

Source: Internet
Author: User

The audio card drivers in Linux mainly include OSS and ALSA.

OOS (Open Sound System), Official Website: www.opensound.com
ALSA (Advanced Linux sound architecture), Official Website: www.alsa-project.com

OSS architecture and implementation
An OSS device is a character device, and the master device number is 14. The second device number is defined separately by each device.
DEVICE file:
/Dev/sndstat
Read-Only files only report the current sound card status. Provided to end users for sound card detection.

/Dev/DSP
Device Files used for sampling and recording. Writing data is playing, reading data is recording. This device may have multiple devices, such as/dev/dsp1.
DSP devices are mainly used for A/D, D/A conversion. It can be opened in read/write mode, such as an IP phone number.
The speed matching between the kernel buffer and the user buffer must be considered for DSP device drivers, mainly because of the matching between the sampling frequency (determined by the kernel) and the read/write speed of the application, speed difference may cause inconsistency of sound data or IO blocking.
Default Value: 8-bit unsigned data, single channel, 8 KHz sampling rate.

/Dev/Audio
Similar to/dev/DSP, for compatibility purposes, it is compatible with audio devices on SUN workstations and uses the Mu-Law encoding method. For applications, only one of/dev/DSP or/dev/Audio can be used at the same time, because they are different software interfaces of the same hardware.

/Dev/Mixer
The software interface of the application to the mixer. The mixer circuit consists of two parts: Input mixer and ouput mixer.
The mixer is located behind the DSP and is directly connected to devices such as speakers. The mixer outputs both analog signals, whether output to the DSP or the Speaker.
Programming on the mixer includes how to set the gain controller level and how to switch between different audio sources. These operations are usually not consecutive and do not occupy a large amount of computer resources like recording or playing. Therefore, in addition to open and close, most of the operations are performed by calling the ioctl system. Unlike/dev/DSP,/dev/mixer allows simultaneous access by multiple applications, and the set value of the mixer remains until the corresponding device file is closed.
To simplify the application design, most of the audio card drivers on Linux support applying the ioctl operation of the mixer directly to the sound device. That is to say, if/dev/DSP is enabled, you do not need to enable/dev/mixer to operate the mixer. Instead, you can directly use the File Identifier obtained when opening/dev/DSP to set the mixer.

/Dev/sequencer
It is used to operate the built-in wave table synthesizer of the sound card or to control the instrument on the Midi bus.

Related Files: (IN kernel)
Include/Linux/Soundcard. h
Include/Linux/sound. h
Sound/sound_core.h

For the module entry, see sound_core.h:
Main Implementation
Subsys_initcall (init_soundcore );
Module_exit (cleanup_soundcore );

Static int _ init init_soundcore (void)
{
Int RC;

Rc = init_oss_soundcore ();
If (RC)
Return RC;

Sound_class = class_create (this_module, "sound ");
If (is_err (sound_class )){
Cleanup_oss_soundcore ();
Return ptr_err (sound_class );
}

Sound_class-> devnode = sound_devnode;

Return 0;
}

Static int _ init init_oss_soundcore (void)
{
If (preclaim_oss &&
Register_chrdev (sound_major, "sound", & soundcore_fops) =-1 ){
Printk (kern_err "soundcore: Sound device already in use. \ n ");
Return-ebusy;
}

Return 0;
}

Static void _ exit cleanup_soundcore (void)
{
Cleanup_oss_soundcore ();
Class_destroy (sound_class );
}

Static void cleanup_oss_soundcore (void)
{
/* We have nothing to really do here-we know the lists must be
Empty */
Unregister_chrdev (sound_major, "sound ");
}

Static const struct file_operations soundcore_fops =
{
/* We must have an owner or the module locking fails */
. Owner = this_module,
. Open = soundcore_open,
};

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.