From dec7875a6e23212021e4d9080330a42832dfe02a Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 15 Jun 2021 01:40:19 +0000
Subject: [PATCH] update SDL soruce to 2.0.14
---
source/src/audio/wasapi/SDL_wasapi.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/source/src/audio/wasapi/SDL_wasapi.c b/source/src/audio/wasapi/SDL_wasapi.c
index 622a05c..abefcca 100644
--- a/source/src/audio/wasapi/SDL_wasapi.c
+++ b/source/src/audio/wasapi/SDL_wasapi.c
@@ -18,7 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
-
#include "../../SDL_internal.h"
#if SDL_AUDIO_DRIVER_WASAPI
@@ -28,8 +27,6 @@
#include "SDL_timer.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
-#include "SDL_assert.h"
-#include "SDL_log.h"
#define COBJMACROS
#include <mmdeviceapi.h>
@@ -508,7 +505,7 @@
const SDL_AudioSpec oldspec = this->spec;
const AUDCLNT_SHAREMODE sharemode = AUDCLNT_SHAREMODE_SHARED;
UINT32 bufsize = 0; /* this is in sample frames, not samples, not bytes. */
- REFERENCE_TIME duration = 0;
+ REFERENCE_TIME default_period = 0;
IAudioClient *client = this->hidden->client;
IAudioRenderClient *render = NULL;
IAudioCaptureClient *capture = NULL;
@@ -572,7 +569,7 @@
return SDL_SetError("WASAPI: Unsupported audio format");
}
- ret = IAudioClient_GetDevicePeriod(client, NULL, &duration);
+ ret = IAudioClient_GetDevicePeriod(client, &default_period, NULL);
if (FAILED(ret)) {
return WIN_SetErrorFromHRESULT("WASAPI can't determine minimum device period", ret);
}
@@ -591,7 +588,7 @@
}
streamflags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
- ret = IAudioClient_Initialize(client, sharemode, streamflags, duration, sharemode == AUDCLNT_SHAREMODE_SHARED ? 0 : duration, waveformat, NULL);
+ ret = IAudioClient_Initialize(client, sharemode, streamflags, 0, 0, waveformat, NULL);
if (FAILED(ret)) {
return WIN_SetErrorFromHRESULT("WASAPI can't initialize audio client", ret);
}
@@ -606,9 +603,12 @@
return WIN_SetErrorFromHRESULT("WASAPI can't determine buffer size", ret);
}
- this->spec.samples = (Uint16) bufsize;
- if (!this->iscapture) {
- this->spec.samples /= 2; /* fill half of the DMA buffer on each run. */
+ /* Match the callback size to the period size to cut down on the number of
+ interrupts waited for in each call to WaitDevice */
+ {
+ const float period_millis = default_period / 10000.0f;
+ const float period_frames = period_millis * this->spec.freq / 1000.0f;
+ this->spec.samples = (Uint16)SDL_ceilf(period_frames);
}
/* Update the fragment size as size in bytes */
--
Gitblit v1.9.3