Skip to content
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

Fix audio crackling issues due to incorrect WASAPI buffer size #89283

Merged
merged 1 commit into from Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions drivers/wasapi/audio_driver_wasapi.cpp
Expand Up @@ -737,12 +737,17 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
ad->start_counting_ticks();

if (avail_frames > 0 && ad->audio_output.audio_client) {
UINT32 buffer_size;
UINT32 cur_frames;
bool invalidated = false;
HRESULT hr = ad->audio_output.audio_client->GetCurrentPadding(&cur_frames);
HRESULT hr = ad->audio_output.audio_client->GetBufferSize(&buffer_size);
if (hr != S_OK) {
ERR_PRINT("WASAPI: GetBufferSize error");
}
hr = ad->audio_output.audio_client->GetCurrentPadding(&cur_frames);
if (hr == S_OK) {
// Check how much frames are available on the WASAPI buffer
UINT32 write_frames = MIN(ad->buffer_frames - cur_frames, avail_frames);
UINT32 write_frames = MIN(buffer_size - cur_frames, avail_frames);
if (write_frames > 0) {
BYTE *buffer = nullptr;
hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer);
Expand Down