From d069e75a9facd626aafd7ae3c86d9e6ff763e0d2 Mon Sep 17 00:00:00 2001 From: Spencer Russell Date: Thu, 30 Jan 2020 11:28:44 -0500 Subject: [PATCH] bumps latency for more reliable performance --- src/PortAudio.jl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/PortAudio.jl b/src/PortAudio.jl index 34d01a3..b0644e8 100644 --- a/src/PortAudio.jl +++ b/src/PortAudio.jl @@ -67,6 +67,15 @@ mutable struct PortAudioStream{T} # this inner constructor is generally called via the top-level outer # constructor below + + # TODO: handle blocksize=0, that should be the default and generally works + # much better than trying to specify + # TODO: expose latency parameter + # TODO: pre-fill outbut buffer on init + # TODO: recover from xruns - currently with low latencies (e.g. 0.01) it + # will run fine for a while and then fail with the first xrun. + # TODO: figure out whether we can get deterministic latency... + # TODO: write a latency tester app function PortAudioStream{T}(indev::PortAudioDevice, outdev::PortAudioDevice, inchans, outchans, sr, blocksize, warn_xruns) where {T} @@ -74,10 +83,10 @@ mutable struct PortAudioStream{T} outchans = outchans == -1 ? outdev.maxoutchans : outchans inparams = (inchans == 0) ? Ptr{Pa_StreamParameters}(0) : - Ref(Pa_StreamParameters(indev.idx, inchans, type_to_fmt[T], 0.0, C_NULL)) + Ref(Pa_StreamParameters(indev.idx, inchans, type_to_fmt[T], 0.1, C_NULL)) outparams = (outchans == 0) ? Ptr{Pa_StreamParameters}(0) : - Ref(Pa_StreamParameters(outdev.idx, outchans, type_to_fmt[T], 0.0, C_NULL)) + Ref(Pa_StreamParameters(outdev.idx, outchans, type_to_fmt[T], 0.1, C_NULL)) this = new(sr, blocksize, C_NULL, warn_xruns) # finalizer(close, this) this.sink = PortAudioSink{T}(outdev.name, this, outchans) @@ -199,6 +208,7 @@ end isopen(stream::PortAudioStream) = stream.stream != C_NULL SampledSignals.samplerate(stream::PortAudioStream) = stream.samplerate +SampledSignals.blocksize(stream::PortAudioStream) = stream.blocksize eltype(stream::PortAudioStream{T}) where T = T read(stream::PortAudioStream, args...) = read(stream.source, args...)