Hello people,
I’m playing around with Fiddle and CoreMIDI on OSX.
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
require ‘fiddle’
require ‘fiddle/import’
module CoreMIDI
extend Fiddle::Importer
dlload
‘/System/Library/Frameworks/CoreMIDI.framework/Versions/Current/CoreMIDI’
#from MIDIServices.h
#extern MIDIEndpointRef MIDIGetSource( ItemCount sourceIndex0 )
extern "int MIDIGetSource(int)"
# from MIDIServices.h
# extern OSStatus MIDIObjectGetStringProperty(MIDIObjectRef obj,
CFStringRef propertyID, CFStringRef *str);
extern “int MIDIObjectGetStringProperty(int, char *, char *)”
end
from MIDIServices.h
extern const CFStringRef kMIDIPropertyOffline
irb(main)> m = CoreMIDI.MIDIGetSource(0)
=> 273731602
irb(main)> str = “”
irb(main)> CoreMIDI.MIDIObjectGetStringProperty(m,"",str)
=> -10835 #kMIDIUnknownProperty = -10835
from MIDIServices.h
extern const CFStringRef kMIDIPropertyOffline
irb(main)>
CoreMIDI.MIDIObjectGetStringProperty(m,‘kMIDIPropertyOffline’,str)
[BUG] Segmentation fault at 0x00000000000000
#file ruby_2015-05-03-150759_nautilus.crash
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Codes: EXC_I386_GPFLT
The first try
CoreMIDI.MIDIObjectGetStringProperty(m,"",str)
returns -10835 which is kMIDIUnknownProperty. Looks ok for a response.
But then:
CoreMIDI.MIDIObjectGetStringProperty(m,‘kMIDIPropertyOffline’,str)
Exit with a Segmentation fault.
This function MIDIObjectGetStringProperty has an argument “CFStringRef
*str” which I understand is a reference. But how can I give that
reference from ruby. Is it possible?
Should I provide the BUG report. I’m not sure this is a BUG but me not
passing the right parameters type or references.
Many thanks in advance!
Matias Repetti.