Author: silverblade
Date: Sat Jan 3 01:15:48 2009
New Revision: 38520
URL:
http://svn.reactos.org/svn/reactos?rev=38520&view=rev
Log:
Started implementing WAVEHDR prepare/unprepare/submit routines (they call
the function table entries, nothing is on the other end). Also re-worked my
previous streaming thread code to operate on a per-device-instance basis and
tested the new implementation is capable of dispatching requests properly.
Added:
branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/header.c (with props)
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/deviceinstance.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmewrap.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/format.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
branches/silverblade-audio/lib/drivers/sound/mment4/control.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] Sat Jan 3
01:15:48 2009
@@ -47,7 +47,7 @@
Capabilities,
CapabilitiesSize);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return Result;
/* Inject the appropriate device name */
@@ -90,7 +90,7 @@
Result = ListSoundDevice(DeviceType, (PVOID) PathCopy, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
return TranslateInternalMmResult(Result);
return FALSE;
@@ -102,6 +102,9 @@
FuncTable.SetWaveFormat = SetNt4WaveDeviceFormat;
FuncTable.Open = OpenNt4SoundDevice;
FuncTable.Close = CloseNt4SoundDevice;
+ FuncTable.PrepareWaveHeader = NULL;
+ FuncTable.UnprepareWaveHeader = NULL;
+ FuncTable.SubmitWaveHeader = NULL;
SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
@@ -126,14 +129,14 @@
Result = InitEntrypointMutexes();
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return 0L;
Result = EnumerateNt4ServiceSoundDevices(L"sndblst",
0,
FoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
CleanupEntrypointMutexes();
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] Sat Jan
3 01:15:48 2009
@@ -153,6 +153,9 @@
DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIOUTCAPS_FUNC, LPMIDIOUTCAPS);
DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIINCAPS_FUNC, LPMIDIINCAPS );
+struct _SOUND_DEVICE;
+struct _SOUND_DEVICE_INSTANCE;
+
typedef MMRESULT (*MMWAVEQUERYFORMATSUPPORT_FUNC)(
IN struct _SOUND_DEVICE* Device,
IN PWAVEFORMATEX WaveFormat,
@@ -170,6 +173,10 @@
typedef MMRESULT (*MMCLOSE_FUNC)(
IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
IN PVOID Handle); /* not sure about this */
+
+typedef MMRESULT (*MMWAVEHEADER_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
+ IN PWAVEHDR WaveHeader);
typedef struct _MMFUNCTION_TABLE
{
@@ -187,7 +194,36 @@
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport;
MMWAVESETFORMAT_FUNC SetWaveFormat;
+
+ MMWAVEHEADER_FUNC PrepareWaveHeader;
+ MMWAVEHEADER_FUNC UnprepareWaveHeader;
+ MMWAVEHEADER_FUNC SubmitWaveHeader;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
+
+typedef MMRESULT (*SOUND_THREAD_REQUEST_HANDLER)(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
+ IN PVOID Parameter);
+
+typedef struct _SOUND_THREAD
+{
+ HANDLE Handle;
+ BOOL Running;
+
+ struct
+ {
+ HANDLE Ready;
+ HANDLE Request;
+ HANDLE Done;
+ } Events;
+
+ struct
+ {
+ SOUND_THREAD_REQUEST_HANDLER Handler;
+ struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance;
+ PVOID Parameter;
+ MMRESULT Result;
+ } Request;
+} SOUND_THREAD, *PSOUND_THREAD;
typedef struct _SOUND_DEVICE
{
@@ -205,6 +241,7 @@
struct _SOUND_DEVICE_INSTANCE* Next;
struct _SOUND_DEVICE* Device;
PVOID Handle;
+ struct _SOUND_THREAD* Thread;
/* Stuff generously donated to us from WinMM */
struct
@@ -216,7 +253,6 @@
} WinMM;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
-
/*
reentrancy.c
*/
@@ -265,6 +301,15 @@
MmeCloseDevice(
IN DWORD PrivateHandle);
+#define MmePrepareWaveHeader(private_handle, header) \
+ PrepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
+
+#define MmeUnprepareWaveHeader(private_handle, header) \
+ UnprepareWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
+
+#define MmeSubmitWaveHeader(private_handle, header) \
+ SubmitWaveHeader((PSOUND_DEVICE_INSTANCE)private_handle, (PWAVEHDR)header)
+
/*
capabilities.c
@@ -380,6 +425,26 @@
/*
+ thread.c
+*/
+
+MMRESULT
+CreateSoundThread(
+ OUT PSOUND_THREAD* Thread);
+
+MMRESULT
+DestroySoundThread(
+ IN PSOUND_THREAD Thread);
+
+MMRESULT
+CallSoundThread(
+ IN PSOUND_THREAD Thread,
+ IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
+ IN PVOID Parameter OPTIONAL);
+
+
+/*
utility.c
*/
@@ -422,6 +487,26 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN LPWAVEFORMATEX Format,
IN DWORD FormatSize);
+
+
+/*
+ wave/header.c
+*/
+
+MMRESULT
+PrepareWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header);
+
+MMRESULT
+UnprepareWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header);
+
+MMRESULT
+SubmitWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header);
/*
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] Sat
Jan 3 01:15:48 2009
@@ -44,14 +44,14 @@
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
/* Obtain the function table */
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
/* Check that the capabilities structure is of a valid size */
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]
Sat Jan 3 01:15:48 2009
@@ -158,12 +158,12 @@
Result = AllocateSoundDeviceInstance(SoundDeviceInstance);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
/* Get the "open" routine from the function table, and validate it */
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
FreeSoundDeviceInstance(*SoundDeviceInstance);
return TranslateInternalMmResult(Result);
@@ -179,11 +179,20 @@
(*SoundDeviceInstance)->Next = NULL;
(*SoundDeviceInstance)->Device = SoundDevice;
(*SoundDeviceInstance)->Handle = NULL;
-
- (*SoundDeviceInstance)->WinMM.Handle = NULL;
+ (*SoundDeviceInstance)->Thread = NULL;
+
+ (*SoundDeviceInstance)->WinMM.Handle = INVALID_HANDLE_VALUE;
(*SoundDeviceInstance)->WinMM.ClientCallback = 0;
(*SoundDeviceInstance)->WinMM.ClientCallbackInstanceData = 0;
(*SoundDeviceInstance)->WinMM.Flags = 0;
+
+ /* Create the streaming thread (TODO - is this for wave only?) */
+ Result = CreateSoundThread(&(*SoundDeviceInstance)->Thread);
+ if ( ! MMSUCCESS(Result) )
+ {
+ FreeSoundDeviceInstance(*SoundDeviceInstance);
+ return TranslateInternalMmResult(Result);
+ }
/* Add the instance to the list */
Result = ListSoundDeviceInstance(SoundDevice, *SoundDeviceInstance);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c [iso-8859-1] Sat
Jan 3 01:15:48 2009
@@ -145,7 +145,7 @@
Result = AllocateSoundDevice(DeviceType, &NewDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Failed to allocate SOUND_DEVICE structure\n");
return Result;
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Sat
Jan 3 01:15:48 2009
@@ -11,10 +11,12 @@
<file>reentrancy.c</file>
<file>utility.c</file>
<file>kernel.c</file>
+ <file>thread.c</file>
<directory name="wave">
<file>widMessage.c</file>
<file>wodMessage.c</file>
<file>format.c</file>
+ <file>header.c</file>
</directory>
<directory name="midi">
<file>midMessage.c</file>
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] Sat Jan
3 01:15:48 2009
@@ -67,7 +67,7 @@
/* Our parameter checks are done elsewhere */
Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return Result;
return GetSoundDeviceCapabilities(SoundDevice,
@@ -97,12 +97,12 @@
Format = OpenParameters->lpFormat;
Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
/* Does this device support the format? */
Result = QueryWaveDeviceFormatSupport(SoundDevice, Format, sizeof(WAVEFORMATEX));
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Format not supported\n");
return TranslateInternalMmResult(Result);
@@ -117,11 +117,11 @@
/* Create a sound device instance and open the sound device */
Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
Result = SetWaveDeviceFormat(SoundDeviceInstance, Format, sizeof(WAVEFORMATEX));
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
/* TODO: Destroy sound instance */
return TranslateInternalMmResult(Result);
@@ -154,7 +154,6 @@
MmeCloseDevice(
IN DWORD PrivateHandle)
{
- /* FIXME - Where do we call the callback?? */
MMRESULT Result;
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
PSOUND_DEVICE SoundDevice;
@@ -166,11 +165,11 @@
SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
ReleaseEntrypointMutex(DeviceType);
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c [iso-8859-1] Sat Jan 3
01:15:48 2009
@@ -1,0 +1,228 @@
+/*
+ * PROJECT: ReactOS Sound System "MME Buddy" Library
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/sound/mmebuddy/thread.c
+ *
+ * PURPOSE: Multimedia thread management
+ *
+ * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <ntddk.h>
+#include <ntddsnd.h>
+#include <mmebuddy.h>
+
+DWORD WINAPI
+SoundThreadMain(
+ IN LPVOID lpParameter OPTIONAL)
+{
+ PSOUND_THREAD Thread = (PSOUND_THREAD) lpParameter;
+
+ SND_TRACE(L"SoundThread running :)\n");
+
+ /* Callers will wait for us to be ready */
+ Thread->Running = TRUE;
+ SetEvent(Thread->Events.Ready);
+
+ while ( Thread->Running )
+ {
+ DWORD WaitResult;
+
+ /* Wait for a request, or an I/O completion */
+ WaitResult = WaitForSingleObjectEx(Thread->Events.Request, INFINITE, TRUE);
+ SND_TRACE(L"SoundThread - Came out of waiting\n");
+
+ if ( WaitResult == WAIT_OBJECT_0 )
+ {
+ SND_TRACE(L"SoundThread - Processing request\n");
+
+ if ( Thread->Request.Handler )
+ {
+ Thread->Request.Result =
Thread->Request.Handler(Thread->Request.SoundDeviceInstance,
+
Thread->Request.Parameter);
+ }
+ else
+ {
+ Thread->Request.Result = MMSYSERR_ERROR;
+ }
+
+ /* Announce completion of the request */
+ SetEvent(Thread->Events.Done);
+ /* Accept new requests */
+ SetEvent(Thread->Events.Ready);
+ }
+ else if ( WaitResult == WAIT_IO_COMPLETION )
+ {
+ SND_TRACE(L"SoundThread - Processing IO completion\n");
+ /* TODO */
+ }
+ else
+ {
+ /* This should not happen! */
+ SND_ASSERT(FALSE);
+ }
+
+ }
+
+ return 0;
+}
+
+MMRESULT
+CreateSoundThreadEvents(
+ OUT HANDLE* ReadyEvent,
+ OUT HANDLE* RequestEvent,
+ OUT HANDLE* DoneEvent)
+{
+ BOOL ok;
+
+ VALIDATE_MMSYS_PARAMETER( ReadyEvent );
+ VALIDATE_MMSYS_PARAMETER( RequestEvent );
+ VALIDATE_MMSYS_PARAMETER( DoneEvent );
+
+ SND_TRACE(L"Creating thread events\n");
+
+ /* Initialise these so we can identify them upon failure */
+ *ReadyEvent = *RequestEvent = *DoneEvent = INVALID_HANDLE_VALUE;
+
+ ok = (*ReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) != INVALID_HANDLE_VALUE;
+ ok &= (*RequestEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) !=
INVALID_HANDLE_VALUE;
+ ok &= (*DoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) !=
INVALID_HANDLE_VALUE;
+
+ /* If something went wrong, clean up */
+ if ( ! ok )
+ {
+ if ( *ReadyEvent != INVALID_HANDLE_VALUE )
+ CloseHandle(*ReadyEvent);
+
+ if ( *RequestEvent != INVALID_HANDLE_VALUE )
+ CloseHandle(*RequestEvent);
+
+ if ( *DoneEvent != INVALID_HANDLE_VALUE )
+ CloseHandle(*DoneEvent);
+
+ return MMSYSERR_NOMEM;
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+DestroySoundThreadEvents(
+ IN HANDLE ReadyEvent,
+ IN HANDLE RequestEvent,
+ IN HANDLE DoneEvent)
+{
+ VALIDATE_MMSYS_PARAMETER( ReadyEvent != INVALID_HANDLE_VALUE );
+ VALIDATE_MMSYS_PARAMETER( RequestEvent != INVALID_HANDLE_VALUE );
+ VALIDATE_MMSYS_PARAMETER( DoneEvent != INVALID_HANDLE_VALUE );
+
+ SND_TRACE(L"Destroying thread events\n");
+
+ CloseHandle(ReadyEvent);
+ CloseHandle(RequestEvent);
+ CloseHandle(DoneEvent);
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+CreateSoundThread(
+ OUT PSOUND_THREAD* Thread)
+{
+ MMRESULT Result;
+ PSOUND_THREAD NewThread;
+
+ VALIDATE_MMSYS_PARAMETER( Thread );
+
+ NewThread = AllocateStruct(SOUND_THREAD);
+ if ( ! NewThread )
+ return MMSYSERR_NOMEM;
+
+ /* Prepare the events we'll be using to sync. everything */
+ Result = CreateSoundThreadEvents(&NewThread->Events.Ready,
+ &NewThread->Events.Request,
+ &NewThread->Events.Done);
+
+ if ( ! MMSUCCESS(Result) )
+ {
+ FreeMemory(NewThread);
+ return TranslateInternalMmResult(Result);
+ }
+
+ SND_TRACE(L"Creating a sound thread\n");
+ NewThread->Handle = CreateThread(NULL,
+ 0,
+ &SoundThreadMain,
+ (LPVOID) NewThread,
+ CREATE_SUSPENDED,
+ NULL);
+
+ /* Something went wrong, bail out! */
+ if ( NewThread->Handle == INVALID_HANDLE_VALUE )
+ {
+ SND_ERR(L"Sound thread creation failed!\n");
+ DestroySoundThreadEvents(NewThread->Events.Ready,
+ NewThread->Events.Request,
+ NewThread->Events.Done);
+
+ FreeMemory(NewThread);
+
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ /* Wake the thread up */
+ if ( ResumeThread(NewThread->Handle) == -1 )
+ {
+ CloseHandle(NewThread->Handle);
+ DestroySoundThreadEvents(NewThread->Events.Ready,
+ NewThread->Events.Request,
+ NewThread->Events.Done);
+
+ FreeMemory(NewThread);
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ /* If all is well we can now give the thread to the caller */
+ *Thread = NewThread;
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+DestroySoundThread(
+ IN PSOUND_THREAD Thread)
+{
+ /* TODO: Implement me! */
+ return MMSYSERR_NOTSUPPORTED;
+}
+
+MMRESULT
+CallSoundThread(
+ IN PSOUND_THREAD Thread,
+ IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
+ IN PVOID Parameter OPTIONAL)
+{
+ VALIDATE_MMSYS_PARAMETER( Thread );
+ VALIDATE_MMSYS_PARAMETER( RequestHandler );
+
+ SND_TRACE(L"Waiting for READY event\n");
+ WaitForSingleObject(Thread->Events.Ready, INFINITE);
+
+ Thread->Request.Result = MMSYSERR_NOTSUPPORTED;
+ Thread->Request.Handler = RequestHandler;
+ Thread->Request.SoundDeviceInstance = SoundDeviceInstance;
+ Thread->Request.Parameter = Parameter;
+
+ /* Notify the thread it has work to do */
+ SND_TRACE(L"Setting REQUEST event\n");
+ SetEvent(Thread->Events.Request);
+
+ /* Wait for the work to be done */
+ SND_TRACE(L"Waiting for DONE event\n");
+ WaitForSingleObject(Thread->Events.Done, INFINITE);
+
+ return Thread->Request.Result;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
------------------------------------------------------------------------------
svn:eol-style = native
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] Sat
Jan 3 01:15:48 2009
@@ -41,7 +41,7 @@
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
if ( ! FunctionTable->QueryWaveFormatSupport )
@@ -68,7 +68,7 @@
VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
@@ -81,7 +81,7 @@
Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
if ( ! FunctionTable->SetWaveFormat )
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/header.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/header.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/header.c [iso-8859-1] Sat
Jan 3 01:15:48 2009
@@ -1,0 +1,101 @@
+/*
+ * PROJECT: ReactOS Sound System "MME Buddy" Library
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/sound/mmebuddy/header.c
+ *
+ * PURPOSE: Wave header preparation routines
+ *
+ * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <ntddk.h>
+#include <ntddsnd.h>
+#include <mmebuddy.h>
+
+MMRESULT
+PrepareWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE FunctionTable;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Header );
+
+ SND_TRACE(L"Preparing wave header\n");
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ if ( ! FunctionTable->PrepareWaveHeader )
+ return MMSYSERR_NOTSUPPORTED;
+
+ return FunctionTable->PrepareWaveHeader(SoundDeviceInstance, Header);
+}
+
+MMRESULT
+UnprepareWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE FunctionTable;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Header );
+
+ SND_TRACE(L"Un-preparing wave header\n");
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ if ( ! FunctionTable->UnprepareWaveHeader )
+ return MMSYSERR_NOTSUPPORTED;
+
+ return FunctionTable->UnprepareWaveHeader(SoundDeviceInstance, Header);
+}
+
+MMRESULT
+SubmitWaveHeader(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PWAVEHDR Header)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE FunctionTable;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Header );
+
+ SND_TRACE(L"Submitting wave header\n");
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+ if ( ! MMSUCCESS(Result) )
+ return TranslateInternalMmResult(Result);
+
+ if ( ! FunctionTable->SubmitWaveHeader )
+ return MMSYSERR_NOTSUPPORTED;
+
+ return FunctionTable->SubmitWaveHeader(SoundDeviceInstance, Header);
+}
+
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/header.c
------------------------------------------------------------------------------
svn:eol-style = native
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]
Sat Jan 3 01:15:48 2009
@@ -16,6 +16,15 @@
#include <ntddsnd.h>
#include <mmebuddy.h>
+
+#if 0
+MMRESULT HelloWorld(PSOUND_DEVICE_INSTANCE Instance, PVOID String)
+{
+ PWSTR WString = (PWSTR) String;
+ SND_TRACE(WString);
+ return MMSYSERR_NOTSUPPORTED;
+}
+#endif
/*
Standard MME driver entry-point for messages relating to wave audio
@@ -71,11 +80,32 @@
case WODM_PREPARE :
{
- /*Result = MmeWavePrepare(*/
+ /* TODO: Do we need to pass 2nd parameter? */
+ Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
+ break;
}
case WODM_UNPREPARE :
{
+ Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
+ break;
+ }
+
+ case WODM_WRITE :
+ {
+ Result = MmeSubmitWaveHeader(PrivateHandle, Parameter1);
+ break;
+ }
+
+ case WODM_GETPOS :
+ {
+#if 0
+ /* Hacky code to test the threading */
+ PSOUND_DEVICE_INSTANCE Instance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
+ CallSoundThread(Instance->Thread, HelloWorld, Instance, L"Hello
World!");
+ CallSoundThread(Instance->Thread, HelloWorld, Instance, L"Hello
Universe!");
+#endif
+ break;
}
}
Modified: branches/silverblade-audio/lib/drivers/sound/mment4/control.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mment4/control.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mment4/control.c [iso-8859-1] Sat Jan 3
01:15:48 2009
@@ -32,7 +32,7 @@
VALIDATE_MMSYS_PARAMETER( Handle );
Result = GetSoundDeviceIdentifier(SoundDevice, (PVOID*) &Path);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Unable to get sound device path");
return TranslateInternalMmResult(Result);
@@ -99,7 +99,7 @@
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- if ( Result != MMSYSERR_NOERROR );
+ if ( ! MMSUCCESS(Result) );
return TranslateInternalMmResult(Result);
/* Choose the appropriate IOCTL */
@@ -120,7 +120,7 @@
/* Get the capabilities information from the driver */
Result = OpenNt4KernelSoundDevice(SoundDevice, TRUE, &DeviceHandle);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Failed to open device");
return TranslateInternalMmResult(Result);
@@ -136,7 +136,7 @@
CloseKernelSoundDevice(DeviceHandle);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Retrieval of capabilities information failed\n");
Result = TranslateInternalMmResult(Result);
@@ -170,7 +170,7 @@
FALSE,
&Handle);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Unable to open kernel sound device\n");
return TranslateInternalMmResult(Result);
@@ -184,7 +184,7 @@
0,
NULL);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
{
SND_ERR(L"Sync overlapped I/O failed - MMSYS_ERROR %d\n", Result);
Result = TranslateInternalMmResult(Result);
@@ -210,7 +210,7 @@
Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
SND_TRACE(L"Setting wave device format on handle %x\n", Handle);
@@ -223,7 +223,7 @@
0,
NULL);
- if ( Result != MMSYSERR_NOERROR )
+ if ( ! MMSUCCESS(Result) )
return TranslateInternalMmResult(Result);
return MMSYSERR_NOERROR;