Thanks @anon914446, I always appreciate your thorough responses on mine and other posts on this forum.
In general the idea is that if you have opened the device you will have kept the returned ID, if you have not opened the device then it should not otherwise affect your code
this may be true most of the time, but not for my application. I’m writing a DAW, and the user must be able to see a list of available devices when, for example, selecting the input for a given audio track:
For a variety of reasons (one of which you helped me on!), those capture devices are only opened when they are being used to record audio. The data structures in my program containing the audio device information cannot be simply destroyed and recreated, because they are referenced all over the place. If SDL_AudioEvent
provided an index or a device name, I could check those lists for the removed device and modify them accordingly. Since it does not, as far as I can tell right now, my best option is to do another call to SDL_GetNumAudioDevices
and check each of the subsequent calls to SDL_GetAudioDeviceName
against the existing list to determine which was removed, and then do the modification. That is ok, but requires some extra work (n^2 string comparisons instead of n) and is a somewhat ugly solution if SDL actually knows which device was removed (even if it has never been opened).