mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-21 17:30:49 +00:00
add init_event_threads, end_event_threads
to Worker module. run now handles init/end event threads
This commit is contained in:
parent
d8ee19e2f8
commit
ce8c82a2ca
@ -14,8 +14,7 @@ module Voicemeeter
|
||||
include Worker
|
||||
include Util::Cache
|
||||
|
||||
attr_reader :kind, :midi, :event, :running, :callback, :delay
|
||||
attr_accessor :cache
|
||||
attr_reader :kind, :midi, :event, :callback, :running, :delay, :cache
|
||||
alias_method :observer, :callback
|
||||
|
||||
RATELIMIT = 0.033
|
||||
@ -44,14 +43,9 @@ module Voicemeeter
|
||||
run_voicemeeter(kind.name) if CBindings.call(:bind_login, ok: [0, 1]) == 1
|
||||
clear_dirty
|
||||
logger.info "Successfully logged into #{self} version #{version}"
|
||||
if event.any?
|
||||
init_worker(@que)
|
||||
init_producer(@que)
|
||||
end
|
||||
end
|
||||
|
||||
def logout
|
||||
@running = false
|
||||
sleep(0.1)
|
||||
CBindings.call(:bind_logout)
|
||||
logger.info "Sucessfully logged out of #{self}"
|
||||
|
@ -39,7 +39,6 @@ module Voicemeeter
|
||||
eq = [:eq].to_h { |param| [param, {on: false}] }
|
||||
|
||||
overrides = {B1: true}
|
||||
|
||||
# physical strip params
|
||||
phys_strip =
|
||||
(0...@kind.phys_in).to_h do |i|
|
||||
|
@ -58,9 +58,13 @@ module Voicemeeter
|
||||
|
||||
def run
|
||||
login
|
||||
if event.any?
|
||||
init_event_threads
|
||||
end
|
||||
|
||||
yield(self) if block_given?
|
||||
|
||||
ensure
|
||||
end_event_threads
|
||||
logout
|
||||
end
|
||||
end
|
||||
|
@ -45,10 +45,15 @@ module Voicemeeter
|
||||
end
|
||||
end
|
||||
|
||||
def end_worker
|
||||
def init_event_threads
|
||||
init_worker(@que)
|
||||
init_producer(@que)
|
||||
end
|
||||
|
||||
def end_event_threads
|
||||
@running = false
|
||||
end
|
||||
|
||||
module_function :init_worker, :end_worker
|
||||
module_function :init_event_threads, :end_event_threads
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user