JuliaAudio / PortAudio.jl

PortAudio wrapper for the Julia programming language, compatible with the JuliaAudio family of packages
Other
115 stars 19 forks source link

Using PortAudio gives errors in precompilation while works in REPL #103

Open omlins opened 2 years ago

omlins commented 2 years ago

In the REPL, using PortAudio and creating a stream work just fine and also the available devices seem to have been recognized without problems:

julia> using PortAudio

julia> PortAudioStream(1, 0; eltype=Int16, samplerate=44100.0, latency=0.001)
PortAudioStream{Int16}
  Samplerate: 44100.0Hz
  1 channel source: "default"

julia> PortAudio.devices()
22-element Vector{PortAudio.PortAudioDevice}:
 "C-Media USB Audio Device: - (hw:0,0)" 1→0
 "HDA Intel PCH: ALC285 Analog (hw:2,0)" 2→2
 "HDA Intel PCH: HDMI 0 (hw:2,3)" 0→8
 "HDA Intel PCH: HDMI 1 (hw:2,7)" 0→8
 "HDA Intel PCH: HDMI 2 (hw:2,8)" 0→8
 "HDA Intel PCH: HDMI 3 (hw:2,9)" 0→8
 "HDA Intel PCH: HDMI 4 (hw:2,10)" 0→8
 "HDA NVidia: HDMI 0 (hw:3,3)" 0→2
 "HDA NVidia: HDMI 1 (hw:3,7)" 0→8
 "HDA NVidia: HDMI 2 (hw:3,8)" 0→8
 ⋮
 "HDA NVidia: HDMI 6 (hw:3,12)" 0→8
 "sysdefault" 128→0
 "spdif" 1→0
 "samplerate" 128→0
 "speexrate" 128→0
 "pulse" 32→32
 "upmix" 8→0
 "vdownmix" 6→0
 "default" 32→32

However, when I add using PortAudio (and nothing else!) to a package, then it this package gives many errors in precompilation:

julia> using JustSayIt
[ Info: Precompiling JustSayIt [dc137d0a-f97d-424e-bedb-455a3ba6ee67]
ALSA lib pcm_dmix.c:1035:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.hdmi.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM hdmi
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.modem.0:CARD=0'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=0,DEV=0
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.modem.0:CARD=0'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=0,DEV=0
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.modem.0:CARD=0'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM phoneline
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.modem.0:CARD=0'
ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM phoneline
ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_jack.so (/home/omlins/.julia/artifacts/d587f48a6815c72dec4b083bf297caec7a8e3f4b/lib/alsa-lib/libasound_module_pcm_jack.so: cannot open shared object file: No such file or directory)
ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_jack.so (/home/omlins/.julia/artifacts/d587f48a6815c72dec4b083bf297caec7a8e3f4b/lib/alsa-lib/libasound_module_pcm_jack.so: cannot open shared object file: No such file or directory)
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1035:(snd_pcm_dmix_open) unable to open slave

Thus, I wonder: should PortAudio.jl move some of these initializations from precompilation time to module load time (__init__())?

NOTE: OS info:

omlins@Omlin-Lenovo:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
bramtayl commented 2 years ago

Hi, thanks for the report. Those aren't errors per say, just ALSA messages about alsa trying to figure out your sound setup. We redirect them to the debug log during __init__. Ref https://github.com/JuliaAudio/PortAudio.jl/blob/f6cd300ec8716853fd41043da2232d42c680baee/src/PortAudio.jl#L111 . It seems that's not working in some circumstances, but I'm not sure why.

omlins commented 2 years ago

@bramtayl, thanks a lot for your reply. I see - I also found the related issues on PortAudio... Might it be that https://github.com/JuliaAudio/PortAudio.jl/blob/f6cd300ec8716853fd41043da2232d42c680baee/src/PortAudio.jl#L20 does already initialize some ALSA stuff and cause these error messages?

bramtayl commented 2 years ago

Hmm, no I don't think so. I'm guessing the issue is Pkg and error capturing don't work well together.