New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default device override not working for Battle.net games? #13
Comments
I think this is related: audiorouterdev/audio-router#24 |
Not sure if related. SAR uses a very different method of overriding the default audio device than audio-router, but it's plausible that some anti-cheat software could break it. I don't have a copy of the game and haven't tested it. Mind checking its handle list using Process Explorer? See if you see SarAsio.dll in its list of open files. |
Yes it is (SarAsio_x64.dll). |
@pannal, you were saying you added the Battle.net folder to the SAR applications; could you share the exact expression you used? Adding whole folders only works by adding a regular expression that matches everything in it, maybe something went wrong with that expression. I wrote that guide by the way ;) |
Sure, but the regex is correct, as Hearthstone and other Battle.net games work in SAR. |
This appears to have nothing to do with Overwatch specifically. The problem is that Overwatch is using the XAudio2 API, which appears to have some backdoor way of getting the default audio device. It only calls IMMDeviceEnumerator::GetDevice, never IMMDeviceEnumerator::GetDefaultAudioEndpoint. Same problem happens with the basic playback example from the XAudio2 SDK samples. I'll see if I can find a solution. |
Awesome. I love the work you're doing here. Any news on a new beta? |
Need to complete a few bug fixes first. Kind of slow going atm due to work related reasons. I'm taking a closer look now and it appears that XAudio2 is creating its renderer by calling ActivateAudioInterfaceAsync with DEVINTERFACE_AUDIO_RENDER, which goes straight into MMDevAPI's internal endpoint lookup code. ActivateAudioInterfaceAsync is implemented by an undocumented coclass ActivateAudioInterfaceWorker (E2F7A62A-862B-40AE-BBC2-5C0CA9A5B7E1) which could be intercepted, albeit at the cost of introducing a dependency on an undocumented interface. Going to give it a shot. For completeness, other options would include hijacking the export out of MMDevAPI (very intrusive) or hijacking the top level XAudio2 COM interface (less comprehensive, other code that uses ActivateAudioInterfaceAsync wouldn't be covered). I consider CreateRemoteThread type approaches (e.g. used by audiorouter) off the table. |
Adds some temporary debug logging to SarMMDeviceEnumerator to see more API calls that clients are making. Since the problem with XAudio2 apps is its internal use of ActivateAudioInterfaceAsync, generalize the registry filter to store mapped registry paths in a table instead of just statically comparing strings. Stub out an interceptor for ActiveAudioInterfaceWorker coclass. All of this is pretty untested code.
Was setting a PUNICODE_STRING* instead of a PUNICODE_STRING as the value in the registry mapping table. Caused some fun bugchecks. Also adds logging of the registry mappings on startup.
- Fixes an issue where the registry filter could access paged memory while holding a spinlock, resulting in bugcheck. - Adds lookup of redirected default device to SarActivateAudioInterfaceWorker. - Adds free threaded marshaler support to SarActivateAudioInterfaceWorker for STA callers. - Adds COM registration to installer. With these changes, both the XAudio2 SDK samples and Overwatch appear to work correctly. My guess is that applications which use the WinRT functions like MediaDevice::GetDefaultAudioRenderId will still not work correctly, but who uses UWP apps anyway, right?
This is now fixed in master. Doing some more local testing and will get a package up soon. |
You're the best. Do you have DEV instructions laying around somewhere for me to follow? I could test the latest master by myself. I'm a developer myself (although, more Python-focused), so I should get through it. Something like: install these requirements, build using that toolchain, sign with test key, fire away. |
Here is a build. This is not adequately tested for release. Should your machine catch fire, don't say I didn't warn you. SynchronousAudioRouter_x64_0_13_debug_20170417.zip Notes:
I don't have actual development instructions, but basically you need VS 2015 with all the C++ and ATL/COM stuff installed, the Windows Driver Kit, and WiX 3.10. Build defaults to test signing which you can Google how to enable loading test signed drivers. Debugging is best done with a 2 machine setup (I use a pair of Firewire cards for 1394 debugging). |
I'll try it, haven't had the time yet, sorry. |
Works. Also I don't have to quit reaper before going into sleep with the newest release (resulted in a bugcheck bluescreen). Seems to work well for now. |
Yep, runs well. |
Ok, no issues since 3 days. Runs well, works with all games yet, and survives standby. Great job! |
Thanks for the feedback. I assume you were hitting the registry filter bugcheck I fixed. IRQL_NOT_LESS_OR_EQUAL or something to that effect? Edit: actually I'm not sure you could have ever hit that. Do you have any files in C:\Windows\Minidump with the crash info? I could use that for verification purposes. |
Exactly. I had to stop reaper before letting my PC go to standby before, otherwise I'd get exactly that bugcheck. Edit: I had, yes. But that got cleaned up on the last cleanup run, I'm sorry. |
I'm trying this with this guide. Added the Battle.net folder to the SAR applications and tried Overwatch. It keeps playing back on the "Application" device, not the "Games" device.
Is this known? Do you need more technical details?
Thank you!
Edit: Windows 10 pro with ASIO4ALL
The text was updated successfully, but these errors were encountered: