From 3de442124f115b2f57ec93f734fbe0af3907a5f0 Mon Sep 17 00:00:00 2001 From: Andrew Madsen Date: Fri, 6 Nov 2015 16:27:58 -0700 Subject: [PATCH] Issue #106: Fix for potential to connect to 'half' of a virtual device. --- Source/MIKMIDIConnectionManager.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/MIKMIDIConnectionManager.m b/Source/MIKMIDIConnectionManager.m index 6f85ec12..34e131d6 100644 --- a/Source/MIKMIDIConnectionManager.m +++ b/Source/MIKMIDIConnectionManager.m @@ -434,6 +434,23 @@ - (void)setIncludesVirtualDevices:(BOOL)includesVirtualDevices } } +- (void)setAvailableDevices:(NSArray *)availableDevices +{ + if (availableDevices != _availableDevices) { + + // Disconnect from newly unavailable devices. + // This will include "partial" virtual devices that are now complete + // by virtue of having been notified of other sources for them. + for (MIKMIDIDevice *device in self.connectedDevices) { + if (![availableDevices containsObject:device]) { + [self internalDisconnectFromDevice:device]; + } + } + + _availableDevices = availableDevices; + } +} + + (BOOL)automaticallyNotifiesObserversOfConnectedDevices { return NO; } - (MIKSetOf(MIKMIDIDevice *) *)connectedDevices {