20 #include "maccommon.h" 22 #if QT_VERSION < QT_VERSION_CHECK(5,2,0) 23 QString CFStringToQString(CFStringRef str)
27 CFIndex length = CFStringGetLength(str);
28 const UniChar *chars = CFStringGetCharactersPtr(str);
30 return QString(reinterpret_cast<const QChar *>(chars), length);
31 QVarLengthArray<UniChar> buffer(length);
32 CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data());
33 return QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
37 QString getEndpointName(MIDIEndpointRef endpoint)
41 MIDIObjectGetStringProperty (endpoint, kMIDIPropertyName, &str);
43 result = QString::fromCFString(str);
47 MIDIEntityRef entity = 0;
48 MIDIEndpointGetEntity(endpoint, &entity);
51 if (result.isEmpty()) {
52 MIDIObjectGetStringProperty (entity, kMIDIPropertyName, &str);
54 result = QString::fromCFString(str);
59 MIDIDeviceRef device = 0;
60 MIDIEntityGetDevice (entity, &device);
63 MIDIObjectGetStringProperty (device, kMIDIPropertyName, &str);
65 QString s = QString::fromCFString(str);
68 if (!result.startsWith(s, Qt::CaseInsensitive) )
69 result = (s +
' ' + result).trimmed();