There's a problem with Leland's loop-detection in GetConnectedPin(..) - it prevents Audacity from finding all devices on my system - and those found have "generic" names (fx "input" and "output" rather than "microphone" and "speaker").
It would seem it isn't enough to check only for re-occurring values of the conn value - apparently it leads to false positives.
Also I suppose the loop-detection has a memory leak as it doesn't clean up the array it creates (very minor problem).

See these screen-dump images from the loop-detection version:
3 inputs found (I'm translating the names to English here):
 (a) "Input (Realtek HD Digital input)"
 (b) "Input (Realtek HD Audio Input)"
 (c) "Input (USB audio device)"
2 outputs found (again translated for the Danish impaired lol!):
 (x) "Output 1 (Realtek HD Audio output)"
 (y) "Output 2 (Realtek HD Audio output)"

And compare with these from my timeout-with-the-fancy-magic-number-of-1024 version:
5 inputs found (names translated to English):
 (1) "Input (Realtek HD Digital input)"  // same device as (a) above
 (2) "Stereomix (Realtek HD Audio Input)" // same device as (b) above, but with better name
 (3) "Volume control for microphone (Realtek HD Audio Input)" // not found above
 (4) "Volume control for line-in (Realtek HD Audio Input)" // not found above
 (5) "Microphone (USB audio device)" // same as (c) above, but with better name
2 outputs found:
 (I) "Speakers 1 (Realtek HD Audio output)" // same device as (x) above, but with better name
 (II) "Speakers 2 (Realtek HD Audio output)" // same device as (y) above, but with better name

Anyway I'm very sorry for not noticing this so very obvious problem before! I was way too busy last week, and I didn't had time to do anything in the weekend either. Aaand when I tried to compile this morning Visual Studio kept on handing me linker errors - even after I did a full clean of the entire solution + a force update of Intellisense!!!!! Only solution was a svn revert and applying the changes again. %€&%"#"!!!

So should I try to refine the loop detection? It would be quite straightforward but still some coding required because it would mean testing values of several other variables besides the _conn_ variable.
On the other hand the timeout-with-the-magic-number version is a no-brainer - and it might be better to keep it simple?
What say you?

// Lasse

"There is a crack in everything, that's how the light gets in." - L. Cohen