From 38c83fc14b790ec307d5e06bdd4705b821c07c2e Mon Sep 17 00:00:00 2001 From: Won-Kyu Park Date: Mon, 26 Jul 2021 17:09:07 +0900 Subject: [PATCH] try to setup desired sampleRate --- source/device.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/device.cpp b/source/device.cpp index 84c9eb3..531c560 100644 --- a/source/device.cpp +++ b/source/device.cpp @@ -468,6 +468,16 @@ bool HDevice::SetupAudioCapture(IBaseFilter *filter, AudioConfig &config) Error(L"Could not get closest audio media type"); return false; } + } else { + // useDefaultConfig case + if (config.sampleRate != 0) { + WAVEFORMATEX *wfex = reinterpret_cast( + audioMediaType->pbFormat); + // set the desired sampleRate + wfex->nSamplesPerSec = config.sampleRate; + Debug(L"\tdesired sampleRate = %d", config.sampleRate); + wfex->nAvgBytesPerSec = wfex->nSamplesPerSec * wfex->nBlockAlign; + } } if (!!pinConfig) {