169 |
void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ProcessMidiEvents(const MIDIPacketList *pktlist) { |
void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ProcessMidiEvents(const MIDIPacketList *pktlist) { |
170 |
MIDIPacket *packet = (MIDIPacket *)pktlist->packet; |
MIDIPacket *packet = (MIDIPacket *)pktlist->packet; |
171 |
for (unsigned int i = 0; i < pktlist->numPackets; ++i) { |
for (unsigned int i = 0; i < pktlist->numPackets; ++i) { |
172 |
char* pData = (char*) packet->data; |
uint8_t* pData = (uint8_t*) packet->data; |
173 |
int k = 0; |
int k = 0; |
174 |
// A MIDIPacket can have more than one (non SysEx) MIDI event in one |
// A MIDIPacket can have more than one (non SysEx) MIDI event in one |
175 |
// packet. However SysEx messages are guaranteed to be alone in one |
// packet. However SysEx messages are guaranteed to be alone in one |
180 |
|
|
181 |
if (k + eventSize > packet->length) goto next_packet; |
if (k + eventSize > packet->length) goto next_packet; |
182 |
|
|
183 |
DispatchRaw(packet->data); |
DispatchRaw(&pData[k]); |
184 |
k += eventSize; |
k += eventSize; |
185 |
} while (k < packet->length); |
} while (k < packet->length); |
186 |
|
|
190 |
} |
} |
191 |
|
|
192 |
void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::connectToSource(MIDIEndpointRef source) { |
void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::connectToSource(MIDIEndpointRef source) { |
193 |
// check if we already have such a connection, if yes, disconnect it first |
// check if we already have such a connection, if yes, ignore it |
194 |
for (uint i = 0; i < bindings.size(); ++i) { |
for (uint i = 0; i < bindings.size(); ++i) { |
195 |
if (bindings[i] == source) { |
if (bindings[i] == source) return; |
|
MIDIPortDisconnectSource(pDevice->pBridge, source); |
|
|
break; |
|
|
} |
|
196 |
} |
} |
197 |
// now establish the CoreMIDI connection |
// now establish the CoreMIDI connection |
198 |
MIDIPortConnectSource(pDevice->pBridge, source, this); |
MIDIPortConnectSource(pDevice->pBridge, source, this); |