Bind Ecasound to ALSA Hardware Using hw Prefix
Ecasound can directly interface with Advanced Linux Sound
Architecture (ALSA) hardware devices using the standard hw:
prefix syntax. This article explains how Ecasound integrates with ALSA
hardware, outlines the required command-line syntax for input and output
routing, and covers key considerations such as exclusive device access
and format compatibility when bypassing software mixing layers.
Direct ALSA Binding in Ecasound
Ecasound natively supports ALSA devices through its ALSA I/O object
type. By utilizing the hw: prefix, Ecasound establishes
direct communication with the sound card's hardware buffer, completely
bypassing ALSA's software mixing layer (dmix) and sample
rate conversion plugins.
To bind to an ALSA hardware device, specify the audio format type as
alsa followed by the target device string in Ecasound’s
input (-i) or output (-o) parameters.
Command Syntax
The general syntax for addressing an ALSA device directly is:
-i alsa,hw:CARD,DEVICE
-o alsa,hw:CARD,DEVICE- CARD: The index number or string identifier of the
sound card (e.g.,
0,1, or named identifiers likehw:DAC). - DEVICE: The specific subdevice number on that card
(typically
0if unspecified).
Example Usage
To route input directly from the first hardware device of the first sound card to the first hardware device of the second card:
ecasound -f:s16_le,2,44100 -i alsa,hw:0,0 -o alsa,hw:1,0You can identify available card and device numbers on your system using the standard ALSA utility:
arecord -l
aplay -lConsiderations When Using the hw Prefix
- Format Matching: Because the
hw:prefix communicates directly with the hardware without software emulation, the stream parameters (sample format, channel count, and sampling rate set via the-foption) must match the exact capabilities of your sound card. If the parameters do not match, Ecasound will exit with an initialization error. - Fallback to plughw: If hardware format conversion
is required, you can use
plughw:instead ofhw:. Theplughw:prefix still targets the physical card but allows ALSA to automatically convert sample rates and formats when necessary. - Exclusive Access: Direct hardware access requires exclusive control of the ALSA device. If another application or sound server (such as PulseAudio or PipeWire) has locked the hardware device, Ecasound will fail to open it until the resource is freed.