Author: janderwald
Date: Fri Nov 13 15:22:11 2009
New Revision: 44133
URL:
http://svn.reactos.org/svn/reactos?rev=44133&view=rev
Log:
[PSDK]
- Fix MIXEROPENDESC struct(x64 compability issue)
[MMEBUDDY]
- Fix usage of MIXEROPENDESC
[WDMAUD.DRV]
- Implement a listening thread which waits for volume level / mute control changes
Modified:
trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c
trunk/reactos/include/psdk/mmddk.h
trunk/reactos/include/reactos/libs/sound/mmebuddy.h
trunk/reactos/lib/drivers/sound/mmebuddy/deviceinstance.c
Modified: trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wdmaud.drv/wdmau…
==============================================================================
--- trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/wdmaud.drv/wdmaud.c [iso-8859-1] Fri Nov 13 15:22:11 2009
@@ -260,6 +260,13 @@
NULL);
}
+ if (DeviceType == MIXER_DEVICE_TYPE)
+ {
+ SetEvent(SoundDeviceInstance->hStopEvent);
+ CloseHandle(SoundDeviceInstance->hStopEvent);
+ CloseHandle(SoundDeviceInstance->hNotifyEvent);
+ }
+
--OpenCount;
if ( OpenCount < 1 )
@@ -280,6 +287,62 @@
{
/* Whatever... */
return MMSYSERR_NOERROR;
+}
+
+
+DWORD
+WINAPI
+MixerEventThreadRoutine(
+ LPVOID Parameter)
+{
+ HANDLE WaitObjects[2];
+ DWORD dwResult;
+ MMRESULT Result;
+ WDMAUD_DEVICE_INFO DeviceInfo;
+ PSOUND_DEVICE_INSTANCE Instance = (PSOUND_DEVICE_INSTANCE)Parameter;
+
+ /* setup wait objects */
+ WaitObjects[0] = Instance->hNotifyEvent;
+ WaitObjects[1] = Instance->hStopEvent;
+
+ /* zero device info */
+ ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO));
+
+ DeviceInfo.hDevice = Instance->Handle;
+ DeviceInfo.DeviceType = MIXER_DEVICE_TYPE;
+
+ do
+ {
+ dwResult = WaitForMultipleObjects(2, WaitObjects, FALSE, INFINITE);
+
+ if (dwResult == WAIT_OBJECT_0 + 1)
+ {
+ /* stop event was signalled */
+ break;
+ }
+
+ Result = SyncOverlappedDeviceIoControl(KernelHandle,
+ IOCTL_GET_MIXER_EVENT,
+ (LPVOID) &DeviceInfo,
+ sizeof(WDMAUD_DEVICE_INFO),
+ (LPVOID) &DeviceInfo,
+ sizeof(WDMAUD_DEVICE_INFO),
+ NULL);
+
+ if (Result == MMSYSERR_NOERROR)
+ {
+ DriverCallback(Instance->WinMM.ClientCallback,
+ HIWORD(Instance->WinMM.Flags),
+ Instance->WinMM.Handle,
+ DeviceInfo.u.MixerEvent.NotificationType,
+ Instance->WinMM.ClientCallbackInstanceData,
+ (DWORD_PTR)DeviceInfo.u.MixerEvent.Value,
+ 0);
+ }
+ }while(TRUE);
+
+ /* done */
+ return 0;
}
@@ -292,6 +355,7 @@
{
MMRESULT Result;
WDMAUD_DEVICE_INFO DeviceInfo;
+ HANDLE hThread;
if (Instance->Handle != KernelHandle)
{
@@ -299,10 +363,18 @@
return MMSYSERR_NOERROR;
}
+ Instance->hNotifyEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ if ( ! Instance->hNotifyEvent )
+ return MMSYSERR_NOMEM;
+
+ Instance->hStopEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ if ( ! Instance->hStopEvent )
+ return MMSYSERR_NOMEM;
ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO));
DeviceInfo.DeviceType = MIXER_DEVICE_TYPE;
DeviceInfo.DeviceIndex = DeviceId;
+ DeviceInfo.u.hNotifyEvent = Instance->hNotifyEvent;
Result = SyncOverlappedDeviceIoControl(KernelHandle,
IOCTL_OPEN_WDMAUD,
@@ -314,7 +386,15 @@
if ( ! MMSUCCESS(Result) )
{
- return TranslateInternalMmResult(Result);
+ CloseHandle(Instance->hNotifyEvent);
+ CloseHandle(Instance->hStopEvent);
+ return TranslateInternalMmResult(Result);
+ }
+
+ hThread = CreateThread(NULL, 0, MixerEventThreadRoutine, (LPVOID)Instance, 0, NULL);
+ if ( hThread )
+ {
+ CloseHandle(hThread);
}
/* Store sound device handle instance handle */
Modified: trunk/reactos/include/psdk/mmddk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/mmddk.h?rev=4…
==============================================================================
--- trunk/reactos/include/psdk/mmddk.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/mmddk.h [iso-8859-1] Fri Nov 13 15:22:11 2009
@@ -416,9 +416,10 @@
typedef struct tMIXEROPENDESC
{
HMIXEROBJ hmx;
- LPVOID pReserved0;
- DWORD dwCallback;
- DWORD dwInstance;
+ LPVOID pReserved0;
+ DWORD_PTR dwCallback;
+ DWORD_PTR dwInstance;
+ DWORD_PTR dnDevNode;
} MIXEROPENDESC, *LPMIXEROPENDESC;
typedef struct {
Modified: trunk/reactos/include/reactos/libs/sound/mmebuddy.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/sound…
==============================================================================
--- trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Fri Nov 13 15:22:11
2009
@@ -334,8 +334,8 @@
{
HDRVR Handle;
DWORD Flags;
- DWORD ClientCallback;
- DWORD ClientCallbackInstanceData;
+ DWORD_PTR ClientCallback;
+ DWORD_PTR ClientCallbackInstanceData;
} WinMM;
/* DO NOT TOUCH THESE OUTSIDE OF THE SOUND THREAD */
@@ -357,6 +357,8 @@
DWORD FrameSize;
DWORD BufferCount;
WAVEFORMATEX WaveFormatEx;
+ HANDLE hNotifyEvent;
+ HANDLE hStopEvent;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
/* This lives in WAVEHDR.reserved */
@@ -561,8 +563,8 @@
SetSoundDeviceInstanceMmeData(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN HDRVR MmeHandle,
- IN DWORD ClientCallback,
- IN DWORD ClientCallbackData,
+ IN DWORD_PTR ClientCallback,
+ IN DWORD_PTR ClientCallbackData,
IN DWORD Flags);
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/deviceinstance.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy…
==============================================================================
--- trunk/reactos/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1] Fri Nov 13
15:22:11 2009
@@ -353,8 +353,8 @@
SetSoundDeviceInstanceMmeData(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN HDRVR MmeHandle,
- IN DWORD ClientCallback,
- IN DWORD ClientCallbackData,
+ IN DWORD_PTR ClientCallback,
+ IN DWORD_PTR ClientCallbackData,
IN DWORD Flags)
{
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );