mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
[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! svn path=/trunk/; revision=50900
This commit is contained in:
@@ -476,7 +476,7 @@ WdmAudSetWaveDeviceFormatByLegacy(
|
||||
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 @@ WdmAudSetWaveDeviceFormatByLegacy(
|
||||
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 @@ WdmAudCommitWaveBufferByLegacy(
|
||||
|
||||
|
||||
// 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,13 +646,11 @@ WdmAudCommitWaveBufferByLegacy(
|
||||
}
|
||||
|
||||
// close event handle
|
||||
CloseHandle(Overlap->Standard.hEvent);
|
||||
CloseHandle(Handle);
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MMRESULT
|
||||
WdmAudSetWaveStateByLegacy(
|
||||
IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
|
||||
|
||||
Reference in New Issue
Block a user