removes extra asynccondition step now that our task isn't blocking
This commit is contained in:
parent
f868087e99
commit
56cf15e9df
1 changed files with 16 additions and 33 deletions
|
@ -87,7 +87,6 @@ type PortAudioStream{T, U}
|
||||||
sink # untyped because of circular type definition
|
sink # untyped because of circular type definition
|
||||||
source # untyped because of circular type definition
|
source # untyped because of circular type definition
|
||||||
taskwork::Base.SingleAsyncWork
|
taskwork::Base.SingleAsyncWork
|
||||||
taskcond::Condition # used to wake the audio task when the PA callback happens
|
|
||||||
bufstate::BufferState # used to synchronize the portaudio and julia sides
|
bufstate::BufferState # used to synchronize the portaudio and julia sides
|
||||||
bufinfo::CallbackInfo{T} # immutable data used in the portaudio callback
|
bufinfo::CallbackInfo{T} # immutable data used in the portaudio callback
|
||||||
|
|
||||||
|
@ -107,8 +106,7 @@ type PortAudioStream{T, U}
|
||||||
prefill=false, underflow=PAD)
|
prefill=false, underflow=PAD)
|
||||||
this.source = PortAudioSource{T, U}(indev.name, this, inchans, bufsize;
|
this.source = PortAudioSource{T, U}(indev.name, this, inchans, bufsize;
|
||||||
prefill=true, overflow=OVERWRITE)
|
prefill=true, overflow=OVERWRITE)
|
||||||
this.taskwork = Base.SingleAsyncWork(_ -> wakeaudiotask(this))
|
this.taskwork = Base.SingleAsyncWork(_ -> audiotask(this))
|
||||||
this.taskcond = Condition()
|
|
||||||
this.bufstate = PortAudioPending
|
this.bufstate = PortAudioPending
|
||||||
this.bufinfo = CallbackInfo(inchans, pointer(this.source.pabuf),
|
this.bufinfo = CallbackInfo(inchans, pointer(this.source.pabuf),
|
||||||
outchans, pointer(this.sink.pabuf),
|
outchans, pointer(this.sink.pabuf),
|
||||||
|
@ -244,15 +242,11 @@ function portaudio_callback{T}(inptr::Ptr{T}, outptr::Ptr{T},
|
||||||
paContinue
|
paContinue
|
||||||
end
|
end
|
||||||
|
|
||||||
wakeaudiotask(stream::PortAudioStream) = notify(stream.taskcond)
|
# this gets called from uv_async_send, so it MUST NOT BLOCK
|
||||||
|
|
||||||
function audiotask{T, U}(stream::PortAudioStream{T, U})
|
function audiotask{T, U}(stream::PortAudioStream{T, U})
|
||||||
while true
|
|
||||||
try
|
try
|
||||||
wait(stream.taskcond)
|
|
||||||
isopen(stream) || break
|
|
||||||
if stream.bufstate != JuliaPending
|
if stream.bufstate != JuliaPending
|
||||||
continue
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
transpose!(stream.source.jlbuf, stream.source.pabuf)
|
transpose!(stream.source.jlbuf, stream.source.pabuf)
|
||||||
|
@ -263,19 +257,8 @@ function audiotask{T, U}(stream::PortAudioStream{T, U})
|
||||||
|
|
||||||
stream.bufstate = PortAudioPending
|
stream.bufstate = PortAudioPending
|
||||||
catch ex
|
catch ex
|
||||||
# if isa(ex, InterruptException)
|
|
||||||
# for w in stream.source.waiters
|
|
||||||
# notify(w, ex; error=true)
|
|
||||||
# end
|
|
||||||
# for w in stream.sink.waiters
|
|
||||||
# notify(w, ex; error=true)
|
|
||||||
# end
|
|
||||||
# else
|
|
||||||
warn("Audio Task died with exception: $ex")
|
warn("Audio Task died with exception: $ex")
|
||||||
Base.show_backtrace(STDOUT, catch_backtrace())
|
Base.show_backtrace(STDOUT, catch_backtrace())
|
||||||
break
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue