Open sletz opened 3 years ago
same for me, I tried @async as well as @spawn, the read still blocks.
Please provide a minimum working example to demonstrate what you are reporting.
using PortAudio
using Base.Threads
stream = PortAudioStream()
buffer = Array{Float32, 2}(undef, (44100 * 10, 2))
function r()
println("before read!")
read!(stream, buffer)
println("after read!")
end
println("calling @async r ")
@async r()
#Threads.@spawn r()
#println("after @async")
while true
sleep(0.5)
println("doing something")
end
produces:
calling @async r
after @async
before read!
doing something
after read!
doing something
doing something
doing something
doing something
doing something
doing something
doing something
doing something
btw playing ascyn is also not working
Have you tested this without PortAudio to confirm your understanding of how async works is correct?
Actually I have, but to be honest I am a novice in Julia, so maybe I misunderstood some basics. I come from python and used their portaudio wrapper pyaudio.
The code @async function above is useless but should run in a different thread, right? I would assume that this thread shouldn't block the program for 10 secs, but it does.
Maybe I will try it instead of threads with different processes.
Thanks! Writing is working, sorry was my fault. Reading not, but actually additionally I have still no clue how I could manage some producer consumer pattern between the shared buffers in Julia.
I'm trying to use PortAudio.jl in an application where the running audio code control parameters have to be updated in real-time, like with a GTK base GUI, or an OSC controller (or even possibly both at the same time).
The PA template code is here: https://github.com/grame-cncm/faust/blob/master-dev/architecture/julia/audio/portaudio.jl
And I have a OSC controller here: https://github.com/grame-cncm/faust/blob/master-dev/architecture/julia/gui/OSCUI.jl
threads = 1
, but start to be choppy whenthreads > 1
Threads.@spawn
here https://github.com/grame-cncm/faust/blob/master-dev/architecture/julia/gui/OSCUI.jl#L67, without success. ThereceiveMessage()
is never called.