I would like to solve it properly, and to me the most important thing to do that is to understand exactly how it should behave. I’m hoping I got it right now? : On each external device/port change, we want the device restarted, just like it happens when changing active channels in the AudioIODeviceSelectorComponent.
Let me take another look at it then and get back to you.
Thank you for your patience. How would you feel about something like this:
updateActivePorts() gets called on each port change. Hence no need to call it from open(). It knows to ignore port changes in other clients (every jack port change triggers our callback), and also to restart the device when necessary.
Thank you Jules, it builds and performs correctly AFAICT. Both external and internal port changes trigger a device restart, and the correct number of actually-connected in/out ports are sent to the audio callback at all times. Great to have that fixed.
Just a C++ question, out of curiosity: you have declared the static function JackAudioIODevice::sendDeviceChangedCallback() within the class, and defined it at the end of the same file. Is there some cleverness to this - would it make any difference defining it directly within the class definition?
I put that method at the end because it wouldn’t compile if it was inline - it calls the device type class, which isn’t defined until later in the file.