adds running? method

returns producer thread alive state

fixes bug in strip/bus classes
This commit is contained in:
onyx-and-iris 2023-08-10 14:40:22 +01:00
parent 81f277260a
commit b2194c7aa3
3 changed files with 7 additions and 3 deletions

View File

@ -102,7 +102,7 @@ module Voicemeeter
def getter(mode)
convert = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
vals = if @remote.running && @remote.event.ldirty
vals = if @remote.running? && @remote.event.ldirty
@remote.cache[:bus_level][@init, @offset]
else
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }

View File

@ -232,7 +232,7 @@ module Voicemeeter
convert = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
@remote.cache[:strip_mode] = mode
vals = if @remote.running && @remote.event.ldirty
vals = if @remote.running? && @remote.event.ldirty
@remote.cache[:strip_level][@init, @offset]
else
(@init...@init + @offset).map { |i| @remote.get_level(mode, i) }

View File

@ -49,13 +49,17 @@ module Voicemeeter
public
def running?
@producer&.alive? # safe navigation
end
def init_event_threads
que = Queue.new
init_worker(que) and init_producer(que)
end
def end_event_threads
if @producer&.alive? # safe navigation
if running
@producer[:running] = false
@producer.join
end