From 81f8bcea8c9456124eaa422a155e6bbced4319f0 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Sun, 27 Jun 2021 23:04:36 +0200 Subject: [PATCH] [DSOUND][WAVE] Workaround crash when recording sound in Scratch 1.4 CORE-13202 It regressed by SVN r44721 == git 356d4bab16092de335705e02b0e87698ec35c393 when #define USE_MMIXER_LIB was removed. Thanks to the patches author Doug Lyons. VBox https://reactos.org/testman/compare.php?ids=77914,77919 LGTM KVM https://reactos.org/testman/compare.php?ids=77913,77918 LGTM --- dll/directx/wine/dsound/capture.c | 6 ++++++ sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/dll/directx/wine/dsound/capture.c b/dll/directx/wine/dsound/capture.c index b8df4f52488..35533de0805 100644 --- a/dll/directx/wine/dsound/capture.c +++ b/dll/directx/wine/dsound/capture.c @@ -846,6 +846,12 @@ static HRESULT IDirectSoundCaptureBufferImpl_Create( wfex->nAvgBytesPerSec, wfex->nBlockAlign, wfex->wBitsPerSample, wfex->cbSize); + /* Do some sanity checks for 'recording' SamplesPerSec value */ + if (wfex->nSamplesPerSec > 100000) + wfex->nSamplesPerSec = 100000; + if (wfex->nSamplesPerSec < 5000) + wfex->nSamplesPerSec = 5000; + device->pwfx = DSOUND_CopyFormat(wfex); if ( device->pwfx == NULL ) { *ppobj = NULL; diff --git a/sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c b/sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c index 81fd344a413..c2e8363a237 100644 --- a/sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c +++ b/sdk/lib/drivers/sound/mmebuddy/wave/widMessage.c @@ -61,6 +61,14 @@ widMessage( } case WIDM_OPEN : { + + /* Do sanity checks for 'recording' SamplesPerSec value */ + LPWAVEOPENDESC OpenParameters = (LPWAVEOPENDESC)Parameter1; + if (OpenParameters->lpFormat->nSamplesPerSec > 100000) + OpenParameters->lpFormat->nSamplesPerSec = 100000; + if (OpenParameters->lpFormat->nSamplesPerSec < 5000) + OpenParameters->lpFormat->nSamplesPerSec = 5000; + Result = MmeOpenDevice(WAVE_IN_DEVICE_TYPE, DeviceId, (LPWAVEOPENDESC) Parameter1,