actually, this might be nicer as a macro
This commit is contained in:
parent
08681d135d
commit
c969b8b349
1 changed files with 7 additions and 9 deletions
|
@ -95,10 +95,8 @@ mutable struct PortAudioStream{T}
|
|||
# finalizer(close, this)
|
||||
this.sink = PortAudioSink{T}(outdev.name, this, outchans)
|
||||
this.source = PortAudioSource{T}(indev.name, this, inchans)
|
||||
this.stream = suppress_err() do
|
||||
Pa_OpenStream(inparams, outparams, sr, 0, paNoFlag,
|
||||
this.stream = @stderr_as_debug Pa_OpenStream(inparams, outparams, sr, 0, paNoFlag,
|
||||
nothing, nothing)
|
||||
end
|
||||
|
||||
Pa_StartStream(this.stream)
|
||||
# pre-fill the output stream so we're less likely to underrun
|
||||
|
@ -369,9 +367,11 @@ function discard_input(source::PortAudioSource)
|
|||
end
|
||||
end
|
||||
|
||||
function suppress_err(dofunc::Function)
|
||||
debug_message = @suppress_err dofunc()
|
||||
macro stderr_as_debug(expression)
|
||||
quote
|
||||
debug_message = @capture_err $(esc(expression))
|
||||
@debug debug_message
|
||||
end
|
||||
end
|
||||
|
||||
function __init__()
|
||||
|
@ -407,9 +407,7 @@ function __init__()
|
|||
# junk to STDOUT on initialization, so we swallow it.
|
||||
# TODO: actually check the junk to make sure there's nothing in there we
|
||||
# don't expect
|
||||
suppress_err() do
|
||||
Pa_Initialize()
|
||||
end
|
||||
@stderr_as_debug Pa_Initialize()
|
||||
|
||||
atexit() do
|
||||
Pa_Terminate()
|
||||
|
|
Loading…
Reference in a new issue