What's the purpose of argument 'CFStringRef name' in functions MIDIClientCreate, MIDIInputPortCreate and MIDIOutputPortCreate?

StackOverflow https://stackoverflow.com/questions/23594875

  •  20-07-2023
  •  | 
  •  

سؤال

There's three functions in "CoreMIDI API" that have argument (CFStringRef) name: "MIDIClientCreate", "MIDIInputPortCreate" and "MIDIOutputPortCreate".

What's the purpose of 'CFStringRef name' argument? How it's used in the API? Why does they (Apple) created in their API such argument that doesn't used anywhere? Maybe I wrong about the last one. But why name in arguments?

Thank you for attention!

هل كانت مفيدة؟

المحلول

The underlying MIDI system services uses inter-process communication to the the MIDI server which takes names for it's components, so this was built in as support but is not fully taken advantage of in the Core Midi Library yet. However, like the comments below the question suggest, it actually does have usefulness in retrieving a description or name of a particular object for identification or comparison. For example, this will return the name

MIDIClientRef midiClient;
OSStatus result;
result = MIDIClientCreate(CFSTR("My MIDI client"), NULL, NULL, &midiClient);


if (result == noErr)
{
    CFStringRef nameString;
    MIDIObjectGetStringProperty(midiClient, kMIDIPropertyName, &nameString);
    CFShow(nameString);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top