The officially official Devuan Forum!

You are not logged in.

#1 Today 01:45:27

igorzwx
Member
Registered: 2024-05-06
Posts: 508  

The exclusive mode of ALSA

The exclusive mode of ALSA

With plughw:0,0 or default, the audio path is:

Application → ALSA Library → Plugin Layer → Kernel PCM Core → Hardware Driver → Hardware 

The ALSA path with hw:0,0 is:

Application → ALSA Library → Kernel PCM Core → Hardware Driver → Hardware 

When using hw:0,0, the ALSA library bypasses the plugin layer (software format/rate/channel conversion) but still goes through the kernel PCM core for buffer management, period handling, and synchronization before reaching the hardware driver.

Usually, "exclusive mode" refers to exclusive device access control by one applications (this is what the word exclusive is supposed to mean). Such exclusive device access prevents multiple applications from simultaneously using the same hardware resource. In the Linux kernel's technical documentation, "exclusive" has a specific meaning: preventing multiple applications from simultaneously using the same hardware resource.

ALSA permits "exclusive full duplex":

$ arecord -f cd -D hw:0,0 | aplay -V mono -D hw:0,0  
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
#####################   +                          | 46%

$ arecord -f cd -D hw:1,0 | aplay -V mono -D hw:1,0 
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
##################################################+| MAX

$ arecord -f cd -D hw:PCH,0 | aplay -V mono -D hw:PCH,0 
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
####################                             + | 97% 

arecord opens hw:0,0 for capture
aplay opens hw:0,0 for playback
Both processes have the the same device open simultaneously in "exclusive mode".

The active meter indicates that the full duplex works and audio data is actively flowing through the pipeline in real-time.

Thus, two applications, arecord and aplay, have exclusive access to the same device simultaneously. It works with Intel HDA codecs, USB soundcards, etc.

OSS4 with software mixer vmix disabled does not support "exclusive full duplex" for Intel HDA codecs

$ ./fulldup

Using audio engine 0=HD Audio play front for duplex

/dev/dsp doesn't support one device based full duplex scheme
Please use the two device scheme.

$ file /dev/dsp
/dev/dsp: symbolic link to /dev/oss/oss_hdaudio0/pcm0 

ALSA is more advanced in this sense. In advanced Monty Python reality, the word exclusive has a flexible meaning. It may mean anything you want.

Offline

Board footer