Module: AlsaRawMIDI::API::Device
Overview
Wrapper for ALSA methods dealing with devices
Instance Method Summary collapse
-
#close(handle) ⇒ Boolean
Close the device with the given handle.
- #get_info(id, direction) ⇒ SndCtlCardInfo
-
#open(id, &block) {|handle_pointer| ... } ⇒ Fixnum
Open the device with the given id.
Instance Method Details
#close(handle) ⇒ Boolean
Close the device with the given handle
322 323 324 325 326 |
# File 'lib/alsa-rawmidi/api.rb', line 322 def close(handle) API.snd_rawmidi_drain(handle) API.snd_rawmidi_close(handle) true end |
#get_info(id, direction) ⇒ SndCtlCardInfo
307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/alsa-rawmidi/api.rb', line 307 def get_info(id, direction) stream_key = case direction when :input then :SND_RAWMIDI_STREAM_INPUT when :output then :SND_RAWMIDI_STREAM_OUTPUT end stream = API::CONSTANTS[stream_key] info = API::SndRawMIDIInfo.new API.snd_rawmidi_info_set_device(info.pointer, id) API.snd_rawmidi_info_set_stream(info.pointer, stream) info end |
#open(id, &block) {|handle_pointer| ... } ⇒ Fixnum
Open the device with the given id
332 333 334 335 336 |
# File 'lib/alsa-rawmidi/api.rb', line 332 def open(id, &block) handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int)) yield(handle_pointer) handle_pointer.read_int end |