only look for ALSA on linux systems

This commit is contained in:
Spencer Russell 2020-01-30 11:54:16 -05:00
parent 9d780e4950
commit b18b9bdcae

View file

@ -315,31 +315,33 @@ function suppress_err(dofunc::Function)
end end
function __init__() function __init__()
envkey = "ALSA_CONFIG_DIR" if Sys.islinux()
if envkey keys(ENV) envkey = "ALSA_CONFIG_DIR"
searchdirs = ["/usr/share/alsa", if envkey keys(ENV)
"/usr/local/share/alsa", searchdirs = ["/usr/share/alsa",
"/etc/alsa"] "/usr/local/share/alsa",
confdir_idx = findfirst(searchdirs) do d "/etc/alsa"]
isfile(joinpath(d, "alsa.conf")) confdir_idx = findfirst(searchdirs) do d
end isfile(joinpath(d, "alsa.conf"))
if confdir_idx === nothing end
throw(ErrorException( if confdir_idx === nothing
""" throw(ErrorException(
Could not find ALSA config directory. Searched: """
$(join(searchdirs, "\n")) Could not find ALSA config directory. Searched:
$(join(searchdirs, "\n"))
if ALSA is installed, set the "ALSA_CONFIG_DIR" environment if ALSA is installed, set the "ALSA_CONFIG_DIR" environment
variable. The given directory should have a file "alsa.conf". variable. The given directory should have a file "alsa.conf".
If it would be useful to others, please file an issue at If it would be useful to others, please file an issue at
https://github.com/JuliaAudio/PortAudio.jl/issues https://github.com/JuliaAudio/PortAudio.jl/issues
with your alsa config directory so we can add it to the search with your alsa config directory so we can add it to the search
paths. paths.
""")) """))
end
confdir = searchdirs[confdir_idx]
ENV[envkey] = confdir
end end
confdir = searchdirs[confdir_idx]
ENV[envkey] = confdir
end end
# initialize PortAudio on module load. libportaudio prints a bunch of # initialize PortAudio on module load. libportaudio prints a bunch of
# junk to STDOUT on initialization, so we swallow it. # junk to STDOUT on initialization, so we swallow it.