From 1d04f03a852bdb98946ef2c286a20f6b675f55f4 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 18 Sep 2019 17:39:50 +1000 Subject: [PATCH] WASAPI: Get WASAPI to perform automatic resampling. --- miniaudio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index 0e8f4b18..a9e846df 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -7862,7 +7862,7 @@ ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device_type d pData->pRenderClient = NULL; pData->pCaptureClient = NULL; - streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK; + streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK | MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY; if (deviceType == ma_device_type_loopback) { streamFlags |= MA_AUDCLNT_STREAMFLAGS_LOOPBACK; } @@ -7953,6 +7953,9 @@ ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device_type d goto done; } + /* Override the native sample rate with the one requested by the caller. We'll use WASAPI to perform the sample rate conversion. */ + wf.Format.nSamplesPerSec = pData->sampleRateIn; + pData->formatOut = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)&wf); pData->channelsOut = wf.Format.nChannels; pData->sampleRateOut = wf.Format.nSamplesPerSec;