Merge pull request #89283 from AlexOtsuka/audio-fix
Fix audio crackling issues due to incorrect WASAPI buffer size
This commit is contained in:
commit
377ce78d4e
1 changed files with 7 additions and 2 deletions
|
@ -737,12 +737,17 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
||||||
ad->start_counting_ticks();
|
ad->start_counting_ticks();
|
||||||
|
|
||||||
if (avail_frames > 0 && ad->audio_output.audio_client) {
|
if (avail_frames > 0 && ad->audio_output.audio_client) {
|
||||||
|
UINT32 buffer_size;
|
||||||
UINT32 cur_frames;
|
UINT32 cur_frames;
|
||||||
bool invalidated = false;
|
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) {
|
if (hr == S_OK) {
|
||||||
// Check how much frames are available on the WASAPI buffer
|
// 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) {
|
if (write_frames > 0) {
|
||||||
BYTE *buffer = nullptr;
|
BYTE *buffer = nullptr;
|
||||||
hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer);
|
hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer);
|
||||||
|
|
Loading…
Reference in a new issue