TF2 gives error on startup - couldn't initialize sound
So I am at my wits end, any help would be much appreciated. My rig has an i5 14000 kf cpu and a 7900 xtx gpu, Windows 10 pro with TF2 (Steam) installed in a secondary M2 ssd drive. I have both a 2.1 speaker setup (audio jack, Realtek) and an headset (USB, integrated audio chip) connected at the same time, and to switch between the audio outputs I use a little tool named AudioSwitch.
Here's the problem: when using the headset TF2 throws an error that reads:
"Couldn't Initialize Sound.
Please make sure you have a sound playback device that is enabled and properly configured.
Failed in: MilesDriverCreate
Miles output follows:
Audio Hardware Error: Failed to initialize IAudioClient (shared, event mode, float, chans=2, rate=96000, HR=AUDCLNT_E_DEVICE_IN_USE)
Failed to initialized WASAPI audio hardware, trying XAudio.
Couldn't create XAudio2 master voice."
Using the onboard Realtek audio does not generate this error, and if I feedle a bit with the "Set as default device" and "Set as default communication device" tags in Settings > Sound, sometimes I can get TF2 to work using my headset. However, it seems to be by pure trial and error, as I cannot find a pattern and the process is extremely tedious to be done each time I want to play this game.
Here's a small enumeration of what I have already tried to no avail.
- disable Realtek audio,
- delete all TF2 settings files,
- run TF2 as admin, and force the settings files to be read only (after being able to launch the game),
- reinstall tf2
- lower audio frequency as suggested in some posts,
- ...
Any help will be much appreciated