mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-15 15:00:46 +00:00
push @running into que when terminating threads
This commit is contained in:
parent
1ba1247b7f
commit
00cc4c9547
@ -31,7 +31,6 @@ module Voicemeeter
|
|||||||
**(kwargs.select { |k, _| %i[pdirty mdirty ldirty midi].include? k })
|
**(kwargs.select { |k, _| %i[pdirty mdirty ldirty midi].include? k })
|
||||||
)
|
)
|
||||||
@midi = Midi.new
|
@midi = Midi.new
|
||||||
@que = Queue.new
|
|
||||||
@cache = {strip_mode: 0}
|
@cache = {strip_mode: 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ module Voicemeeter
|
|||||||
|
|
||||||
include Logging
|
include Logging
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def init_producer(que)
|
def init_producer(que)
|
||||||
@running = true
|
@running = true
|
||||||
Thread.new do
|
Thread.new do
|
||||||
@ -18,7 +20,7 @@ module Voicemeeter
|
|||||||
sleep(@ratelimit)
|
sleep(@ratelimit)
|
||||||
end
|
end
|
||||||
logger.debug "closing #{Thread.current.name} thread"
|
logger.debug "closing #{Thread.current.name} thread"
|
||||||
que << :stop
|
que << @running
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,16 +31,11 @@ module Voicemeeter
|
|||||||
@cache[:bus_comp] = Array.new(kind.num_bus_levels, false)
|
@cache[:bus_comp] = Array.new(kind.num_bus_levels, false)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
Thread.current.name = "worker"
|
Thread.current.name = "worker"
|
||||||
loop do
|
while (event = que.pop)
|
||||||
e_from_que = @que.pop
|
trigger :pdirty if event == :pdirty && pdirty?
|
||||||
if e_from_que == :stop
|
trigger :mdirty if event == :mdirty && mdirty?
|
||||||
logger.debug "closing #{Thread.current.name} thread"
|
trigger :midi if event == :midi && get_midi_message
|
||||||
break
|
if event == :ldirty && ldirty?
|
||||||
end
|
|
||||||
trigger :pdirty if e_from_que == :pdirty && pdirty?
|
|
||||||
trigger :mdirty if e_from_que == :mdirty && mdirty?
|
|
||||||
trigger :midi if e_from_que == :midi && get_midi_message
|
|
||||||
if e_from_que == :ldirty && ldirty?
|
|
||||||
cache[:strip_comp] = cache[:strip_level].zip(cache[:strip_buf]).map { |a, b| a != b }
|
cache[:strip_comp] = cache[:strip_level].zip(cache[:strip_buf]).map { |a, b| a != b }
|
||||||
cache[:bus_comp] = cache[:bus_level].zip(cache[:bus_buf]).map { |a, b| a != b }
|
cache[:bus_comp] = cache[:bus_level].zip(cache[:bus_buf]).map { |a, b| a != b }
|
||||||
cache[:strip_level] = cache[:strip_buf]
|
cache[:strip_level] = cache[:strip_buf]
|
||||||
@ -46,18 +43,20 @@ module Voicemeeter
|
|||||||
trigger :ldirty
|
trigger :ldirty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
logger.debug "closing #{Thread.current.name} thread"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
public
|
||||||
|
|
||||||
def init_event_threads
|
def init_event_threads
|
||||||
init_worker(@que)
|
que = Queue.new
|
||||||
init_producer(@que)
|
init_worker(que)
|
||||||
|
init_producer(que)
|
||||||
end
|
end
|
||||||
|
|
||||||
def end_event_threads
|
def end_event_threads
|
||||||
@running = false
|
@running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :init_event_threads, :end_event_threads
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user