WASAPI loopback

Good to see SDL 2.0.6 is now using WASAPI for audio on Windows and can get input from there. I was wondering if it would be possible to add loopback support, possibly as a pseudo audio device as the last capturing device? Looking at this documentation and SDL_wasapi.c it seems like it would be mostly a question of setting variable ‘dataflow’ after line 411 to eRender if in loopback and at line 755 to change the 3rd argument of IAudioClient_Initialize() from 0 to AUDCLNT_STREAMFLAGS_LOOPBACK.

I haven’t tried it myself yet and I don’t know how the rest of the code is set up to know what else would have to change to get a loopback pseudo device, but that would be great if it ever happened. My dream is to have this so that I can finally make a standalone SDL version of my Spiral visualisation plugin with the loopback as a source for the audio to visualise.

It seems like SDL’s WASAPI code is based on PortAudio, and as it happens there’s a patch to enable loopback capture on SDL, just in case anyone wishes to apply it to SDL’S WASAPI code: https://github.com/michaelni/audacity/blob/master/lib-src/portaudio-v19/wasapi-loopback.patch