Author: silverblade
Date: Sun Jul 13 18:32:00 2008
New Revision: 34478
URL:
http://svn.reactos.org/svn/reactos?rev=34478&view=rev
Log:
Partially implemented wave output reset (WODM_RESET) which sends a request to
the device to stop playing and (for now) drops the current buffer, which stops
the streaming mechanism from doing anything further. This will need to be done
more cleanly later. Think I've also fixed the bug where it was crashing on
exit.
Modified:
branches/silverblade-audio/dll/win32/sndblst/sndblst.c
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streamcontrol.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streaming.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wave.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
Modified: branches/silverblade-audio/dll/win32/sndblst/sndblst.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/snd…
==============================================================================
--- branches/silverblade-audio/dll/win32/sndblst/sndblst.c [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/sndblst/sndblst.c [iso-8859-1] Sun Jul 13
18:32:00 2008
@@ -222,6 +222,9 @@
POPUP("Click for WODM_RESTART");
Result = wodMessage(0, WODM_RESTART, (DWORD) InstanceData, (DWORD) 0, 0);
+ POPUP("Click for WODM_RESET");
+ Result = wodMessage(0, WODM_RESET, (DWORD) InstanceData, (DWORD) 0, 0);
+
POPUP("Click for WODM_CLOSE test");
Result = wodMessage(0, WODM_CLOSE, (DWORD) InstanceData, (DWORD) 0, 0);
/* SOUND_DEBUG_HEX(Result); */
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] Sun Jul
13 18:32:00 2008
@@ -235,6 +235,7 @@
MMGETWAVESTATE_FUNC GetWaveDeviceState;
MMSETWAVESTATE_FUNC PauseWaveDevice;
MMSETWAVESTATE_FUNC RestartWaveDevice;
+ MMSETWAVESTATE_FUNC ResetWaveDevice;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
@@ -664,6 +665,14 @@
DefaultRestartWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+MMRESULT
+ResetWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
+MMRESULT
+DefaultResetWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
/*
wave/wodMessage.c
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] Sun Jul
13 18:32:00 2008
@@ -66,6 +66,7 @@
Device->Functions.GetWaveDeviceState = DefaultGetWaveDeviceState;
Device->Functions.PauseWaveDevice = DefaultPauseWaveDevice;
Device->Functions.RestartWaveDevice = DefaultRestartWaveDevice;
+ Device->Functions.ResetWaveDevice = DefaultResetWaveDevice;
if ( ! SourceFunctionTable )
{
@@ -121,6 +122,12 @@
{
Device->Functions.RestartWaveDevice =
SourceFunctionTable->RestartWaveDevice;
+ }
+
+ if ( SourceFunctionTable->ResetWaveDevice )
+ {
+ Device->Functions.ResetWaveDevice =
+ SourceFunctionTable->ResetWaveDevice;
}
TRACE_EXIT(0);
@@ -226,6 +233,7 @@
PSOUND_DEVICE PreviousDevice = NULL;
/*TRACE_("Removing a sound device from list %d\n", DeviceType);*/
+ TRACE_ENTRY();
VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
@@ -234,11 +242,13 @@
/* Clean up any instances */
if ( SoundDevice->FirstInstance != NULL )
{
+ TRACE_("About to destroy all instances of this sound device\n");
DestroyAllInstancesOfSoundDevice(SoundDevice);
}
if ( SoundDeviceLists[TypeIndex] == SoundDevice )
{
+ TRACE_("Removing head of list\n");
SoundDeviceLists[TypeIndex] = SoundDevice->Next;
Done = TRUE;
}
@@ -247,6 +257,8 @@
/* Remove from list */
CurrentDevice = SoundDeviceLists[TypeIndex];
PreviousDevice = NULL;
+
+ TRACE_("Removing from list\n");
while ( CurrentDevice )
{
@@ -266,8 +278,11 @@
ASSERT(Done);
+ TRACE_("Freeing path at %p\n", SoundDevice->DevicePath);
/* Free the memory associated with the device info */
FreeMemory(SoundDevice->DevicePath);
+
+ TRACE_("Freeing struct\n");
FreeMemory(SoundDevice);
TRACE_EXIT(MMSYSERR_NOERROR);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c [iso-8859-1] Sun Jul
13 18:32:00 2008
@@ -20,6 +20,7 @@
static HANDLE ProcessHeapHandle = INVALID_HANDLE_VALUE;
static DWORD CurrentAllocations = 0;
+#if 0
typedef struct _ALLOCATION
{
DWORD Tag;
@@ -68,6 +69,40 @@
ZeroMemory(AllocationInfo, AllocationInfo->Size + sizeof(ALLOCATION));
HeapFree(ProcessHeapHandle, 0, AllocationInfo);
+
+ -- CurrentAllocations;
+}
+#endif
+
+PVOID
+AllocateTaggedMemory(
+ IN DWORD Tag,
+ IN DWORD Size)
+{
+ PVOID Pointer = NULL;
+
+ if ( ProcessHeapHandle == INVALID_HANDLE_VALUE )
+ ProcessHeapHandle = GetProcessHeap();
+
+ Pointer = HeapAlloc(ProcessHeapHandle, HEAP_ZERO_MEMORY, Size);
+
+ if ( ! Pointer )
+ return NULL;
+
+ ++ CurrentAllocations;
+
+ return Pointer;
+}
+
+VOID
+FreeTaggedMemory(
+ IN DWORD Tag,
+ IN PVOID Pointer)
+{
+ ASSERT(ProcessHeapHandle != INVALID_HANDLE_VALUE);
+ ASSERT(Pointer);
+
+ HeapFree(ProcessHeapHandle, 0, Pointer);
-- CurrentAllocations;
}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streamcontrol.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streamcontrol.c
[iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streamcontrol.c
[iso-8859-1] Sun Jul 13 18:32:00 2008
@@ -47,14 +47,21 @@
VALIDATE_MMSYS_PARAMETER( BufferHeader );
VALIDATE_MMSYS_PARAMETER( BufferHeader->lpData );
VALIDATE_MMSYS_PARAMETER( BufferHeader->dwBufferLength > 0 );
- /* TODO: Check anything more about this buffer? */
-
- if ( ! (BufferHeader->dwFlags & WHDR_PREPARED ) )
+
+ /* Make sure the buffer flags are sane */
+ BufferHeader->dwFlags &= WHDR_INQUEUE | WHDR_DONE | WHDR_PREPARED |
+ WHDR_BEGINLOOP | WHDR_ENDLOOP;
+
+ if ( ! ( BufferHeader->dwFlags & WHDR_PREPARED ) )
return WAVERR_UNPREPARED;
- /* TODO: WHDR_INQUEUE */
-
+ if ( ( BufferHeader->dwFlags & WHDR_INQUEUE ) )
+ return WAVERR_STILLPLAYING;
+
+ /* Clear the "done" flag */
BufferHeader->dwFlags &= ~WHDR_DONE;
+
+ /* ...and at present there's nothing after this buffer, so we do this: */
BufferHeader->lpNext = NULL;
return CallUsingSoundThread(SoundDeviceInstance,
@@ -172,3 +179,36 @@
TRACE_EXIT(Result);
return Result;
}
+
+MMRESULT
+ResetWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+
+ return CallUsingSoundThread(SoundDeviceInstance,
+ ResetWaveDevice_Request,
+ NULL);
+}
+
+MMRESULT
+DefaultResetWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ ULONG RequestedState = WAVE_DD_RESET;
+ MMRESULT Result;
+
+ TRACE_ENTRY();
+
+ Result = SendToSoundDevice(SoundDeviceInstance,
+ IOCTL_WAVE_SET_STATE,
+ &RequestedState,
+ sizeof(RequestedState),
+ NULL);
+
+ ASSERT( Result == MMSYSERR_NOERROR );
+
+ Result = TranslateInternalMmResult(Result);
+ TRACE_EXIT(Result);
+ return Result;
+}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streaming.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streaming.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/streaming.c [iso-8859-1]
Sun Jul 13 18:32:00 2008
@@ -334,3 +334,29 @@
return Functions->RestartWaveDevice(SoundDeviceInstance);
}
+
+/* This is quite horribly broken */
+MMRESULT
+ResetWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE Functions;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance,
+ &SoundDevice);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice,
+ &Functions);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ /* ugly HACK to stop sound playback... FIXME */
+ SoundDeviceInstance->Streaming.Wave.CurrentBuffer = NULL;
+
+ return Functions->ResetWaveDevice(SoundDeviceInstance);
+}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wave.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wave.h [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wave.h [iso-8859-1] Sun Jul
13 18:32:00 2008
@@ -32,4 +32,9 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter);
+MMRESULT
+ResetWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter);
+
#endif
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]
Sun Jul 13 18:32:00 2008
@@ -144,6 +144,12 @@
}
case WODM_RESET :
+ {
+ ASSERT(Instance != NULL);
+
+ return ResetWaveDevice(Instance);
+ }
+
case WODM_BREAKLOOP :
return MMSYSERR_INVALHANDLE;