From 1e3850cd25124c91626d0993981b9dc12eaacd15 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 11 Jul 2009 22:02:30 +0000 Subject: [PATCH] [WDMAUD.DRV] - The wave / mixer / midi handles are kernel handles, consequently wdmaud_kernel must close them svn path=/trunk/; revision=41894 --- reactos/dll/win32/wdmaud.drv/wdmaud.c | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/wdmaud.drv/wdmaud.c b/reactos/dll/win32/wdmaud.drv/wdmaud.c index bb3f38660cc..24088d4d0b7 100644 --- a/reactos/dll/win32/wdmaud.drv/wdmaud.c +++ b/reactos/dll/win32/wdmaud.drv/wdmaud.c @@ -175,6 +175,18 @@ CloseWdmSoundDevice( IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance, IN PVOID Handle) { + WDMAUD_DEVICE_INFO DeviceInfo; + MMRESULT Result; + MMDEVICE_TYPE DeviceType; + PSOUND_DEVICE SoundDevice; + + Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice); + + if ( ! MMSUCCESS(Result) ) + { + return TranslateInternalMmResult(Result); + } + if ( OpenCount == 0 ) { return MMSYSERR_NOERROR; @@ -182,9 +194,23 @@ CloseWdmSoundDevice( SND_ASSERT( KernelHandle != INVALID_HANDLE_VALUE ); + Result = GetSoundDeviceType(SoundDevice, &DeviceType); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + if (SoundDeviceInstance->Handle != (PVOID)KernelHandle) { - CloseHandle((HANDLE)SoundDeviceInstance->Handle); + ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO)); + + DeviceInfo.DeviceType = DeviceType; + DeviceInfo.hDevice = SoundDeviceInstance->Handle; + + SyncOverlappedDeviceIoControl(KernelHandle, + IOCTL_CLOSE_WDMAUD, + (LPVOID) &DeviceInfo, + sizeof(WDMAUD_DEVICE_INFO), + (LPVOID) &DeviceInfo, + sizeof(WDMAUD_DEVICE_INFO), + NULL); } --OpenCount;