I have an LXC container configured, which contains a Debian Buster 18. The container runs on a QNAP NAS (Intel 64 bit 8 GB RAM). The QNAP firmware is of course based on Linux.
I plugged a USB audio dongle to the USB port, which I would like to be a sound card for Debian installed in a container.
Unfortunately, neither ALSA nor PulseAudio can see this card, although the USB subsystem recognizes the dongle correctly. Below appropriate outputs. They are identical both when run from the NAS itself and from a container.
root@Debian:~# cat /proc/asound/cards
0 [PCH ]: HDA-Intel - HDA Intel PCH HDA Intel PCH at 0x81810000 irq 130
1 [Device ]: USB-Audio - USB Audio Device GeneralPlus USB Audio Device at usb-0000:00:14.0-1, full speed
root@Debian:~# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
What can I do to make USB audio dongle available for Debian in container?
ALSA is the audio subsystem in the Linux kernel. If you want to use this sound card, then the host’s Linux kernel (i.e. ALSA) should be able to make sense of it.
[~] # lsmod 2>&1|grep snd
snd_usb_caiaq 53248 0
snd_usb_audio 188416 2
snd_usbmidi_lib 28672 1 snd_usb_audio
snd_seq_midi 16384 0
snd_rawmidi 32768 3 snd_usb_caiaq,snd_usbmidi_lib,snd_seq_midi
[~] # aplay -l
**** List of PLAYBACK Hardware Devices ****
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL hw:0
aplay: device_list:277: control open (0): No such file or directory
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL hw:1
aplay: device_list:277: control open (1): No such file or directory
UPDATE
Using FFMPEG on host:
# ffmpeg -sources alsa
Auto-detected sources for alsa:
null [Discard all samples (playback) or generate zero samples (capture)]
default:CARD=PCH [Default Audio Device]
sysdefault:CARD=PCH [Default Audio Device]
front:CARD=PCH,DEV=0 [Front speakers]
default:CARD=Device [Default Audio Device]
sysdefault:CARD=Device [Default Audio Device]
front:CARD=Device,DEV=0 [Front speakers]
surround21:CARD=Device,DEV=0 [2.1 Surround output to Front and Subwoofer speakers]
surround40:CARD=Device,DEV=0 [4.0 Surround output to Front and Rear speakers]
surround41:CARD=Device,DEV=0 [4.1 Surround output to Front, Rear and Subwoofer speakers]
surround50:CARD=Device,DEV=0 [5.0 Surround output to Front, Center and Rear speakers]
surround51:CARD=Device,DEV=0 [5.1 Surround output to Front, Center, Rear and Subwoofer speakers]
surround71:CARD=Device,DEV=0 [7.1 Surround output to Front, Center, Side, Rear and Woofer speakers]
iec958:CARD=Device,DEV=0 [IEC958 (S/PDIF) Digital Audio Output]
I can not disable ALSA on host. It is always used by HDstation (native app from QNAP) for play sound via HDMI on TV. So as I can see, the only solution is to run my application (streaming radio station from internet) on host, not in container
I not really sure that ALSA libs are complete on QNAP. Probably not. But I had similar problems with other libraries. Copying them from Debian has always helped.
Nevertheless ALSA itself works on host:
[~] # cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k4.14.24-qnap.
Pulseaudio probably too. But it looks like an absence of lib module:
[/etc] # aplay -L
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL hw:0
[/etc] # aplay -l
**** List of PLAYBACK Hardware Devices ****
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL hw:0
aplay: device_list:277: control open (0): No such file or directory
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL hw:1
aplay: device_list:277: control open (1): No such file or directory