Skip to content

Allow WASAPI exclusive mode to work in more devices #1084

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

Closed
wants to merge 2 commits into from

Conversation

LAGonauta
Copy link
Contributor

In all my devices exclusive mode wasn't working, and that is because GetCurrentPadding was always returning zero. This PR fixes in all my devices in my case, and there are no skipping or glitches.

sample-type=int16 is still required for my devices, but I am going to resolve it later.

mDevice->handleDisconnect("Failed to retrieve buffer padding: {:#x}",
as_unsigned(hr));
break;
hr = audio.mClient->GetBufferSize(&written);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless this value can change, it was already stored in mOutBufferSize, which is copied into the local variable buffer_len. It doesn't need to be queried each time. Also, since written is used to update mPadding, which is used for latency calculations, I'm not sure leaving it as the buffer size is a good idea (unless that is the actual amount of padding WASAPI holds for exclusive streams, i.e. the amount of audio still left to play before the new samples to be mixed).

@ThreeDeeJay
Copy link
Contributor

Confirmed this fixed audio on my onboard Realtek device, though other devices are still having issues.
More details/context here: #682 (comment)

@kcat
Copy link
Owner

kcat commented Dec 26, 2024

I ended up reworking stuff in the WASAPI backend, which created conflicts. But I may have also fixed some issues with exclusive mode. Are there still issues that need fixing?

@ThreeDeeJay
Copy link
Contributor

@kcat I'm still getting no audio on my Realtek card (which is probably what most PC users have) https://www.diffchecker.com/gR1s8cfX/
My Creative X-Fi USB works fine with the same settings, though: https://www.diffchecker.com/THjvIkax/
Here's a comparison of the logs of both cards using WASAPI exclusive: https://www.diffchecker.com/RG6XGpcW/
I noticed that the Realtek changes period_size from 144 to 160, and still doesn't work. I also get no audio if I manually set it to 160 or even values over 1K.

@LAGonauta
Copy link
Contributor Author

LAGonauta commented Jan 2, 2025

This should have been fixed in the rework.

@LAGonauta LAGonauta closed this Jan 2, 2025
@ThreeDeeJay
Copy link
Contributor

Can confirm 👌
Realtek now works though it still post-resets to 160 even though I set 133 (anything lower crashes both), which sticks when using my Creative card: https://www.diffchecker.com/LCYzsRbR/

@kcat
Copy link
Owner

kcat commented Jan 3, 2025

Can confirm 👌
Realtek now works though it still post-resets to 160 even though I set 133 (anything lower crashes both), which sticks when using my Creative card: https://www.diffchecker.com/LCYzsRbR/

Possibly the Realtek device can't go lower than 160 (~3.333ms), while the Creative card can go a bit lower. If initializing fails with AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED, it gets the next supported period size, which would be 160. Values less than 133 are probably triggering a different initialization error (AUDCLNT_E_BUFFER_SIZE_ERROR maybe?), which causes a failure and the delayed crash.

@ThreeDeeJay
Copy link
Contributor

Replied in the main thread #682 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants