swallows STDERR to remove some spurrious warnings from PortAudio and OSX
This commit is contained in:
parent
fcf87c0c61
commit
80af028efb
1 changed files with 19 additions and 3 deletions
|
@ -26,7 +26,9 @@ const CHUNKSIZE=128
|
||||||
|
|
||||||
function __init__()
|
function __init__()
|
||||||
# initialize PortAudio on module load
|
# initialize PortAudio on module load
|
||||||
Pa_Initialize()
|
swallow_stderr() do
|
||||||
|
Pa_Initialize()
|
||||||
|
end
|
||||||
|
|
||||||
# the portaudio callbacks are parametric on the sample type
|
# the portaudio callbacks are parametric on the sample type
|
||||||
global const pa_callbacks = Dict{Type, Ptr{Void}}()
|
global const pa_callbacks = Dict{Type, Ptr{Void}}()
|
||||||
|
@ -118,8 +120,10 @@ type PortAudioStream{T, U}
|
||||||
end
|
end
|
||||||
this.bufinfo = CallbackInfo(inchans, this.source.ringbuf,
|
this.bufinfo = CallbackInfo(inchans, this.source.ringbuf,
|
||||||
outchans, this.sink.ringbuf, synced)
|
outchans, this.sink.ringbuf, synced)
|
||||||
this.stream = Pa_OpenStream(inparams, outparams, float(sr), blocksize,
|
this.stream = swallow_stderr() do
|
||||||
paNoFlag, pa_callbacks[T], fieldptr(this, :bufinfo))
|
Pa_OpenStream(inparams, outparams, float(sr), blocksize,
|
||||||
|
paNoFlag, pa_callbacks[T], fieldptr(this, :bufinfo))
|
||||||
|
end
|
||||||
|
|
||||||
Pa_StartStream(this.stream)
|
Pa_StartStream(this.stream)
|
||||||
|
|
||||||
|
@ -333,6 +337,18 @@ function portaudio_callback{T}(inptr::Ptr{T}, outptr::Ptr{T},
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
"""Call the given function and discard stdout and stderr"""
|
||||||
|
function swallow_stderr(f)
|
||||||
|
origerr = STDERR
|
||||||
|
(errread, errwrite) = redirect_stderr()
|
||||||
|
result = f()
|
||||||
|
redirect_stderr(origerr)
|
||||||
|
close(errwrite)
|
||||||
|
close(errread)
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
memset(buf, val, count) = ccall(:memset, Ptr{Void},
|
memset(buf, val, count) = ccall(:memset, Ptr{Void},
|
||||||
(Ptr{Void}, Cint, Csize_t),
|
(Ptr{Void}, Cint, Csize_t),
|
||||||
buf, val, count)
|
buf, val, count)
|
||||||
|
|
Loading…
Reference in a new issue