OK, I investigated some more today and I got a core midi error on line 322 of your code, in MidiOutput::openDevice. In particular, on this line of code:
if (CHECK_ERROR (MIDIObjectGetStringProperty (endPoint, kMIDIPropertyName, &pname)))
the actual error reported is 0xffffffce, and from what I can see this is an OSStatus code. I searched around but could not find out what this code actually means... your function uses MIDIGetDestination, and the MIDI Services Reference at
https://developer.apple.com/library/ios/documentation/CoreMidi/Reference/MIDIServices_Reference/#//apple_ref/c/func/MIDIGetDestination
Says that the return value of that function is "A reference to a destination, or NULL if an error occurred". I'm guessing you are trying to get the name of the device through MIDIObjectGetStringProperty, but perhaps the endPoint parameter is null because that is what MIDIGetDestination returned? It would be very helpful if your code actually printed the error, instead of the 0xffffffce so I would know why exactly the index that I'm passing to openDevice is no longer valid, even though I got it before calling openDevice, using MidiOutput::getDevices() ...
I kept getting the same error, and I was able to consistently reproduce it, all while only using Apple's IAC ports in osx 10.9. I would start the app, quit and restart and I would have the same problem again.
So eventually I went into the audio / midi setup dialog on osx. The IAC ports were online (checkbox checked). I then unchecked the device is online checkbox which put the device offline, and then checked it again to bring the device back online. And that solved the problem!
So yes, strictly speaking not your problem, BUT .... if your code would have given me more hints about the actual error codes reported by core midi, and what they mean, then I would have saved myself a day of work :-)
So it would be great if you could add some functions to the MidiOutput/MidiInput class that would print the actual core midi error as a string instead of just printing an error code.
I still don't know what exactly put the IAC ports into this state in the first place and why marking them offline and then back online solved the issue.