On my MacBook (Sonoma 14.6.1), I've got a Python script that uses [pyaudio](https://people.csail.mit.edu/hubert/pyaudio/) (which uses portaudio) to play audio files through my speaker. The script works just fine. However, for reasons, I'd like to run the script inside of a Docker container (Ubuntu 22.04). When I run my script that way, I get
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_id returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM dmix
I'm guessing this has something to do with the container being unable to locate the audio device. Is there an option I can pass to docker run
to mount the device?
UPDATE:
I followed the instructions given in [this SO answer](https://stackoverflow.com/a/50939994/8075540) but still received no sound output. I did, however, see some logs from the pulseaudio
daemon:
AVAudioSession_MacOS.mm:2356 --> setPlayState Started Output {410C0FC2-0000-0000-0A22-010380462778, 0xa}
AVAudioSession_MacOS.mm:2379 Devices are same: =0. Previous: {()}. Current: {("410C0FC2-0000-0000-0A22-010380462778")}
AVAudioSession_MacOS.mm:981 Sent updated IOState to server: [0, 1]. BT device UIDS: {()}
AVAudioSession_MacOS.mm:2397 setPlayState Stopped Output {410C0FC2-0000-0000-0A22-010380462778, 0xa}
AVAudioSession_MacOS.mm:2379 Devices are same: =0. Previous: {("410C0FC2-0000-0000-0A22-010380462778")}. Current: {()}
AVAudioSession_MacOS.mm:981 Sent updated IOState to server: [0, 0]. BT device UIDS: {()}
AVAudioSession_MacOS.mm:2397 <-- setPlayState Server update was required.
I tried playing a .wav file from the container with paplay
. The command succeeded (and took the right amount of time for the length of the .wav file) but there was no output. The corresponding pulseaudio logs were
I: [] client.c: Created 0 "Native client (TCP/IP client from 127.0.0.1:52371)"
I: [] sink-input.c: Trying to change sample spec
I: [] remap.c: Using mono to stereo remapping
I: [] speex.c: Choosing speex quality setting 1.
I: [] sink-input.c: Created input 0 "sample-1728359287.wav" on Channel_1__Channel_2 with sample spec s16le 1ch 44100Hz and channel map mono
I: [] sink-input.c: media.format = "WAV (Microsoft)"
I: [] sink-input.c: application.name = "paplay"
I: [] sink-input.c: media.name = "sample-1728359287.wav"
I: [] sink-input.c: native-protocol.peer = "TCP/IP client from 127.0.0.1:52371"
I: [] sink-input.c: native-protocol.version = "35"
I: [] sink-input.c: application.process.id = "40"
I: [] sink-input.c: application.process.user = "user"
I: [] sink-input.c: application.process.host = "02a5f943ef9c"
I: [] sink-input.c: application.process.binary = "pacat"
I: [] sink-input.c: application.language = "C"
I: [] sink-input.c: application.process.machine_id = "02a5f943ef9c"
I: [] sink-input.c: module-stream-restore.id = "sink-input-by-application-name:paplay"
I: [] protocol-native.c: Requested tlength=2000.00 ms, minreq=20.00 ms
I: [] protocol-native.c: Final latency 2250.00 ms = 1960.00 ms + 2*20.00 ms + 250.00 ms
I: [] sink-input.c: Freeing input 0 "sample-1728359287.wav"
I: [] client.c: Freed 0 "paplay"
I: [] protocol-native.c: Connection died.
Asked by Daniel Walker
(479 rep)
Oct 7, 2024, 03:09 PM
Last activity: Oct 8, 2024, 04:04 AM
Last activity: Oct 8, 2024, 04:04 AM