fix: devices not updating when running in node.js
fixes #8
When running in node there is no CFRunLoop to drive CoreMIDI internal updates. see: https://developer.apple.com/documentation/corefoundation/cfrunloop
There are two ways to address the issue.
- start the loop in a separate thread when needed
- drive the loop manually with CFRunLoop
This implementation is 2. It's a brute force and probably has some minor performance impact since we yield to the loop on each call to MidiInfo MidiList and a few other places. It would probably be far better to spawn a thread but I'm not a very strong C++ developer and my skills with low level threading are super rusty. It looks like some code was started to enable this external threading. I'm hoping the brute force approach is acceptable as a bug fix, until someone with more experience in native module development and OSX is able to do something better or I find some time to bang on this again.
Could this potentially address #5 also?
@matthewjumpsoffbuildings not really. I'm not that good of a C developer. Feel free to have it yourself if it's a problem for you. I switched to https://www.npmjs.com/package/@julusian/midi since it seems to be the most actively maintained of the node.js midi modules currently.