1

我一直在尝试使用 unimidi gem,但没有成功......我已经在 unimidi github 的存储库上发布了我的问题,但有一段时间没有答案

我在 OS X.8.2 上使用 rvm,ruby 1.9.3-p327

安装unimidi时一切似乎都很好:

new-host:~ pierrebaille$ gem install unimidi
Building native extensions.  This could take a while...
Fetching: alsa-rawmidi-0.2.14.gem (100%)
Fetching: ffi-coremidi-0.1.8.gem (100%)
Fetching: midi-jruby-0.0.12.gem (100%)
Fetching: midi-winmm-0.1.10.gem (100%)
Fetching: unimidi-0.3.3.gem (100%)
Successfully installed ffi-1.2.0
Successfully installed alsa-rawmidi-0.2.14
Successfully installed ffi-coremidi-0.1.8
Successfully installed midi-jruby-0.0.12
Successfully installed midi-winmm-0.1.10
Successfully installed unimidi-0.3.3
6 gems installed
Installing ri documentation for ffi-1.2.0...
Installing RDoc documentation for alsa-rawmidi-0.2.14...
Installing RDoc documentation for ffi-coremidi-0.1.8...
Installing RDoc documentation for midi-jruby-0.0.12...
Installing RDoc documentation for midi-winmm-0.1.10...
Installing RDoc documentation for unimidi-0.3.3...

当我尝试使用它时:

new-host:~ pierrebaille$ unimidi list
input:
/Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-      1.2.0/lib/ffi/pointer.rb:42:in `get_string': invalid memory read at address=0x00000000000000 (FFI::NullPointerError)
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-1.2.0/lib/ffi/pointer.rb:42:in `read_string'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-coremidi-0.1.8/lib/coremidi/device.rb:23:in `initialize'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-coremidi-0.1.8/lib/coremidi/device.rb:41:in `new'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-coremidi-0.1.8/lib/coremidi/device.rb:41:in `all'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/ffi-coremidi-0.1.8/lib/coremidi/endpoint.rb:52:in `all_by_type'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi/adapter/ffi-coremidi.rb:28:in `populate'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi/congruous_api_adapter.rb:143:in `ensure_initialized'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi/congruous_api_adapter.rb:110:in `all_by_type'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi/congruous_api_adapter.rb:249:in `all'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi/congruous_api_adapter.rb:55:in `list'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/lib/unimidi.rb:26:in `command'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/gems/unimidi-0.3.3/bin/unimidi:10:in `<top (required)>'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/bin/unimidi:19:in `load'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/bin/unimidi:19:in `<main>'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/pierrebaille/.rvm/gems/ruby-1.9.3-p327@first_gemset/bin/ruby_noexec_wrapper:14:in `<main>'

任何帮助都应该非常感激......

圣诞节快乐!

4

1 回答 1

2

我认为这是 ffi-coremidi 中的一个错误,它没有正确处理从 CFStringGetCStringPtr() 返回的 NULL(请参阅https://stackoverflow.com/a/9166500/186057)。

例如,它应该一直在做:

name_ptr = FFI::MemoryPointer.new(:pointer)
Map::MIDIObjectGetStringProperty(@resource, prop, name_ptr)
name = name_ptr.read_pointer
len = Map::CF.CFStringGetMaximumSizeForEncoding(Map::CF.CFStringGetLength(name), :kCFStringEncodingUTF8)
bytes = FFI::MemoryPointer.new(len + 1)
raise RuntimeError.new("CFStringGetCString") unless Map::CF.CFStringGetCString(name, bytes, len, :kCFStringEncodingUTF8)
@name = bytes.read_string

如果您想自己应用修复程序,请应用https://github.com/arirusso/ffi-coremidi/pull/2并重建 ffi-coremidi gem。

于 2012-12-26T02:39:49.800 回答