From 864f35db75194bee619a70698200291512f9b496 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Sun, 27 Jul 2014 13:51:02 -0400 Subject: [PATCH] Fixes to work with BinDeps/Homebrew properly --- src/AudioIO.jl | 2 ++ src/portaudio.jl | 10 +++++----- src/sndfile.jl | 24 +++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/AudioIO.jl b/src/AudioIO.jl index 17f4abb..8b423bb 100644 --- a/src/AudioIO.jl +++ b/src/AudioIO.jl @@ -54,6 +54,8 @@ function render(node::AudioNode, input::AudioBuf, info::DeviceInfo) end end +# Get binary dependencies loaded from BinDeps +include( "../deps/deps.jl") include("nodes.jl") include("portaudio.jl") include("sndfile.jl") diff --git a/src/portaudio.jl b/src/portaudio.jl index 8c64788..7387f7e 100644 --- a/src/portaudio.jl +++ b/src/portaudio.jl @@ -77,7 +77,7 @@ end function handle_status(err::PaError) if err != PA_NO_ERROR - msg = ccall((:Pa_GetErrorText, "libportaudio"), + msg = ccall((:Pa_GetErrorText, libportaudio), Ptr{Cchar}, (PaError,), err) error("libportaudio: " * bytestring(msg)) end @@ -151,14 +151,14 @@ type PortAudioInterface <: AudioInterface end # some thin wrappers to portaudio calls -get_device_info(i) = unsafe_load(ccall((:Pa_GetDeviceInfo, "libportaudio"), +get_device_info(i) = unsafe_load(ccall((:Pa_GetDeviceInfo, libportaudio), Ptr{PaDeviceInfo}, (PaDeviceIndex,), i)) -get_host_api_info(i) = unsafe_load(ccall((:Pa_GetHostApiInfo, "libportaudio"), +get_host_api_info(i) = unsafe_load(ccall((:Pa_GetHostApiInfo, libportaudio), Ptr{PaHostApiInfo}, (PaHostApiIndex,), i)) function get_portaudio_devices() init_portaudio() - device_count = ccall((:Pa_GetDeviceCount, "libportaudio"), PaDeviceIndex, ()) + device_count = ccall((:Pa_GetDeviceCount, libportaudio), PaDeviceIndex, ()) pa_devices = [get_device_info(i) for i in 0:(device_count - 1)] [PortAudioInterface(bytestring(d.name), bytestring(get_host_api_info(d.host_api).name), @@ -174,7 +174,7 @@ function init_portaudio() @assert(libportaudio_shim != "", "Failed to find required library libportaudio_shim. Try re-running the package script using Pkg.build(\"AudioIO\"), then reloading with reload(\"AudioIO\")") info("Initializing PortAudio. Expect errors as we scan devices") - err = ccall((:Pa_Initialize, "libportaudio"), PaError, ()) + err = ccall((:Pa_Initialize, libportaudio), PaError, ()) handle_status(err) portaudio_inited = true end diff --git a/src/sndfile.jl b/src/sndfile.jl index ff9adf8..7664614 100644 --- a/src/sndfile.jl +++ b/src/sndfile.jl @@ -1,7 +1,5 @@ export af_open, FilePlayer -const sndfile = "libsndfile" - const SFM_READ = int32(0x10) const SFM_WRITE = int32(0x20) @@ -59,12 +57,12 @@ function af_open(path::String, mode::String = "r", end end - filePtr = ccall((:sf_open, sndfile), Ptr{Void}, + filePtr = ccall((:sf_open, libsndfile), Ptr{Void}, (Ptr{Uint8}, Int32, Ptr{SF_INFO}), path, file_mode, &sfinfo) if filePtr == C_NULL - errmsg = ccall((:sf_strerror, sndfile), Ptr{Uint8}, (Ptr{Void},), filePtr) + errmsg = ccall((:sf_strerror, libsndfile), Ptr{Uint8}, (Ptr{Void},), filePtr) error(bytestring(errmsg)) end @@ -72,7 +70,7 @@ function af_open(path::String, mode::String = "r", end function Base.close(file::AudioFile) - err = ccall((:sf_close, sndfile), Int32, (Ptr{Void},), file.filePtr) + err = ccall((:sf_close, libsndfile), Int32, (Ptr{Void},), file.filePtr) if err != 0 error("Failed to close file") end @@ -95,19 +93,19 @@ function Base.read(file::AudioFile, nframes::Integer, dtype::Type) end if dtype == Int16 - nread = ccall((:sf_readf_short, sndfile), Int64, + nread = ccall((:sf_readf_short, libsndfile), Int64, (Ptr{Void}, Ptr{Int16}, Int64), file.filePtr, arr, nframes) elseif dtype == Int32 - nread = ccall((:sf_readf_int, sndfile), Int64, + nread = ccall((:sf_readf_int, libsndfile), Int64, (Ptr{Void}, Ptr{Int32}, Int64), file.filePtr, arr, nframes) elseif dtype == Float32 - nread = ccall((:sf_readf_float, sndfile), Int64, + nread = ccall((:sf_readf_float, libsndfile), Int64, (Ptr{Void}, Ptr{Float32}, Int64), file.filePtr, arr, nframes) elseif dtype == Float64 - nread = ccall((:sf_readf_double, sndfile), Int64, + nread = ccall((:sf_readf_double, libsndfile), Int64, (Ptr{Void}, Ptr{Float64}, Int64), file.filePtr, arr, nframes) end @@ -124,19 +122,19 @@ function Base.write{T}(file::AudioFile, frames::Array{T}) nframes = int(length(frames) / file.sfinfo.channels) if T == Int16 - return ccall((:sf_writef_short, sndfile), Int64, + return ccall((:sf_writef_short, libsndfile), Int64, (Ptr{Void}, Ptr{Int16}, Int64), file.filePtr, frames, nframes) elseif T == Int32 - return ccall((:sf_writef_int, sndfile), Int64, + return ccall((:sf_writef_int, libsndfile), Int64, (Ptr{Void}, Ptr{Int32}, Int64), file.filePtr, frames, nframes) elseif T == Float32 - return ccall((:sf_writef_float, sndfile), Int64, + return ccall((:sf_writef_float, libsndfile), Int64, (Ptr{Void}, Ptr{Float32}, Int64), file.filePtr, frames, nframes) elseif T == Float64 - return ccall((:sf_writef_double, sndfile), Int64, + return ccall((:sf_writef_double, libsndfile), Int64, (Ptr{Void}, Ptr{Float64}, Int64), file.filePtr, frames, nframes) end