| 1 |
Index: pm_mac/pmmacosxcm.c |
| 2 |
=================================================================== |
| 3 |
--- pm_mac/pmmacosxcm.c (revision 234) |
| 4 |
+++ pm_mac/pmmacosxcm.c (working copy) |
| 5 |
@@ -70,6 +70,7 @@ |
| 6 |
#define VERBOSE_ON 1 |
| 7 |
#define VERBOSE if (VERBOSE_ON) |
| 8 |
|
| 9 |
+#define MIDI_CLOCK 0xf8 |
| 10 |
#define MIDI_SYSEX 0xf0 |
| 11 |
#define MIDI_EOX 0xf7 |
| 12 |
#define MIDI_STATUS_MASK 0x80 |
| 13 |
@@ -199,9 +200,16 @@ |
| 14 |
/* since there's no more data, we're done */ |
| 15 |
return; |
| 16 |
} |
| 17 |
- m->last_msg_length = cur_message_length; |
| 18 |
- m->last_command = cur_packet_data[0]; |
| 19 |
- switch (cur_message_length) { |
| 20 |
+ if (cur_packet_data[0] < MIDI_SYSEX) { |
| 21 |
+ /* channel messages allow running status */ |
| 22 |
+ m->last_command = cur_packet_data[0]; |
| 23 |
+ m->last_msg_length = cur_message_length; |
| 24 |
+ } else if(cur_packet_data[0] < MIDI_CLOCK) { |
| 25 |
+ /* system messages clear running status */ |
| 26 |
+ m->last_command = 0; |
| 27 |
+ m->last_msg_length = 0; |
| 28 |
+ } |
| 29 |
+ switch (cur_message_length) { |
| 30 |
case 1: |
| 31 |
event->message = Pm_Message(cur_packet_data[0], 0, 0); |
| 32 |
break; |
| 33 |
@@ -220,8 +228,8 @@ |
| 34 |
return; /* give up on packet if continued after assert */ |
| 35 |
} |
| 36 |
pm_read_short(midi, event); |
| 37 |
- remaining_length -= m->last_msg_length; |
| 38 |
- cur_packet_data += m->last_msg_length; |
| 39 |
+ remaining_length -= cur_message_length; |
| 40 |
+ cur_packet_data += cur_message_length; |
| 41 |
} else if (m->last_msg_length > remaining_length + 1) { |
| 42 |
/* we have running status, but not enough data */ |
| 43 |
#ifdef DEBUG |
| 44 |
@@ -836,49 +844,16 @@ |
| 45 |
|
| 46 |
char* cm_get_full_endpoint_name(MIDIEndpointRef endpoint) |
| 47 |
{ |
| 48 |
-#ifdef OLDCODE |
| 49 |
- MIDIEntityRef entity; |
| 50 |
- MIDIDeviceRef device; |
| 51 |
- |
| 52 |
- CFStringRef endpointName = NULL; |
| 53 |
- CFStringRef deviceName = NULL; |
| 54 |
-#endif |
| 55 |
- CFStringRef fullName = NULL; |
| 56 |
- CFStringEncoding defaultEncoding; |
| 57 |
char* newName; |
| 58 |
+ CFStringRef fullName = ConnectedEndpointName(endpoint); |
| 59 |
|
| 60 |
- /* get the default string encoding */ |
| 61 |
- defaultEncoding = CFStringGetSystemEncoding(); |
| 62 |
- |
| 63 |
- fullName = ConnectedEndpointName(endpoint); |
| 64 |
- |
| 65 |
-#ifdef OLDCODE |
| 66 |
- /* get the entity and device info */ |
| 67 |
- MIDIEndpointGetEntity(endpoint, &entity); |
| 68 |
- MIDIEntityGetDevice(entity, &device); |
| 69 |
- |
| 70 |
- /* create the nicely formated name */ |
| 71 |
- MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &endpointName); |
| 72 |
- MIDIObjectGetStringProperty(device, kMIDIPropertyName, &deviceName); |
| 73 |
- if (deviceName != NULL) { |
| 74 |
- fullName = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@: %@"), |
| 75 |
- deviceName, endpointName); |
| 76 |
- } else { |
| 77 |
- fullName = endpointName; |
| 78 |
- } |
| 79 |
-#endif |
| 80 |
/* copy the string into our buffer */ |
| 81 |
- newName = (char *) malloc(CFStringGetLength(fullName) + 1); |
| 82 |
- CFStringGetCString(fullName, newName, CFStringGetLength(fullName) + 1, |
| 83 |
- defaultEncoding); |
| 84 |
- |
| 85 |
- /* clean up */ |
| 86 |
-#ifdef OLDCODE |
| 87 |
- if (endpointName) CFRelease(endpointName); |
| 88 |
- if (deviceName) CFRelease(deviceName); |
| 89 |
-#endif |
| 90 |
- if (fullName) CFRelease(fullName); |
| 91 |
+ CFIndex length = CFStringGetLength(fullName) + 1; |
| 92 |
+ const CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; |
| 93 |
+ newName = (char *) malloc(maxSize); |
| 94 |
+ CFStringGetCString(fullName, newName, maxSize, kCFStringEncodingUTF8); |
| 95 |
|
| 96 |
+ if (fullName) CFRelease(fullName); |
| 97 |
return newName; |
| 98 |
} |
| 99 |
|