Search code examples
configurationdefaultalsa

ALSA: asound.conf file read but not used with arecord


I'm using ALSA to configure a mic, but after some hours of search on stackoverflow/alsa doc/other sources, I don't understand how arecord work...

I'm trying to set a default record

Signed 16 bit Little Endian, Fréquence 48000 Hz, Stéréo

The equivalent arecord CLI command is (in my case) :

arecord /tmp/test.wav -f dat -D sysdefault:CARD=1

I try to do that with /etc/asound.conf

I write this :

pcm.!default {
  type asym
  playback.pcm {
    type plug
    slave.pcm "hw:1,0"
  }
  capture.pcm "multi"
}

pcm.multi {
  type plug
  slave.pcm "multiapps"
}

pcm.multiapps {
  type dsnoop
  ipc_key 666666
  slave {
    pcm "hw:1,0"
    format "S16_LE"
    rate 48000
  }
}

ctl.!default {
  type hw
  card 1
}

But when I try a simple :

arecord /tmp/test.wav or arecord /tmp/test.wav -D default

It fails with

Capture WAVE '/tmp/test.wav' : Unsigned 8 bit, Fréquence 8000 Hz, Mono arecord: set_params:1299: Ce format d'échantillonage n'est pas disponible Available formats: - S16_LE

Just to test, I try with

arecord /tmp/test.wav -D multi

I have a half success, it works but with bad configuration

Capture WAVE '/tmp/test.wav' : Unsigned 8 bit, Fréquence 8000 Hz, Mono

Can someone explain to me what I missed ? :|

Thanks !

-- EDIT --

I realize that /etc/asound.conf is overlapped by ~/.asound.

So, I copied the first in the second.

No more fatal on default, but always in 8k/8bit...


Solution

  • Putting entries like format and rate into a slave definition restricts the possible configurations that an application can choose.

    Most applications ask the device what configurations it actually supports. However, aplay/arecord do not; they always try to use the configuration you have set with parameters (or their silly defaults).