don't prefill empty output (#72)

This commit is contained in:
bramtayl 2021-05-21 16:12:47 -04:00 committed by GitHub
parent 5bdd8975a9
commit 0187b4937d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View file

@ -345,12 +345,14 @@ end
Fill the playback buffer of the given sink.
"""
function prefill_output(sink::PortAudioSink)
towrite = Pa_GetStreamWriteAvailable(sink.stream.stream)
while towrite > 0
n = min(towrite, CHUNKFRAMES)
fill!(sink.chunkbuf, zero(eltype(sink.chunkbuf)))
Pa_WriteStream(sink.stream.stream, sink.chunkbuf, n, false)
towrite -= n
if nchannels(sink) > 0
towrite = Pa_GetStreamWriteAvailable(sink.stream.stream)
while towrite > 0
n = min(towrite, CHUNKFRAMES)
fill!(sink.chunkbuf, zero(eltype(sink.chunkbuf)))
Pa_WriteStream(sink.stream.stream, sink.chunkbuf, n, false)
towrite -= n
end
end
end

View file

@ -279,7 +279,7 @@ end
# end
#
# General utility function to handle the status from the Pa_* functions
function handle_status(err::PaError, show_warnings::Bool=true)
function handle_status(err::Integer, show_warnings::Bool=true)
if err == PA_OUTPUT_UNDERFLOWED || err == PA_INPUT_OVERFLOWED
if show_warnings
msg = @locked ccall((:Pa_GetErrorText, libportaudio),