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__()
|
||||
# initialize PortAudio on module load
|
||||
swallow_stderr() do
|
||||
Pa_Initialize()
|
||||
end
|
||||
|
||||
# the portaudio callbacks are parametric on the sample type
|
||||
global const pa_callbacks = Dict{Type, Ptr{Void}}()
|
||||
|
@ -118,8 +120,10 @@ type PortAudioStream{T, U}
|
|||
end
|
||||
this.bufinfo = CallbackInfo(inchans, this.source.ringbuf,
|
||||
outchans, this.sink.ringbuf, synced)
|
||||
this.stream = Pa_OpenStream(inparams, outparams, float(sr), blocksize,
|
||||
this.stream = swallow_stderr() do
|
||||
Pa_OpenStream(inparams, outparams, float(sr), blocksize,
|
||||
paNoFlag, pa_callbacks[T], fieldptr(this, :bufinfo))
|
||||
end
|
||||
|
||||
Pa_StartStream(this.stream)
|
||||
|
||||
|
@ -333,6 +337,18 @@ function portaudio_callback{T}(inptr::Ptr{T}, outptr::Ptr{T},
|
|||
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},
|
||||
(Ptr{Void}, Cint, Csize_t),
|
||||
buf, val, count)
|
||||
|
|
Loading…
Reference in a new issue