Author: silverblade
Date: Sun Jul 13 17:53:53 2008
New Revision: 34475
URL:
http://svn.reactos.org/svn/reactos?rev=34475&view=rev
Log:
Implemented functions required to make wave playback pause and resume function
(WODM_PAUSE and WODM_RESTART) using IOCTL_WAVE_SET_STATE. Modified internal
I/O control routine to deal with the fact the device does overlapped I/O.
Verified pause/resume functions, however there is a crash on exit if all
audio buffers are exhausted by the time WODM_CLOSE is issued.
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/capabilities.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.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/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
17:53:53 2008
@@ -216,6 +216,12 @@
// SOUND_DEBUG_HEX(Result);
+ POPUP("Click for WODM_PAUSE");
+ Result = wodMessage(0, WODM_PAUSE, (DWORD) InstanceData, (DWORD) 0, 0);
+
+ POPUP("Click for WODM_RESTART");
+ Result = wodMessage(0, WODM_RESTART, (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 17:53:53 2008
@@ -217,7 +217,7 @@
typedef MMRESULT (*MMGETWAVESTATE_FUNC)(
IN struct _SOUND_DEVICE_INSTANCE* Instance,
- OUT PUCHAR State);
+ OUT PULONG State);
typedef MMRESULT (*MMSETWAVESTATE_FUNC)(
IN struct _SOUND_DEVICE_INSTANCE* Instance);
@@ -262,8 +262,6 @@
typedef struct _WAVE_STREAM_INFO
{
- /* Current wave stream state */
- WORD State;
/* Buffer queue head and tail */
PWAVEHDR BufferQueueHead;
PWAVEHDR BufferQueueTail;
@@ -446,7 +444,7 @@
IN LPOVERLAPPED Overlapped);
MMRESULT
-ReadFromDeviceHandle(
+RetrieveFromDeviceHandle(
IN HANDLE Handle,
IN DWORD IoControlCode,
OUT LPVOID OutBuffer,
@@ -455,7 +453,7 @@
IN LPOVERLAPPED Overlapped);
MMRESULT
-WriteToDeviceHandle(
+SendToDeviceHandle(
IN HANDLE Handle,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
@@ -471,26 +469,23 @@
IN DWORD InBufferSize,
OUT LPVOID OutBuffer,
IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped);
-
-MMRESULT
-ReadFromSoundDevice(
+ OUT LPDWORD BytesReturned);
+
+MMRESULT
+RetrieveFromSoundDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN DWORD IoControlCode,
OUT LPVOID OutBuffer,
IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped);
-
-MMRESULT
-WriteToSoundDevice(
+ OUT LPDWORD BytesReturned);
+
+MMRESULT
+SendToSoundDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped);
+ OUT LPDWORD BytesReturned);
MMRESULT
WriteSoundDeviceBuffer(
@@ -646,12 +641,12 @@
MMRESULT
GetWaveDeviceState(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PUCHAR State);
+ OUT PULONG State);
MMRESULT
DefaultGetWaveDeviceState(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PUCHAR State);
+ OUT PULONG State);
MMRESULT
PauseWaveDevice(
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/capabilities.c [iso-8859-1] Sun
Jul 13 17:53:53 2008
@@ -95,7 +95,7 @@
}
/* Call the driver */
- Result = ReadFromDeviceHandle(
+ Result = RetrieveFromDeviceHandle(
Handle,
Ioctl,
(LPVOID) RawCapsPtr,
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c [iso-8859-1] Sun Jul 13
17:53:53 2008
@@ -94,15 +94,15 @@
IN LPOVERLAPPED Overlapped)
{
BOOLEAN IoResult = FALSE;
- DWORD AccessRights = GENERIC_READ;
VALIDATE_MMSYS_PARAMETER( Handle != INVALID_HANDLE_VALUE );
- /* Determine if we actually need to write stuff */
- if ( InBuffer != NULL )
- AccessRights |= GENERIC_WRITE;
-
- MessageBox(0, L"Doing IO", L"Info", MB_OK | MB_TASKMODAL);
+ /*MessageBox(0, L"Doing IO", L"Info", MB_OK | MB_TASKMODAL);*/
+
+ TRACE_("IoCtl on handle %d - in %p (%d), out %p (%d)\n",
+ (int) Handle, InBuffer, (int) InBufferSize, OutBuffer,
+ (int) OutBufferSize);
+
IoResult = DeviceIoControl(
Handle,
IoControlCode,
@@ -113,8 +113,10 @@
BytesReturned,
Overlapped);
+
if ( ! IoResult )
{
+ TRACE_("IoCtl result %d\n", (int) GetLastError());
return Win32ErrorToMmResult(GetLastError());
}
@@ -122,7 +124,7 @@
}
MMRESULT
-ReadFromDeviceHandle(
+RetrieveFromDeviceHandle(
IN HANDLE Handle,
IN DWORD IoControlCode,
OUT LPVOID OutBuffer,
@@ -141,7 +143,7 @@
}
MMRESULT
-WriteToDeviceHandle(
+SendToDeviceHandle(
IN HANDLE Handle,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
@@ -167,33 +169,75 @@
IN DWORD InBufferSize,
OUT LPVOID OutBuffer,
IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped)
-{
+ OUT LPDWORD BytesTransferred)
+{
+ /*
+ NOTE: This will always do overlapped I/O, which we wait for.
+ */
+
+ OVERLAPPED Overlapped;
+ BOOLEAN IoResult;
+ MMRESULT Result;
+ DWORD Transferred;
+
if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
return MMSYSERR_INVALPARAM;
if ( SoundDeviceInstance->Handle == INVALID_HANDLE_VALUE )
return MMSYSERR_ERROR;
- return PerformDeviceIo(SoundDeviceInstance->Handle,
- IoControlCode,
- InBuffer,
- InBufferSize,
- OutBuffer,
- OutBufferSize,
- BytesReturned,
- Overlapped);
-}
-
-MMRESULT
-ReadFromSoundDevice(
+ ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
+
+ /* This event is used for announcing the I/O operation completed */
+ Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+
+ if ( Overlapped.hEvent == INVALID_HANDLE_VALUE )
+ return Win32ErrorToMmResult(GetLastError());
+
+ TRACE_("** Overlapped at %p\n", &Overlapped);
+
+ Result = PerformDeviceIo(SoundDeviceInstance->Handle,
+ IoControlCode,
+ InBuffer,
+ InBufferSize,
+ OutBuffer,
+ OutBufferSize,
+ NULL,
+ &Overlapped);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ return Result;
+ }
+
+ /* Wait for I/O completion */
+ IoResult = GetOverlappedResult(SoundDeviceInstance->Handle,
+ &Overlapped,
+ &Transferred,
+ TRUE);
+
+ CloseHandle(Overlapped.hEvent);
+
+ if ( ! IoResult )
+ {
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ if ( BytesTransferred )
+ {
+ *BytesTransferred = Transferred;
+ }
+
+ return Result;
+}
+
+MMRESULT
+RetrieveFromSoundDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN DWORD IoControlCode,
OUT LPVOID OutBuffer,
IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped)
+ OUT LPDWORD BytesReturned)
{
return PerformSoundDeviceIo(SoundDeviceInstance,
IoControlCode,
@@ -201,18 +245,16 @@
0,
OutBuffer,
OutBufferSize,
- BytesReturned,
- Overlapped);
-}
-
-MMRESULT
-WriteToSoundDevice(
+ BytesReturned);
+}
+
+MMRESULT
+SendToSoundDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped)
+ OUT LPDWORD BytesReturned)
{
return PerformSoundDeviceIo(SoundDeviceInstance,
IoControlCode,
@@ -220,8 +262,7 @@
InBufferSize,
NULL,
0,
- BytesReturned,
- Overlapped);
+ BytesReturned);
}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c [iso-8859-1] Sun Jul 13
17:53:53 2008
@@ -44,6 +44,7 @@
PSOUND_THREAD_OVERLAPPED SoundOverlapped;
TRACE_("** I/O has completed\n");
+ TRACE_("** Returned overlapped at %p\n", lpOverlapped);
SoundOverlapped = (PSOUND_THREAD_OVERLAPPED) lpOverlapped;
ASSERT(SoundOverlapped);
@@ -155,14 +156,18 @@
/* Wait for a request, or an I/O completion */
WaitResult = WaitForSingleObjectEx(RequestEvent, INFINITE, TRUE);
+ TRACE_("Came out of waiting\n");
if ( WaitResult == WAIT_OBJECT_0 )
{
/* Process the request */
+ TRACE_("Processing request\n");
+
ASSERT(CurrentRequest.RequestHandler);
if ( CurrentRequest.RequestHandler )
{
+ TRACE_("Calling function %p\n",
CurrentRequest.RequestHandler);
CurrentRequest.ReturnValue = CurrentRequest.RequestHandler(
CurrentRequest.SoundDeviceInstance,
CurrentRequest.Parameter);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c [iso-8859-1] Sun
Jul 13 17:53:53 2008
@@ -79,12 +79,11 @@
if ( Result != MMSYSERR_NOERROR )
return Result;
- Result = WriteToSoundDevice(Handle,
- IOCTL_WAVE_QUERY_FORMAT,
- (LPVOID) WaveFormat,
- WaveFormatSize,
- &BytesReturned,
- NULL);
+ Result = SendToSoundDevice(Handle,
+ IOCTL_WAVE_QUERY_FORMAT,
+ (LPVOID) WaveFormat,
+ WaveFormatSize,
+ &BytesReturned);
CloseKernelSoundDevice(Handle);
@@ -153,12 +152,11 @@
/* Make sure we have a wave device */
VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) );
- Result = WriteToSoundDevice(SoundDeviceInstance,
- IOCTL_WAVE_SET_FORMAT,
- (LPVOID) WaveFormat,
- WaveFormatSize,
- &BytesReturned,
- NULL);
+ Result = SendToSoundDevice(SoundDeviceInstance,
+ IOCTL_WAVE_SET_FORMAT,
+ (LPVOID) WaveFormat,
+ WaveFormatSize,
+ &BytesReturned);
return Result;
}
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 17:53:53 2008
@@ -27,7 +27,7 @@
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- StreamInfo->State = WAVE_DD_IDLE;
+ /*StreamInfo->State = WAVE_DD_IDLE;*/
StreamInfo->BufferQueueHead = NULL;
StreamInfo->BufferQueueTail = NULL;
@@ -65,7 +65,7 @@
MMRESULT
GetWaveDeviceState(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PUCHAR State)
+ OUT PULONG State)
{
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
VALIDATE_MMSYS_PARAMETER( State );
@@ -78,45 +78,66 @@
MMRESULT
DefaultGetWaveDeviceState(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PUCHAR State)
+ OUT PULONG State)
{
-// MMRESULT Result;
+ MMRESULT Result;
+
+ TRACE_ENTRY();
ASSERT(SoundDeviceInstance);
ASSERT(State);
-/*
- Result = WriteSoundDevice(S
-MMRESULT
-WriteSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID InBuffer,
- DWORD InBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped)
-*/
- return MMSYSERR_NOERROR;
+ Result = RetrieveFromSoundDevice(SoundDeviceInstance,
+ IOCTL_WAVE_GET_STATE,
+ State,
+ sizeof(ULONG),
+ NULL);
+
+ ASSERT( Result == MMSYSERR_NOERROR );
+
+ Result = TranslateInternalMmResult(Result);
+ TRACE_EXIT(Result);
+
+ return Result;
}
MMRESULT
PauseWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
+ MMRESULT Result;
+ TRACE_ENTRY();
+
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
- return CallUsingSoundThread(SoundDeviceInstance,
- PauseWaveDevice_Request,
- NULL);
+ Result = CallUsingSoundThread(SoundDeviceInstance,
+ PauseWaveDevice_Request,
+ NULL);
+
+ TRACE_EXIT(Result);
+ return Result;
}
MMRESULT
DefaultPauseWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
- TRACE_("Pausing device\n");
- /* TODO */
- return MMSYSERR_NOERROR;
+ ULONG RequestedState = WAVE_DD_STOP;
+ 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;
}
MMRESULT
@@ -134,7 +155,20 @@
DefaultRestartWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
- TRACE_("Restarting device\n");
- /* TODO */
- return MMSYSERR_NOERROR;
+ ULONG RequestedState = WAVE_DD_PLAY;
+ 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 17:53:53 2008
@@ -82,10 +82,10 @@
/* If we're out of buffers, mark stream as stopped and do nothing */
if ( ! StreamInfo->CurrentBuffer )
{
- TRACE_("*** NOTHING TO DO - state is now WAVE_DD_IDLE ***\n");
+ TRACE_("*** NOTHING TO DO ***\n");
/* The stream is idle */
- StreamInfo->State = WAVE_DD_IDLE;
+ /*StreamInfo->State = WAVE_DD_IDLE;*/
return 0;
}
@@ -120,8 +120,10 @@
/* TODO: Deal with INPUT as well */
if ( DeviceType == WAVE_OUT_DEVICE_TYPE )
{
+ /*
TRACE_("Streamed data - state is now WAVE_DD_PLAYING\n");
StreamInfo->State = WAVE_DD_PLAYING;
+ */
}
else
{
@@ -270,7 +272,7 @@
MMRESULT Result;
PSOUND_DEVICE SoundDevice;
PMMFUNCTION_TABLE Functions;
- PUCHAR State = (PUCHAR) Parameter;
+ PULONG State = (PULONG) Parameter;
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
VALIDATE_MMSYS_PARAMETER( State );
@@ -316,13 +318,19 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter)
{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE Functions;
+
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
- if ( SoundDeviceInstance->Streaming.Wave.State != WAVE_DD_STOPPED )
- {
- WARN_("Nothing to do\n");
- return MMSYSERR_NOERROR;
- }
-
- return MMSYSERR_NOERROR;
-}
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance,
+ &SoundDevice);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice,
+ &Functions);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ return Functions->RestartWaveDevice(SoundDeviceInstance);
+}
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 17:53:53 2008
@@ -131,11 +131,15 @@
case WODM_PAUSE :
{
+ ASSERT(Instance != NULL);
+
return PauseWaveDevice(Instance);
}
case WODM_RESTART :
{
+ ASSERT(Instance != NULL);
+
return RestartWaveDevice(Instance);
}