MIDIThruConnectionCreate cannot create non-persistent thru connections in Swift

Originator:stef
Number:rdar://FB9836833 Date Originated:1/7/2022
Status:Open Resolved:No
Product:Core MIDI Product Version:macOS 10.13 through 12.1
Classification:Bug Reproducible:Yes
 
When passing Swift nil into MIDIThruConnectionCreate(inPersistentOwnerID:inConnectionParams:outConnection:) as the first parameter, Core MIDI does not interpret it as a NULL. Core MIDI creates a persistent thru connection instead, which is only supposed to happen if this parameter is a non-null string.

The documentation for this method states: “inPersistentOwnerID: A unique identifier of the owning object, such as com.mycompany.MyApp. If you pass NULL, the client owns the connection and it’s automatically disposed with the client.”

My workaround is having to create an Objective-C wrapper function that can achieve it:

OSStatus CMIDIThruConnectionCreateNonPersistent(CFDataRef inConnectionParams, MIDIThruConnectionRef *outConnection)
{
    return MIDIThruConnectionCreate(NULL, inConnectionParams, outConnection);
}

This has been a very long-standing issue for many years, across multiple macOS versions (and possibly iOS as well).

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!