3.5 C
New York
Saturday, November 23, 2024

macos: Play audio from Docker container


On my MacBook (Sonoma 14.6.1), I’ve a Python script that makes use of paudio (which makes use of portaudio) to play audio recordsdata by my speaker. The script works nicely. Nevertheless, for a number of causes, I wish to run the script inside a Docker container (Ubuntu 22.04). Once I run my script that means I get

ALSA lib confmisc.c:855:(parse_card) can not discover card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_card_inum returned error: No such file or listing
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_concat returned error: No such file or listing
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating title
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_refer returned error: No such file or listing
ALSA lib conf.c:5701:(snd_config_expand) Consider error: No such file or listing
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) can not discover card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_card_inum returned error: No such file or listing
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_concat returned error: No such file or listing
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating title
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_refer returned error: No such file or listing
ALSA lib conf.c:5701:(snd_config_expand) Consider error: No such file or listing
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.entrance
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.facet
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround40
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround41
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround50
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround51
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.surround71
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.iec958
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.hdmi
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.modem
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.phoneline
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM playing cards.pcm.phoneline
ALSA lib confmisc.c:855:(parse_card) can not discover card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_card_inum returned error: No such file or listing
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_concat returned error: No such file or listing
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating title
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_refer returned error: No such file or listing
ALSA lib conf.c:5701:(snd_config_expand) Consider error: No such file or listing
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) can not discover card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_card_inum returned error: No such file or listing
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_concat returned error: No such file or listing
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating title
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_refer returned error: No such file or listing
ALSA lib conf.c:5701:(snd_config_expand) Consider error: No such file or listing
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) can not discover card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_card_id returned error: No such file or listing
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_concat returned error: No such file or listing
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating title
ALSA lib conf.c:5178:(_snd_config_evaluate) perform snd_func_refer returned error: No such file or listing
ALSA lib conf.c:5701:(snd_config_expand) Consider error: No such file or listing
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM dmix

I assume this has one thing to do with the container not with the ability to find the audio gadget. Is there an choice I can transfer on to? docker run to mount the gadget?

UPDATE:

I adopted the directions given in this SO reply however nonetheless obtained no sound output. Nevertheless, I noticed some information of the pulseaudio satan:

AVAudioSession_MacOS.mm:2356  --> setPlayState Began Output {410C0FC2-0000-0000-0A22-010380462778, 0xa}
AVAudioSession_MacOS.mm:2379  Units are identical: =0. Earlier: {()}. Present: {("410C0FC2-0000-0000-0A22-010380462778")}
AVAudioSession_MacOS.mm:981   Despatched up to date IOState to server: (0, 1). BT gadget UIDS: {()}
AVAudioSession_MacOS.mm:2397  <-- setPlayState Server replace was required.
AVAudioSession_MacOS.mm:2356  --> setPlayState Stopped Output {410C0FC2-0000-0000-0A22-010380462778, 0xa}
AVAudioSession_MacOS.mm:2379  Units are identical: =0. Earlier: {("410C0FC2-0000-0000-0A22-010380462778")}. Present: {()}
AVAudioSession_MacOS.mm:981   Despatched up to date IOState to server: (0, 0). BT gadget UIDS: {()}
AVAudioSession_MacOS.mm:2397  <-- setPlayState Server replace was required.

I attempted to play a .wav file from the container with paplay. The command succeeded (and took the suitable time for the size of the .wav file) however there have been no outcomes. The corresponding pulseaudio information have been

I: () shopper.c: Created 0 "Native shopper (TCP/IP shopper from 127.0.0.1:52371)"
I: () sink-input.c: Making an attempt to vary pattern spec
I: () remap.c: Utilizing mono to stereo remapping
I: () speex.c: Selecting speex high quality setting 1.
I: () sink-input.c: Created enter 0 "sample-1728359287.wav" on Channel_1__Channel_2 with pattern spec s16le 1ch 44100Hz and channel map mono
I: () sink-input.c:     media.format = "WAV (Microsoft)"
I: () sink-input.c:     utility.title = "paplay"
I: () sink-input.c:     media.title = "sample-1728359287.wav"
I: () sink-input.c:     native-protocol.peer = "TCP/IP shopper from 127.0.0.1:52371"
I: () sink-input.c:     native-protocol.model = "35"
I: () sink-input.c:     utility.course of.id = "40"
I: () sink-input.c:     utility.course of.person = "person"
I: () sink-input.c:     utility.course of.host = "02a5f943ef9c"
I: () sink-input.c:     utility.course of.binary = "pacat"
I: () sink-input.c:     utility.language = "C"
I: () sink-input.c:     utility.course of.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: Closing latency 2250.00 ms = 1960.00 ms + 2*20.00 ms + 250.00 ms
I: () sink-input.c: Liberating enter 0 "sample-1728359287.wav"
I: () shopper.c: Freed 0 "paplay"
I: () protocol-native.c: Connection died.

Related Articles

Latest Articles