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