Module: Voicemeeter::CBindings
- Extended by:
- FFI::Library, Logging
- Defined in:
- lib/voicemeeter/cbindings.rb
Overview
Ruby bindings for the C-API functions
Class Method Summary collapse
Methods included from Logging
Class Method Details
.call(fn, *args, ok: [0], exp: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/voicemeeter/cbindings.rb', line 54 def call(fn, *args, ok: [0], exp: nil) to_cname = -> { "VBVMR_#{fn.to_s.delete_prefix("bind_").camelcase.gsub(/(Button|Input|Output)/, '\1_')}" } res = send(fn, *args) if exp unless exp.call(res) || ok.include?(res) raise Errors::VMCAPIError.new to_cname.call, res end else unless ok.include?(res) raise Errors::VMCAPIError.new to_cname.call, res end end res rescue Errors::VMCAPIError => e err_msg = [ "#{e.class.name}: #{e.}", *e.backtrace ] logger.error err_msg.join("\n") raise end |