Fixes games don't switch to headphones or another audio device.
One day, I was playing Dead Cells. Then I went to unplug my USB speakers. And it didn't switch the audio, and that annoyed me.
When a game wants to play audio, it will usually list all the audio devices, pick one of them, and choose to output audio through that device. So far, so good. But then you connect headphones, Bluetooth headphones, or a USB speaker, and your game audio is still playing out the first device that was selected.
Windows also has another way to select the audio device: Use only the Default Device. When a game creates audio that way, it will automatically switch between devices.
To fix it, you change the code. Detouring is where you replace a function with your own function, and the game will run that code instead. It might sound like scary hacker stuff, but it is used all over the place. Windows's own app compatibility features make use of detouring, and even Steam itself uses detouring when it adds the Steam Overlay to a game.
This program hooks into WASAPI and DirectSound, and whenever the game tries to create the audio device, it will instead pick the Default Device.
First, determine if the game is 32-bit or 64-bit. The easiest way to do this is to select the EXE and go to Properties. Go to the Compatibility tab, check the box for "Run this game in compatibility mode for" and look at the drop down there. If it starts with "Windows 95", you have a 32-bit exe. If it starts with "Windows Vista", then you have a 64-bit exe. Then cancel the properties dialog, we don't actually want to apply a compatibility mode here.
Once you know whether the game is 32-bit or 64-bit, you can pick the appropriate files to drop into the game directory. I suggest copying "version.dll", "cryptbase.dll", and "wldp.dll". If a file conflicts with an existing game mod loader, do not overwrite it.
These are stub DLL files. They have the same filename as a system DLL, but they are not the actual operating system's DLLs. Instead, a stub loads the real system DLL, and forwards all the functions to the real DLL. These DLLs also run the audio fix as well. Do not replace your actual system DLLs with these stub DLLs.
Because Windows is a little careless about loading system DLLs, it will sometimes load a DLL from the game directory instead of the actual system DLL. This is our chance to get the audio fix into the game.
Other mod loaders for games use the same mechanism to get their code to run in the game without modifying any of the game files.
You will get game crashes in Dead Cells unless you update the OpenAL32.dll that comes with the game. You can find a copy from the openal-soft releases page. Download the file with "-bin" in the name. Inside the zip, look for "bin\Win32\soft_oal.dll", and rename it to OpenAL32.dll. Alternatively, you can use the OpenAL32.dll that comes with Binding of Isaac.
Even though this is not a cheat program, you're loading third-party code into a game. Some multiplayer games might not like that, and could confuse it for a cheating program. I have no control over what they decide to do. (kick, ban, etc.)
Just a few games that I tested it on:
- Dead Cells (32-bit) (Must update OpenAL32.dll or else there's game crashes)
- Ori and The Blind Forest - Definitive Edition (32-bit)
- A Hat in Time (64-bit)
- Cuphead (64-bit)
- Escape Goat (32-bit)
- Balatro (64-bit)