OpenWrt Forum Archive

Topic: OpenWRT + ALSA + USB Audio multichannel

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello!
I have a problem, not first day struggling with her to find a solution.

What I'm trying to do: Create Firmware for Dlink DIR-320, which supports connection and simultaneous operation of multiple USB soundcards. Under the simultaneous operation implied the possibility of capturing sound with a few USB Audio simultaneously.

I managed to do:
Collect custom firmware based on OpenWRT backfire 10.03.1 RC6, kernel 2.6.32.27, which includes core modules:
-Kmod_usb_audio,
-Kmod_sound_core,
-Kmod-usb-core,
-Kmod-usb-ohci,
-Kmod-usb2,
-Alsa-lib,
-Alsa-utils.
This firmware allows you to define the USB Audio device connected to the DIR-320
Command type: cat / proc / asound / cards lists the specific sound system:
0 [default]: USB-Audio - Generic USB Audio Device
        Generic USB Audio Device at usb-ssb0 :1-1 .2, full speed
1 [default_1]: USB-Audio - Generic USB Audio Device
        Generic USB Audio Device at usb-ssb0 :1-1 .4.3, full speed
2 [default_2]: USB-Audio - C-Media USB Headphone Set
        C-Media USB Headphone Set at usb-ssb0 :1-1 .4.4, full speed

Supposed to capture the sound using ALSA API. Command arecord, included in the package alsa-utils, effortless execution of capturing audio from a sound card - the one that is installed by default.
Command arecord -fS16_LE -Dhw:0,0 123.wav
starts capturing of the 0-th sound card. An attempt to perform a similar operation on any sound card, clearly indicating the hw: 1,0 or hw: 2,0 - results in an error: arecord: main: 660: audio open error: No such file or directory.

That I did, I could not get to write the sound from USB Audio hw: 1,0 and hw: 2,0.
But when accessing via \ dev \ audio, \ dev \ audio2 - access to various USB Audio is carried out without problems, but this is unacceptable to me - must be through ALSA.
What should I do to be able to access (record / playback audio) with all USB sound cards?

The command cat / proc / asound / version gives the following:
Advanced Linux Sound Architecture Driver Version 1.0.21.

You may need to update the ALSA-driver? But how can this be done in OpenWRT?
Alsa-Lib version of my build: 1.0.24.1-1

Tell me, what to do? Must be able to capture audio through ALSA along with several USB Audio devices.


--------------------------------------------------------------------------------------------------
By Russian:


????????????!
???????? ????????, ??????? ???? ????? ? ??? ? ??????? ???????.

??? ? ??????? ???????: ??????? ???????? ??? Dlink DIR-320, ??????? ???????????? ??????????? ? ????????????? ?????? ?????????? USB ???????? ????. ??? ????????????? ??????? ??????????????? ??????????? ????????? (captute) ????? ? ?????????? USB Audio ????????????.

??? ??? ??????? ???????:
??????? ????????? ???????? OpenWRT ?? ???? backfire 10.03.1 RC6, ???? 2.6.32.27, ? ??????? ???????? ?????? ????:
-kmod_usb_audio,
-kmod_sound_core,
-kmod-usb-core,
-kmod-usb-ohci,     
-kmod-usb2,     
-alsa-lib,     
-alsa-utils.
??? ???????? ????????? ?????????? USB Audio ?????????? ???????????? ? DIR-320
??????? ????: cat /proc/asound/cards ?????? ?????? ???????? ???????????? ????????:

0 [default ]: USB-Audio - Generic USB Audio Device
        Generic USB Audio Device at usb-ssb0:1-1.2, full speed
1 [default_1 ]: USB-Audio - Generic USB Audio Device
        Generic USB Audio Device at usb-ssb0:1-1.4.3, full speed
2 [default_2 ]: USB-Audio - C-Media USB Headphone Set
        C-Media USB Headphone Set at usb-ssb0:1-1.4.4, full speed

???????????? ?????? ????? ?????????????? ? ?????????????? ALSA API. ??????? arecord, ???????? ? ????? alsa-utils, ??? ??????? ????????? ????????? ????? ? ????? ???????? ????? - ??? ??????? ??????????? ?? ?????????. ???????
arecord -fS16_LE -Dhw:0,0 123.wav
????????? ????????? ? 0-? ???????? ?????.????????? ???????????? ??? ???????. ??????? ????????? ??????????? ???????? ?? ????? ?????? ???????? ?????, ???? ?????? hw:1,0 ??? hw:2,0 - ???????? ? ??????: arecord: main:660: audio open error: No such file or directory.

???????? ?????? ? ?????? ?? ????????? ?????? ? ???????? hw:1,0  ? hw:2,0. ?????? ??? ????????? ????? \dev\audio, \dev\audio2 - ?????? ? ?????? ?????????? ?????????????? ??? ???????, ?? ????? ??????? ??? ???? ???? ???????? - ???? ????? ALSA.
??? ???? ???????, ????? ????? ??????????? ?????????? (??????????/?????????????? ????) ?? ???? USB ???????? ???? ?

??????? cat /proc/asound/version ?????? ?????????:
Advanced Linux Sound Architecture Driver Version 1.0.21.


????????, ?????????? ???????? ALSA-??????? ? ?? ??? ??? ??????? ? ?????? OpenWRT ?
?????? Alsa-Lib ? ???? ??????: 1.0.24.1-1

??????????, ??? ??????? ?????????? ???????? ??????????? ??????????? ????? ALSA ???????????? ? ?????????? USB Audio ?????????.

show your "cat /proc/asound/modules"

ratbug wrote:

show your "cat /proc/asound/modules"

The file 'modules' does not exist. After entering the command, the system reports:
cat: can't open '/proc/asound/modules': No such file or directory

After entering  command ls /proc/asound, the system reports:
card0      card2      default    default_2  hwdep      pcm        timers
card1      cards      default_1  devices    oss        seq        version

root@OpenWrt:~# cat /proc/asound/pcm
00-00: USB Audio : USB Audio : playback 1 : capture 1
01-00: USB Audio : USB Audio : playback 1 : capture 1
02-00: USB Audio : USB Audio : playback 1 : capture 1

one more command "arecord --list-devices"

ratbug wrote:

one more command "arecord --list-devices"

root@OpenWrt:~# arecord --list-devices

**** List of CAPTURE Hardware Devices ****
card 0: default [Generic USB Audio Device   ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: default_1 [Generic USB Audio Device   ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: default_2 [C-Media USB Headphone Set  ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Use this command instead

arecord -fS16_LE -Dplughw:0,0 123.wav
arecord -fS16_LE -Dplughw:1,0 1234.wav
arecord -fS16_LE -Dplughw:2,0 12345.wav
arecord -fS16_LE -Dplughw:0,0 123.wav

root@OpenWrt:~# arecord -fS16_LE -Dplughw:0,0 123.wav
Recording WAVE '123.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono

That's OK !

arecord -fS16_LE -Dplughw:1,0 1234.wav

root@OpenWrt:~# arecord -fS16_LE -Dplughw:1,0 1234.wav
arecord: main:660: audio open error: No such file or directory

((

arecord -fS16_LE -Dplughw:2,0 12345.wav

root@OpenWrt:~# arecord -fS16_LE -Dplughw:2,0 12345.wav
arecord: main:660: audio open error: No such file or directory

(((

arecord is not able to find hw:1,0 and hw:2,0.
You should have a  /proc/asound/modules with entry for each device, loaded by the kernel.
0 snd_usb_audio
1 snd_usb_audio

Do you have a *-usb-audio file in /etc/modules.d?

ratbug wrote:

arecord is not able to find hw:1,0 and hw:2,0.
You should have a  /proc/asound/modules with entry for each device, loaded by the kernel.
0 snd_usb_audio
1 snd_usb_audio

Do you have a *-usb-audio file in /etc/modules.d?

File *-usb-audio in /etc/modules.d is exist an named as 60-usb-audio.

Some commands reports:
root@OpenWrt:~# ls /etc/modules.d
01-crypto-core    20-switch         40-ipt-core       50-usb-uhci
09-crypto-aes     20-usb-core       40-pppoe          60-input-evdev
09-crypto-arc4    21-mac80211       40-usb2           60-usb-audio
19-input-core     30-b43            41-ipt-conntrack  61-hid
20-cfg80211       30-b43legacy      42-ipt-nat        70-usb-hid
20-crc-ccitt      30-ppp            45-ipt-nathelper
20-nls-base       30-sound-core     50-usb-ohci

root@OpenWrt:~# cat /etc/modules.d/60-usb-audio
snd-usb-lib
snd-usb-audio

root@OpenWrt:~# cat /etc/modules.d/30-sound-core
soundcore
snd
snd-page-alloc
snd-hwdep
snd-seq-device
snd-rawmidi
snd-timer
snd-pcm
snd-mixer-oss
snd-pcm-oss


The file /proc/asound/modules not exist and i can not make it.

What should I do next ?

KolyanV,

can you confirm if you have CONFIG_USB_EHCI_TT_NEWSCHED=y in your kernel config?
I am guessing it probably related to this bug.
See https://dev.openwrt.org/ticket/7910

ratbug wrote:

KolyanV,

can you confirm if you have CONFIG_USB_EHCI_TT_NEWSCHED=y in your kernel config?
I am guessing it probably related to this bug.
See https://dev.openwrt.org/ticket/7910

1. I rebuild kernel with default options. After this, file /proc/asound/modules is exist.
Command cat /proc/asound/modules has reports:

root@OpenWrt:~# cat /proc/asound/modules
 0 snd_usb_audio
 1 snd_usb_audio
 2 snd_usb_audio

All other files (pcm, cards, ...) remained the same.
But, arecord with hw:1,0 and hw:2,0, as before, reported error:  arecord: main:660: audio open error: No such file or directory

2. Today, all day, i rebuild OpenWRT kernel with different kernel options.
I tried build kernel with different options combinations:

2.1
- CONFIG_USB_EHCI_TT_NEWSCHED=y

2.2
- CONFIG_USB_EHCI_TT_NEWSCHED=y
- USB_EHCI_ROOT_HUB_TT=y

2.3
- CONFIG_USB_EHCI_TT_NEWSCHED=n
- USB_EHCI_ROOT_HUB_TT=n

2.4
- CONFIG_USB_EHCI_TT_NEWSCHED=y
- USB_EHCI_ROOT_HUB_TT=n

2.5
- CONFIG_USB_EHCI_TT_NEWSCHED=n
- USB_EHCI_ROOT_HUB_TT=y

But, not in one case, i don't recieved expected result. Always, when trying to execute command arecord with hw:1,0 and hw:2,0, i receive error message: arecord: main:660: audio open error: No such file or directory.

(((

your cat /proc/asound/modules looks ok now.
Can you show " lsmod | grep snd" , ls /dev/dsp*
Remenber to use plughw instead

ratbug wrote:

your cat /proc/asound/modules looks ok now.
Can you show " lsmod | grep snd" , ls /dev/dsp*
Remenber to use plughw instead

root@OpenWrt:/# lsmod | grep snd
snd_usb_audio          60096  0
snd_usb_lib            13424  1 snd_usb_audio
snd_pcm_oss            36896  0
snd_mixer_oss          13424  1 snd_pcm_oss
snd_pcm                52480  2 snd_usb_audio,snd_pcm_oss
snd_timer              15632  1 snd_pcm
snd_rawmidi            16000  1 snd_usb_lib
snd_seq_device          4080  1 snd_rawmidi
snd_hwdep               4496  1 snd_usb_audio
snd_page_alloc          4320  1 snd_pcm
snd                    35312  8 snd_usb_audio,snd_pcm_oss,snd_mixer_oss,snd_pcm,
snd_timer,snd_rawmidi,snd_seq_device,snd_hwdep
soundcore               4016  1 snd


root@OpenWrt:/# ls /dev/dsp*
/dev/dsp   /dev/dsp1  /dev/dsp2

If execute command 'cat /dev/dsp' - into console displays data from USB Audio index 0, - the LED of soundcard #0 blinks
If execute command 'cat /dev/dsp1' - into console displays data from USB Audio index 1, - the LED of soundcard #1 blinks
If execute command 'cat /dev/dsp2' - into console displays data from USB Audio index 2, - the LED of soundcard #2 blinks

can you test one (card) at a time, says for example: card 1

arecord -fS16_LE -Dplughw:1,0 1234.wav.

Can you show the ouput for: opkg list_installed | grep alsa?

ratbug wrote:

can you test one (card) at a time, says for example: card 1

arecord -fS16_LE -Dplughw:1,0 1234.wav.

Can you show the ouput for: opkg list_installed | grep alsa?

root@OpenWrt:~# arecord -fS16_LE -Dplughw:0,0 1234.wav.
Recording WAVE '1234.wav.' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono

Ok!

root@OpenWrt:~# arecord -fS16_LE -Dplughw:1,0 12345.wav
arecord: main:660: audio open error: No such file or directory

Error

root@OpenWrt:~# arecord -fS16_LE -Dplughw:2,0 123456.wav
arecord: main:660: audio open error: No such file or directory

Error

root@OpenWrt:~# cat /proc/asound/cards
 0 [default        ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.2, full speed
 1 [default_1      ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.4.3, full speed
 2 [default_2      ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set   at usb-ssb0:1-1.4.4, full speed
root@OpenWrt:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: default [Generic USB Audio Device   ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: default_1 [Generic USB Audio Device   ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: default_2 [C-Media USB Headphone Set  ], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@OpenWrt:~# opkg list_installed | grep alsa
alsa-lib - 1.0.24.1-1
alsa-utils - 1.0.24.2-1
root@OpenWrt:~# opkg list_installed
alsa-lib - 1.0.24.1-1
alsa-utils - 1.0.24.2-1
base-files - 43.25-r27794
busybox - 1.15.3-2
crda - 1.1.1-1
dnsmasq - 2.55-6
dropbear - 0.52-4
firewall - 2-26
hotplug2 - 1.0-beta-3
iptables - 1.4.6-3
iptables-mod-conntrack - 1.4.6-3
iptables-mod-nat - 1.4.6-3
iw - 0.9.22-2
kernel - 2.6.32.27-1
kmod-b43 - 2.6.32.27+2011-06-22-2
kmod-b43legacy - 2.6.32.27+2011-06-22-2
kmod-cfg80211 - 2.6.32.27+2011-06-22-2
kmod-crc-ccitt - 2.6.32.27-1
kmod-crypto-aes - 2.6.32.27-1
kmod-crypto-arc4 - 2.6.32.27-1
kmod-crypto-core - 2.6.32.27-1
kmod-diag - 2.6.32.27-7.1
kmod-hid - 2.6.32.27-1
kmod-input-core - 2.6.32.27-1
kmod-input-evdev - 2.6.32.27-1
kmod-ipt-conntrack - 2.6.32.27-1
kmod-ipt-core - 2.6.32.27-1
kmod-ipt-nat - 2.6.32.27-1
kmod-ipt-nathelper - 2.6.32.27-1
kmod-mac80211 - 2.6.32.27+2011-06-22-2
kmod-ppp - 2.6.32.27-1
kmod-pppoe - 2.6.32.27-1
kmod-sound-core - 2.6.32.27-1
kmod-switch - 2.6.32.27-4
kmod-usb-audio - 2.6.32.27-1
kmod-usb-hid - 2.6.32.27-1
kmod-usb-ohci - 2.6.32.27-1
kmod-usb-uhci - 2.6.32.27-1
kmod-usb2 - 2.6.32.27-1
libc - 0.9.30.1-43.25
libgcc - 4.3.3+cs-43.25
libip4tc - 1.4.6-3
libiwinfo - 15
liblua - 5.1.4-7
libncurses - 5.7-2
libnl-tiny - 0.1-1
libpthread - 0.9.30.1-43.25
librt - 0.9.30.1-43.25
libuci - 12012009.6-4
libuci-lua - 12012009.6-4
libxtables - 1.4.6-3
lua - 5.1.4-7
luci - 0.10+svn7335-1
luci-app-firewall - 0.10+svn7335-1
luci-i18n-english - 0.10+svn7335-1
luci-lib-core - 0.10+svn7335-1
luci-lib-ipkg - 0.10+svn7335-1
luci-lib-lmo - 0.10+svn7335-1
luci-lib-nixio - 0.10+svn7335-1
luci-lib-sys - 0.10+svn7335-1
luci-lib-web - 0.10+svn7335-1
luci-mod-admin-core - 0.10+svn7335-1
luci-mod-admin-full - 0.10+svn7335-1
luci-sgi-cgi - 0.10+svn7335-1
luci-theme-base - 0.10+svn7335-1
luci-theme-openwrt - 0.10+svn7335-1
mtd - 13
nvram - 7
opkg - 576-1
ppp - 2.4.4-16
ppp-mod-pppoe - 2.4.4-16
uci - 12012009.6-4
udevtrigger - 106-1
uhttpd - 23
wireless-tools - 29-4
wpad-mini - 20110527-1

No, 1 card at a time.
Output of arecord card 1 without running card 0 and card 2.
Then output of card 2 without card 1 card 0

ratbug wrote:

No, 1 card at a time.
Output of arecord card 1 without running card 0 and card 2.
Then output of card 2 without card 1 card 0

Started configuration:

root@OpenWrt:~# cat /proc/asound/cards
 0 [default        ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set   at usb-ssb0:1-1.4.4, full speed
 1 [default_1      ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.2, full speed
 2 [default_2      ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.4.3, full speed

After excluding cards #1 and #2

root@OpenWrt:~# cat /proc/asound/cards
 0 [default        ]: USB-Audio - C-Media USB Headphone Set
                      C-Media USB Headphone Set   at usb-ssb0:1-1.4.4, full speed

Executing command:

root@OpenWrt:~# arecord -Dplughw:0,0 file.wav
Recording WAVE 'file.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono

OK!

After inserting cards #1 and #2, next excluding cards #0 and #2

root@OpenWrt:~# cat /proc/asound/cards
 1 [default_1      ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.4.3, full speed

Executing commands:

root@OpenWrt:~# arecord -Dplughw:0,0 file.wav
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
arecord: main:660: audio open error: No such file or directory

root@OpenWrt:~# arecord -Dplughw:1,0 file.wav
arecord: main:660: audio open error: No such file or directory

root@OpenWrt:~# arecord -Dplughw:2,0 file.wav
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
arecord: main:660: audio open error: No such file or directory

After inserting cards #0 and #2, next excludings cards #0 and #1

root@OpenWrt:~# cat /proc/asound/cards
 2 [default_2      ]: USB-Audio - Generic USB Audio Device
                      Generic USB Audio Device    at usb-ssb0:1-1.2, full speed

Executing commands:

root@OpenWrt:~# arecord -Dplughw:0,0 file.wav
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
arecord: main:660: audio open error: No such file or directory

root@OpenWrt:~# arecord -Dplughw:1,0 file.wav
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) Invalid value for card
arecord: main:660: audio open error: No such file or directory

root@OpenWrt:~# arecord -Dplughw:2,0 file.wav
arecord: main:660: audio open error: No such file or directory

Obviously, the behavior of soundcards has not changed

What I am asking is output of just one card, in our case card 1:

arecord -Dplughw:1,0 122345.wav.

Do not run "arecord -Dplughw:0,0 file.wav"

Do not run "arecord -Dplughw:2,0 file.wav"

at the same time

ratbug wrote:

What I am asking is output of just one card, in our case card 1:

arecord -Dplughw:1,0 122345.wav.

Do not run "arecord -Dplughw:0,0 file.wav"

Do not run "arecord -Dplughw:2,0 file.wav"

at the same time

Ok!

only card 1 inserted:

root@OpenWrt:~# arecord -Dplughw:1,0 122.wav
arecord: main:660: audio open error: No such file or directory

if only card 2 instered:

root@OpenWrt:~# arecord -Dplughw:2,0 12233.wav
arecord: main:660: audio open error: No such file or directory

But, if inserted only card 0 - that's Ok

root@OpenWrt:~# arecord -Dplughw:0,0 1223344.wav
Recording WAVE '1223344.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono

My question to you is with all usb cards inserted, can you just run what I asked you on post #18.
Output of
arecord -Dplughw:1,0 122345.wav.

ratbug wrote:

My question to you is with all usb cards inserted, can you just run what I asked you on post #18.
Output of
arecord -Dplughw:1,0 122345.wav.

When all cards inserted, result is similar.
It has been written previously on some examples

root@OpenWrt:~# arecord -Dplughw:1,0 122345.wav
arecord: main:660: audio open error: No such file or directory

For the first time, I have a clear clue as to whether that could cause glitch ...

Now to USB hub connected 5 USB souncards.

root@OpenWrt:~# ls /dev/snd
controlC0  controlC2  controlC4  pcmC0D0p
controlC1  controlC3  pcmC0D0c   timer
root@OpenWrt:~# ls /dev/pcm*
/dev/pcmC1D0c  /dev/pcmC2D0c  /dev/pcmC3D0c  /dev/pcmC4D0c
/dev/pcmC1D0p  /dev/pcmC2D0p  /dev/pcmC3D0p  /dev/pcmC4D0p

My suspicions were justified !!!

I changed source of Alsa-Lib and changed in pcm_hw.c path for device from /dev/snd to /dev.
At result, now, i can record from all Usb Audio except hw:0,0. All other devices - hw:1,0   hw:2,0   hw:3,0 ... work fine.

Hello
Very useful post
I could install 2 usb sounds card, with the same proble problem
My solution was as follows:

ln -s /dev/pcmC1D0c /dev/snd/pcmC1D0c
ln -s /dev/pcmC1D0p /dev/snd/pcmC1D0p

and i have all cards working

The discussion might have continued from here.