Author: silverblade
Date: Fri Jan 2 19:59:50 2009
New Revision: 38516
URL:
http://svn.reactos.org/svn/reactos?rev=38516&view=rev
Log:
Implemented callback mechanism, wired this up to the wave device opening and
closing routines. Media Player on Windows NT can now open and close the
device and will exit properly, letting go of the device now.
Modified:
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmewrap.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
Modified: branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/react…
==============================================================================
--- branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1]
(original)
+++ branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Fri Jan
2 19:59:50 2009
@@ -198,6 +198,15 @@
{
struct _SOUND_DEVICE* Device;
PVOID Handle;
+
+ /* Stuff generously donated to us from WinMM */
+ struct
+ {
+ HDRVR Handle;
+ DWORD Flags;
+ DWORD ClientCallback;
+ DWORD ClientCallbackInstanceData;
+ } WinMM;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
@@ -223,6 +232,12 @@
/*
mme.c
*/
+
+VOID
+NotifyMmeClient(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD Message,
+ IN DWORD Parameter);
MMRESULT
MmeGetSoundDeviceCapabilities(
@@ -347,6 +362,14 @@
GetSoundDeviceInstanceHandle(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PVOID* Handle);
+
+MMRESULT
+SetSoundDeviceInstanceMmeData(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN HDRVR MmeHandle,
+ IN DWORD ClientCallback,
+ IN DWORD ClientCallbackData,
+ IN DWORD Flags);
/*
@@ -613,14 +636,6 @@
HANDLE Handle;
/* PSOUND_THREAD Thread;*/
- /* Stuff generously donated to us from WinMM */
- struct
- {
- HDRVR Handle;
- DWORD Flags;
- DWORD ClientCallback;
- DWORD ClientCallbackInstanceData;
- } WinMM;
/* Device-specific parameters */
union
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1]
Fri Jan 2 19:59:50 2009
@@ -189,3 +189,24 @@
return MMSYSERR_NOERROR;
}
+
+MMRESULT
+SetSoundDeviceInstanceMmeData(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN HDRVR MmeHandle,
+ IN DWORD ClientCallback,
+ IN DWORD ClientCallbackData,
+ IN DWORD Flags)
+{
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+
+ SND_TRACE(L"Setting MME data - handle %x, callback %x, instance data %x, flags
%x\n",
+ MmeHandle, ClientCallback, ClientCallbackData, Flags);
+
+ SoundDeviceInstance->WinMM.Handle = MmeHandle;
+ SoundDeviceInstance->WinMM.ClientCallback = ClientCallback;
+ SoundDeviceInstance->WinMM.ClientCallbackInstanceData = ClientCallbackData;
+ SoundDeviceInstance->WinMM.Flags = Flags;
+
+ return MMSYSERR_NOERROR;
+}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmewrap.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmewrap.c [iso-8859-1] Fri Jan
2 19:59:50 2009
@@ -14,6 +14,35 @@
#include <ntddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
+
+/*
+ Call the client application when something interesting happens (MME API
+ defines "interesting things" as device open, close, and buffer
+ completion.)
+*/
+VOID
+NotifyMmeClient(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD Message,
+ IN DWORD Parameter)
+{
+ ASSERT( SoundDeviceInstance );
+
+ SND_TRACE(L"MME client callback - message %d, parameter %d\n",
+ (int) Message,
+ (int) Parameter);
+
+ if ( SoundDeviceInstance->WinMM.ClientCallback )
+ {
+ DriverCallback(SoundDeviceInstance->WinMM.ClientCallback,
+ HIWORD(SoundDeviceInstance->WinMM.Flags),
+ SoundDeviceInstance->WinMM.Handle,
+ Message,
+ SoundDeviceInstance->WinMM.ClientCallbackInstanceData,
+ Parameter,
+ 0);
+ }
+}
/*
This is a helper function to alleviate some of the repetition involved with
@@ -101,9 +130,19 @@
/* Store the device instance pointer in the private handle - is DWORD safe here? */
*PrivateHandle = (DWORD) SoundDeviceInstance;
- /* TODO: Call the client application back to say the device is open */
+ /* Store the additional information we were given - FIXME: Need flags! */
+ SetSoundDeviceInstanceMmeData(SoundDeviceInstance,
+ (HDRVR)OpenParameters->hWave,
+ OpenParameters->dwCallback,
+ OpenParameters->dwInstance,
+ Flags);
+
+ /* Let the application know the device is open */
ReleaseEntrypointMutex(DeviceType);
- /* ... */
+ NotifyMmeClient(SoundDeviceInstance,
+ DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_OPEN : WIM_OPEN,
+ 0);
+
AcquireEntrypointMutex(DeviceType);
SND_TRACE(L"Wave device now open\n");
@@ -118,12 +157,28 @@
/* FIXME - Where do we call the callback?? */
MMRESULT Result;
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
+ PSOUND_DEVICE SoundDevice;
+ MMDEVICE_TYPE DeviceType;
SND_TRACE(L"Closing wave device (WIDM_CLOSE / WODM_CLOSE)\n");
VALIDATE_MMSYS_PARAMETER( PrivateHandle );
SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ ReleaseEntrypointMutex(DeviceType);
+ NotifyMmeClient(SoundDeviceInstance,
+ DeviceType == WAVE_OUT_DEVICE_TYPE ? WOM_CLOSE : WIM_CLOSE,
+ 0);
+ AcquireEntrypointMutex(DeviceType);
+
Result = DestroySoundDeviceInstance(SoundDeviceInstance);
return Result;
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c [iso-8859-1]
Fri Jan 2 19:59:50 2009
@@ -64,14 +64,18 @@
case WODM_CLOSE :
{
- /*
- What should happen here?
- - Validate the sound device instance
- - Destroy it
- */
Result = MmeCloseDevice(PrivateHandle);
break;
+ }
+
+ case WODM_PREPARE :
+ {
+ /*Result = MmeWavePrepare(*/
+ }
+
+ case WODM_UNPREPARE :
+ {
}
}