[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
This commit is contained in:
Joachim Henze 2021-06-27 23:04:36 +02:00
parent 979b7d4d8e
commit 81f8bcea8c
2 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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,