Author: janderwald
Date: Fri Feb 25 16:00:26 2011
New Revision: 50900
URL:
http://svn.reactos.org/svn/reactos?rev=50900&view=rev
Log:
[WDMAUD.DRV]
- Check if the provided waveformat is at least size of WAVEFORMAT
- Compute extra details such as the size or wBitsPerSample from the provided members
- Backup i/o completion handle before commiting the audio buffer as the struct might have
already been released
- Fixes playback of mmsys cpl
- Found by DPH!
Modified:
trunk/reactos/dll/win32/wdmaud.drv/legacy.c
Modified: trunk/reactos/dll/win32/wdmaud.drv/legacy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/legac…
==============================================================================
--- trunk/reactos/dll/win32/wdmaud.drv/legacy.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/wdmaud.drv/legacy.c [iso-8859-1] Fri Feb 25 16:00:26 2011
@@ -476,7 +476,7 @@
DeviceInfo.u.WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
DeviceInfo.u.WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
- DeviceInfo.u.WaveFormatEx.wBitsPerSample = WaveFormat->wBitsPerSample;
+ DeviceInfo.u.WaveFormatEx.wBitsPerSample = (DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec
* 8) / (DeviceInfo.u.WaveFormatEx.nSamplesPerSec * DeviceInfo.u.WaveFormatEx.nChannels);
#endif
Result = SyncOverlappedDeviceIoControl(KernelHandle,
@@ -492,14 +492,19 @@
return TranslateInternalMmResult(Result);
}
- /* Store format */
- Instance->WaveFormatEx.cbSize = WaveFormat->cbSize;
- Instance->WaveFormatEx.wFormatTag = WaveFormat->wFormatTag;
- Instance->WaveFormatEx.nChannels = WaveFormat->nChannels;
- Instance->WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
- Instance->WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
- Instance->WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
- Instance->WaveFormatEx.wBitsPerSample = WaveFormat->wBitsPerSample;
+ if (WaveFormatSize >= sizeof(WAVEFORMAT))
+ {
+ /* Store format */
+ Instance->WaveFormatEx.wFormatTag = WaveFormat->wFormatTag;
+ Instance->WaveFormatEx.nChannels = WaveFormat->nChannels;
+ Instance->WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
+ Instance->WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
+ Instance->WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
+ }
+
+ /* store details */
+ Instance->WaveFormatEx.cbSize = sizeof(WAVEFORMATEX);
+ Instance->WaveFormatEx.wBitsPerSample = (DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec
* 8) / (DeviceInfo.u.WaveFormatEx.nSamplesPerSec * DeviceInfo.u.WaveFormatEx.nChannels);
/* Store sound device handle instance handle */
Instance->Handle = (PVOID)DeviceInfo.hDevice;
@@ -617,7 +622,7 @@
// create completion event
- Overlap->Standard.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ Overlap->Standard.hEvent = Handle = CreateEventW(NULL, FALSE, FALSE, NULL);
if (Overlap->Standard.hEvent == NULL)
{
// no memory
@@ -641,12 +646,10 @@
}
// close event handle
- CloseHandle(Overlap->Standard.hEvent);
+ CloseHandle(Handle);
return MMSYSERR_NOERROR;
}
-
-
MMRESULT
WdmAudSetWaveStateByLegacy(