MIDIClientCreate does not work for 32 bit processors in Swift

我与影子孤独终老i 提交于 2019-12-23 00:53:48

问题


I am able to create a midiclient via MIDIClientCreate when the scheme is a 64 bit processor (iPhone 5 and later). It does not work for 32 bit processors e.g. iPhone 4s.

    #if !arch(arm64) || !arch(x86_64)
    var status = OSStatus(noErr)
    var s:CFString = "MyClient"
    var client : Unmanaged<MIDIClient>?
    status = MIDIClientCreate(s,
            MIDINotifyProc( COpaquePointer( [ MyMIDINotifyProc ] ) ),
            nil,
            &client)
    if status == OSStatus(noErr) {
       if let c = client {
            var val = c.takeRetainedValue()

Blammo. Bad access exception on takeRetainedValue. As you see, the status is OK, and I'm unwrapping the optional.

Do you have any suggestions?

In case you're wondering, for 64 bit processors, it's a lot simpler because you can just initialize the client var. Look at MIDIServices.h and you'll see that MIDICLient is defined differently for different processors.

 var client = MIDIClientRef()
 status = MIDIClientCreate(s,
    MIDINotifyProc( COpaquePointer( [ MyMIDINotifyProc ] ) ),
    nil,
    &client)

来源:https://stackoverflow.com/questions/27708914/midiclientcreate-does-not-work-for-32-bit-processors-in-swift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!