Author: silverblade
Date: Thu Jul 17 17:44:47 2008
New Revision: 34571
URL:
http://svn.reactos.org/svn/reactos?rev=34571&view=rev
Log:
Various changes/tweaks. There are a few nasty issues due to the way the
library is presently implemented (deadlocking, unexpected I/O
completions, hacky debug code...) so after this commit I intend on
rewriting a majority of the code to make it cleaner and less hacky over
the next few days.
(hax equals code calories, which in turn equals fat and unstable)
Modified:
branches/silverblade-audio/dll/win32/sndblst/sndblst.c
branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild
branches/silverblade-audio/include/psdk/digitalv.h
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/DriverProc.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/callback.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.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] Thu Jul 17
17:44:47 2008
@@ -18,8 +18,8 @@
#include <mmebuddy.h>
//#include <debug.h>
-PWSTR SBWaveOutDeviceName = L"Sound Blaster Playback";
-PWSTR SBWaveInDeviceName = L"Sound Blaster Recording";
+PWSTR SBWaveOutDeviceName = L"Sound Blaster Playback (silverblade)";
+PWSTR SBWaveInDeviceName = L"Sound Blaster Recording (silverblade)";
/* TODO: Mixer etc */
@@ -86,29 +86,41 @@
LONG parameter1,
LONG parameter2)
{
+ MMRESULT Result;
+/*
+ WCHAR msg[1024];
+ wsprintf(msg, L"DriverProc msg %d", message);
+ MessageBox(0, msg, L"DriverProc", MB_OK | MB_TASKMODAL);
+*/
+
switch ( message )
{
case DRV_LOAD :
TRACE_("DRV_LOAD");
- EnumerateNt4ServiceSoundDevices(L"sndblst",
- 0,
- FoundDevice);
+ InitMmeBuddyLib();
+
+ Result = EnumerateNt4ServiceSoundDevices(L"sndblst",
+ 0,
+ FoundDevice);
/* TODO: Check return value */
- StartSoundThread();
+ //Result = StartSoundThread();
+ //ASSERT(Result == MMSYSERR_NOERROR);
return 1L;
case DRV_FREE :
TRACE_("DRV_FREE");
- StopSoundThread();
+ //StopSoundThread();
RemoveAllSoundDevices();
// SOUND_DEBUG_HEX(GetMemoryAllocations());
TRACE_("Leaving driver with %d memory allocations present\n", (int)
GetMemoryAllocations());
+
+ CleanupMmeBuddyLib();
return 1L;
@@ -121,7 +133,7 @@
}
}
-
+#if 0
#include <stdio.h>
WORD Buffer[5347700 / 2];
@@ -253,3 +265,28 @@
return 0;
}
+#endif
+
+BOOL WINAPI DllMain(
+ HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch ( fdwReason )
+ {
+ case DLL_PROCESS_ATTACH :
+ MessageBox(0, L"DLL_PROCESS_ATTACH", L"DllMain", MB_OK |
MB_TASKMODAL);
+ break;
+ case DLL_PROCESS_DETACH :
+ MessageBox(0, L"DLL_PROCESS_DETACH", L"DllMain", MB_OK |
MB_TASKMODAL);
+ break;
+ case DLL_THREAD_ATTACH :
+ MessageBox(0, L"DLL_THREAD_ATTACH", L"DllMain", MB_OK |
MB_TASKMODAL);
+ break;
+ case DLL_THREAD_DETACH :
+ MessageBox(0, L"DLL_THREAD_DETACH", L"DllMain", MB_OK |
MB_TASKMODAL);
+ break;
+ }
+
+ return TRUE;
+}
Modified: branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/snd…
==============================================================================
--- branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild [iso-8859-1] Thu Jul 17
17:44:47 2008
@@ -1,7 +1,7 @@
<!-- Temporarily compiling as a CUI app for testing purposes */
<!--module name="mmdrv" type="win32dll"
baseaddress="${BASEADDRESS_MMDRV}" installbase="system32"
installname="mmdrv.dll" unicode="yes"-->
-<module name="sndblst" type="win32cui"
installbase="system32" installname="sndblst.exe"
unicode="yes">
- <!--importlibrary definition="mmdrv.def" /-->
+<module name="sndblst" type="win32dll"
installbase="system32" installname="sndblst2.dll"
unicode="yes">
+ <importlibrary definition="sndblst.def" />
<include base="ReactOS">include/reactos/libs/sound</include>
<include base="sndblst">.</include>
<!--define name="NDEBUG" /-->
Modified: branches/silverblade-audio/include/psdk/digitalv.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/psdk/…
==============================================================================
--- branches/silverblade-audio/include/psdk/digitalv.h [iso-8859-1] (original)
+++ branches/silverblade-audio/include/psdk/digitalv.h [iso-8859-1] Thu Jul 17 17:44:47
2008
@@ -857,20 +857,6 @@
LPWSTR lpstrText;
} MCI_DGV_WINDOW_PARMSW, *LPMCI_DGV_WINDOW_PARMSW;
-/* Driver callback for multimedia components (implemented in winmm) */
-
-WINAPI BOOL
-DriverCallback(
- DWORD dwCallBack,
- DWORD dwFlags,
- HDRVR hdrvr,
- DWORD msg,
- DWORD dwUser,
- DWORD dwParam1,
- DWORD dwParam2
-);
-
-
#ifdef __cplusplus
}
#endif
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] Thu Jul
17 17:44:47 2008
@@ -26,11 +26,14 @@
MessageBoxA(0, msg, __FUNCTION__, MB_OK | MB_TASKMODAL)
-#ifndef NDEBUG
+//#define NDEBUG
+#define NTRACE
#ifdef ASSERT
#undef ASSERT
#endif
+
+#ifndef NDEBUG
/* HACK for testing */
#include <stdio.h>
@@ -62,12 +65,30 @@
} \
}
+#ifndef NTRACE
+
#define TRACE_ENTRY() \
TRACE_("entered function\n")
#define TRACE_EXIT(retval) \
TRACE_("returning %d (0x%x)\n", (int)retval, (int)retval)
+#endif
+
+#else
+
+#define TRACE_(...) do { } while ( 0 )
+#define WARN_(...) do { } while ( 0 )
+#define ERR_(...) do { } while ( 0 )
+#define ASSERT(x) do { } while ( 0 )
+
+#define NTRACE
+
+#endif
+
+#ifdef NTRACE
+ #define TRACE_ENTRY() do { } while ( 0 )
+ #define TRACE_EXIT(retval) do { } while ( 0 )
#endif
@@ -531,6 +552,24 @@
MMRESULT
TranslateInternalMmResult(MMRESULT Result);
+MMRESULT
+InitEntrypointMutex();
+
+VOID
+CleanupEntrypointMutex();
+
+VOID
+AcquireEntrypointMutex();
+
+VOID
+ReleaseEntrypointMutex();
+
+BOOLEAN
+InitMmeBuddyLib();
+
+VOID
+CleanupMmeBuddyLib();
+
/*
instances.c
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/DriverProc.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/DriverProc.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/DriverProc.c [iso-8859-1]
Thu Jul 17 17:44:47 2008
@@ -14,7 +14,8 @@
#include <windows.h>
#include <mmddk.h>
#include <ntddsnd.h>
-#include <debug.h>
+
+#include <mmebuddy.h>
LONG
DefaultDriverProc(
@@ -27,27 +28,27 @@
switch ( message )
{
case DRV_LOAD :
- DPRINT("DRV_LOAD\n");
+ TRACE_("DRV_LOAD\n");
return 1L;
case DRV_FREE :
- DPRINT("DRV_FREE\n");
+ TRACE_("DRV_FREE\n");
return 1L;
case DRV_OPEN :
- DPRINT("DRV_OPEN\n");
+ TRACE_("DRV_OPEN\n");
return 1L;
case DRV_CLOSE :
- DPRINT("DRV_CLOSE\n");
+ TRACE_("DRV_CLOSE\n");
return 1L;
case DRV_ENABLE :
- DPRINT("DRV_ENABLE\n");
+ TRACE_("DRV_ENABLE\n");
return 1L;
case DRV_DISABLE :
- DPRINT("DRV_DISABLE\n");
+ TRACE_("DRV_DISABLE\n");
return 1L;
/*
@@ -56,15 +57,15 @@
*/
case DRV_QUERYCONFIGURE :
- DPRINT("DRV_QUERYCONFIGURE\n");
+ TRACE_("DRV_QUERYCONFIGURE\n");
return 0L;
case DRV_CONFIGURE :
- DPRINT("DRV_CONFIGURE\n");
+ TRACE_("DRV_CONFIGURE\n");
return 0L;
case DRV_INSTALL :
- DPRINT("DRV_INSTALL\n");
+ TRACE_("DRV_INSTALL\n");
return DRVCNF_RESTART;
};
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/callback.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/callback.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/callback.c [iso-8859-1] Thu
Jul 17 17:44:47 2008
@@ -11,7 +11,7 @@
#include <windows.h>
#include <mmsystem.h>
-#include <digitalv.h>
+#include <mmddk.h>
#include <mmebuddy.h>
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] Thu Jul 17
17:44:47 2008
@@ -155,6 +155,8 @@
/* Device type zero means "all" */
VALIDATE_MMSYS_PARAMETER( VALID_SOUND_DEVICE_TYPE(DeviceType) ||
DeviceType == 0 );
+
+ MessageBox(0, ServiceName, L"Looking for devices", MB_OK | MB_TASKMODAL);
while ( OpenSoundDeviceRegKey(ServiceName, KeyIndex, &Key) == MMSYSERR_NOERROR )
{
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] Thu Jul 17
17:44:47 2008
@@ -149,6 +149,8 @@
/* We're ready to do work */
SetEvent(ReadyEvent);
+
+ TRACE_("SoundThreadProc entered\n");
while ( ThreadRunning )
{
@@ -313,7 +315,14 @@
TRACE_("Starting sound thread\n");
/* We're all set to go, so let's start the thread up */
- ResumeThread(SoundThread);
+ if ( ResumeThread(SoundThread) == -1 )
+ {
+ CloseHandle(SoundThread);
+ SoundThread = INVALID_HANDLE_VALUE;
+ CleanupThreadEvents();
+ ERR_("Error %d\n", (int) GetLastError());
+ return Win32ErrorToMmResult(GetLastError());
+ }
return MMSYSERR_NOERROR;
}
@@ -332,6 +341,7 @@
return MMSYSERR_ERROR;
}
+ TRACE_("Waiting for ready event\n");
/* Wait for the sound thread to be ready for a request */
WaitForSingleObject(ReadyEvent, INFINITE);
@@ -344,6 +354,7 @@
/* Tell the sound thread there is a request waiting */
SetEvent(RequestEvent);
+ TRACE_("Waiting for done event\n");
/* Wait for our request to be dealt with */
WaitForSingleObject(DoneEvent, INFINITE);
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] Thu Jul
17 17:44:47 2008
@@ -20,6 +20,9 @@
static HANDLE ProcessHeapHandle = INVALID_HANDLE_VALUE;
static DWORD CurrentAllocations = 0;
+/* Makes the entry-points safe */
+static HANDLE BigMmLock = NULL;
+
#if 0
typedef struct _ALLOCATION
{
@@ -198,3 +201,66 @@
return Result;
}
+
+
+
+/*
+ Entrypoint mutex management
+*/
+
+MMRESULT
+InitEntrypointMutex()
+{
+ BigMmLock = CreateMutex(NULL, FALSE, NULL);
+
+ if ( BigMmLock == NULL )
+ {
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+VOID
+CleanupEntrypointMutex()
+{
+ if ( BigMmLock )
+ {
+ CloseHandle(BigMmLock);
+ }
+}
+
+VOID
+AcquireEntrypointMutex()
+{
+ ASSERT(BigMmLock);
+ WaitForSingleObject(BigMmLock, INFINITE);
+}
+
+VOID
+ReleaseEntrypointMutex()
+{
+ ASSERT(BigMmLock);
+ ReleaseMutex(BigMmLock);
+}
+
+
+/*
+ MME Buddy init/cleanup
+ NOTE: We don't do thread start/stop here...
+*/
+
+BOOLEAN
+InitMmeBuddyLib()
+{
+ if ( InitEntrypointMutex() != MMSYSERR_NOERROR )
+ return FALSE;
+
+ return TRUE;
+}
+
+VOID
+CleanupMmeBuddyLib()
+{
+ ReleaseEntrypointMutex();
+}
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] Thu Jul 17 17:44:47 2008
@@ -74,12 +74,26 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PULONG State)
{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE Functions;
+
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
VALIDATE_MMSYS_PARAMETER( State );
- return CallUsingSoundThread(SoundDeviceInstance,
- GetWaveDeviceState_Request,
- State);
+ // *State = SoundDeviceInstance->Streaming.Wave.State;
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance,
+ &SoundDevice);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice,
+ &Functions);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ return Functions->GetWaveDeviceState(SoundDeviceInstance,
+ State);
+
}
MMRESULT
@@ -113,16 +127,20 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
MMRESULT Result;
- TRACE_ENTRY();
-
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
- Result = CallUsingSoundThread(SoundDeviceInstance,
- PauseWaveDevice_Request,
- NULL);
-
- TRACE_EXIT(Result);
- return 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);
+
+ return Functions->PauseWaveDevice(SoundDeviceInstance);
}
MMRESULT
@@ -143,6 +161,7 @@
ASSERT( Result == MMSYSERR_NOERROR );
Result = TranslateInternalMmResult(Result);
+
TRACE_EXIT(Result);
return Result;
}
@@ -151,11 +170,21 @@
RestartWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
- return CallUsingSoundThread(SoundDeviceInstance,
- RestartWaveDevice_Request,
- NULL);
+ 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);
+
+ return Functions->RestartWaveDevice(SoundDeviceInstance);
}
MMRESULT
@@ -180,15 +209,31 @@
return Result;
}
+/* FIXME - This needs to be done a better way */
MMRESULT
ResetWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
- return CallUsingSoundThread(SoundDeviceInstance,
- ResetWaveDevice_Request,
- NULL);
+ 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;
+
+ /* TODO: Return all audio buffers to the client, marking as DONE */
+
+ return Functions->ResetWaveDevice(SoundDeviceInstance);
}
MMRESULT
@@ -217,11 +262,21 @@
BreakWaveDeviceLoop(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
- return CallUsingSoundThread(SoundDeviceInstance,
- BreakWaveDeviceLoop_Request,
- NULL);
+ 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);
+
+ return Functions->BreakWaveDeviceLoop(SoundDeviceInstance);
}
MMRESULT
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]
Thu Jul 17 17:44:47 2008
@@ -67,7 +67,7 @@
DWORD BytesToStream, BytesStreamed = 0;
UCHAR DeviceType;
- TRACE_("PerformWaveIo\n");
+ TRACE_ENTRY();
ASSERT( IsValidSoundDeviceInstance(SoundDeviceInstance) );
@@ -83,15 +83,13 @@
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- /* If we're out of buffers, mark stream as stopped and do nothing */
+ /* If we're out of buffers, do nothing */
if ( ! StreamInfo->CurrentBuffer )
{
TRACE_("*** NOTHING TO DO ***\n");
- /* The stream is idle */
- /*StreamInfo->State = WAVE_DD_IDLE;*/
-
- return 0;
+ TRACE_EXIT(MMSYSERR_NOERROR);
+ return MMSYSERR_NOERROR;
}
/* Is this the beginning of a loop? */
@@ -111,7 +109,8 @@
StreamInfo->BufferOffset,
MAX_SOUND_BUFFER_SIZE);
- TRACE_("Writing %p + %d (%d bytes) - buffer length is %d bytes\n",
+ TRACE_("Writing hdr %p - %p + %d (%d bytes) - buffer length is %d
bytes\n",
+ StreamInfo->CurrentBuffer,
StreamInfo->CurrentBuffer->lpData,
(int) StreamInfo->BufferOffset,
(int) BytesToStream,
@@ -130,24 +129,8 @@
{
ERR_("Failed to perform wave device I/O! MMSYS Error %d\n",
(int) Result);
+ TRACE_EXIT(Result);
return Result;
- }
-
- /* 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
- {
- /* NOTE - MME wavein recording does not begin immediately!! */
- /*
- TRACE_("Streamed data - state is now WAVE_DD_RECORDING\n");
- StreamInfo->State = WAVE_DD_RECORDING;
- */
}
BytesStreamed = BytesToStream;
@@ -159,12 +142,12 @@
if ( StreamInfo->BufferOffset ==
StreamInfo->CurrentBuffer->dwBufferLength )
{
- TRACE_("Advancing to next buffer\n");
if ( ( StreamInfo->CurrentBuffer->dwFlags & WHDR_ENDLOOP ) &&
( StreamInfo->LoopHead ) &&
( StreamInfo->LoopsRemaining > 0 ) )
{
+ TRACE_("Returning to loop head at %p\n", StreamInfo->LoopHead);
/* Loop back to the head */
StreamInfo->CurrentBuffer = StreamInfo->LoopHead;
-- StreamInfo->LoopsRemaining;
@@ -172,6 +155,10 @@
}
else
{
+ TRACE_("Advancing from wavehdr %p to %p\n",
+ StreamInfo->CurrentBuffer,
+ StreamInfo->CurrentBuffer->lpNext);
+
/* Either not looping, or looping expired */
StreamInfo->CurrentBuffer = StreamInfo->CurrentBuffer->lpNext;
}
@@ -181,6 +168,7 @@
if ( StreamInfo->CurrentBuffer )
{
+ TRACE_("Resetting offset of %p to zero\n",
StreamInfo->CurrentBuffer);
/* Reset the completion offset */
StreamInfo->CurrentBuffer->reserved = 0;
}
@@ -189,6 +177,7 @@
/* Increase the number of outstanding buffers */
++ StreamInfo->BuffersOutstanding;
+ TRACE_EXIT(MMSYSERR_NOERROR);
return MMSYSERR_NOERROR;
}
@@ -206,7 +195,6 @@
while ( StreamReadyForData(StreamInfo) &&
StreamHasBuffersQueued(StreamInfo) )
{
- TRACE_("Performing wave I/O ...\n");
Result = PerformWaveIo(SoundDeviceInstance);
if ( Result != MMSYSERR_NOERROR )
@@ -235,6 +223,10 @@
ASSERT(WaveHeader);
WaveHeader->reserved += BytesWritten;
+
+ TRACE_("Transferred %d bytes - offset is now %d of length %d\n",
+ (int) BytesWritten, (int) WaveHeader->reserved, (int)
WaveHeader->dwBufferLength);
+
ASSERT(WaveHeader->reserved <= WaveHeader->dwBufferLength);
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
@@ -282,7 +274,7 @@
PerformWaveIo(SoundDeviceInstance);
- TRACE_("Wave completion routine done\n");
+ TRACE_EXIT(0);
}
MMRESULT
@@ -299,7 +291,7 @@
/* To avoid stupidly long variable names we alias this */
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- TRACE_("QueueBuffer_Request\n");
+ TRACE_("QueueBuffer_Request - wavehdr %p\n", WaveHeader);
/* Initialise fields of interest to us */
WaveHeader->lpNext = NULL;
@@ -313,10 +305,10 @@
{
TRACE_("This is the first buffer being queued\n");
- /* Set head, tail and current to this buffer */
+ /* Set head and tail to this buffer (current gets set later) */
StreamInfo->BufferQueueHead = WaveHeader;
StreamInfo->BufferQueueTail = WaveHeader;
- StreamInfo->CurrentBuffer = WaveHeader;
+ StreamInfo->CurrentBuffer = NULL;
/* Initialise the stream state */
StreamInfo->BufferOffset = 0;
@@ -327,7 +319,7 @@
StreamInfo->LoopsRemaining = 0;
/* Get the streaming started */
- StreamWaveBuffers(SoundDeviceInstance);
+// StreamWaveBuffers(SoundDeviceInstance);
}
else
{
@@ -337,136 +329,16 @@
StreamInfo->BufferQueueTail->lpNext = WaveHeader;
/* ...and set the buffer as the new tail */
StreamInfo->BufferQueueTail = WaveHeader;
-
- if ( ! StreamInfo->CurrentBuffer )
- {
- /* All buffers so far have been committed to the sound driver */
- StreamInfo->CurrentBuffer = WaveHeader;
- }
+ }
+
+ /* Do we need to push the play button? */
+ if ( ! StreamInfo->CurrentBuffer )
+ {
+ /* All buffers so far have been committed to the sound driver */
+ StreamInfo->CurrentBuffer = WaveHeader;
+
+ StreamWaveBuffers(SoundDeviceInstance);
}
return MMSYSERR_NOERROR;
}
-
-MMRESULT
-GetWaveDeviceState_Request(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PVOID Parameter)
-{
- MMRESULT Result;
- PSOUND_DEVICE SoundDevice;
- PMMFUNCTION_TABLE Functions;
- PULONG State = (PULONG) Parameter;
-
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
- VALIDATE_MMSYS_PARAMETER( State );
-
- // *State = SoundDeviceInstance->Streaming.Wave.State;
-
- Result = GetSoundDeviceFromInstance(SoundDeviceInstance,
- &SoundDevice);
- ASSERT(Result == MMSYSERR_NOERROR);
-
- Result = GetSoundDeviceFunctionTable(SoundDevice,
- &Functions);
- ASSERT(Result == MMSYSERR_NOERROR);
-
- return Functions->GetWaveDeviceState(SoundDeviceInstance,
- State);
-}
-
-/* These are a bit repetitive... */
-
-MMRESULT
-PauseWaveDevice_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);
-
- return Functions->PauseWaveDevice(SoundDeviceInstance);
-}
-
-MMRESULT
-RestartWaveDevice_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);
-
- 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;
-
- /* TODO: Return all audio buffers to the client, marking as DONE */
-
- return Functions->ResetWaveDevice(SoundDeviceInstance);
-}
-
-MMRESULT
-BreakWaveDeviceLoop_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);
-
- return Functions->BreakWaveDeviceLoop(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] Thu Jul
17 17:44:47 2008
@@ -22,24 +22,4 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PVOID Parameter);
-MMRESULT
-PauseWaveDevice_Request(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PVOID Parameter);
-
-MMRESULT
-RestartWaveDevice_Request(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PVOID Parameter);
-
-MMRESULT
-ResetWaveDevice_Request(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PVOID Parameter);
-
-MMRESULT
-BreakWaveDeviceLoop_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]
Thu Jul 17 17:44:47 2008
@@ -29,31 +29,40 @@
PSOUND_DEVICE_INSTANCE Instance =
(PSOUND_DEVICE_INSTANCE)private_handle;
+ AcquireEntrypointMutex();
+
TRACE_("wodMessageStub called\n");
+// MessageBox(0, L"wodMessage", L"wodMessage", MB_OK |
MB_TASKMODAL);
switch ( message )
{
case WODM_GETNUMDEVS :
- return GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
+ {
+ Result = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
+ break;
+ }
case WODM_GETDEVCAPS :
{
UNIVERSAL_CAPS Capabilities;
if ( parameter2 < sizeof(WAVEOUTCAPS) )
- return MMSYSERR_INVALPARAM;
+ {
+ Result = MMSYSERR_INVALPARAM;
+ break;
+ }
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, device_id, &Device);
if ( Result != MMSYSERR_NOERROR )
- return Result;
+ break;
Result = GetSoundDeviceCapabilities(Device, &Capabilities);
if ( Result != MMSYSERR_NOERROR )
- return Result;
+ break;
CopyMemory((LPWAVEOUTCAPS)parameter1, &Capabilities.WaveOut,
parameter2);
- return Result;
+ break;
}
case WODM_OPEN :
@@ -64,9 +73,8 @@
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, device_id, &Device);
TRACE_("GetSoundDevice == %d\n", (int) Result);
-
- if ( Result != MMSYSERR_NOERROR )
- return Result;
+ if ( Result != MMSYSERR_NOERROR )
+ break;
if ( parameter2 & WAVE_FORMAT_QUERY )
{
@@ -74,16 +82,19 @@
OpenParameters->lpFormat,
sizeof(WAVEFORMATEX));
- return Result;
+ break;
}
ASSERT(private_handle != 0);
+
+ // HACK
+ StartSoundThread();
Result = CreateSoundDeviceInstance(Device, &Instance);
TRACE_("CreateSoundDeviceInstance == %d\n", (int) Result);
if ( Result != MMSYSERR_NOERROR )
- return Result;
+ break;
Result = SetWaveDeviceFormat(Instance,
OpenParameters->lpFormat,
@@ -92,7 +103,7 @@
if ( Result != MMSYSERR_NOERROR )
{
DestroySoundDeviceInstance(Instance);
- return Result;
+ break;
}
/* Set up the callback - TODO: Put this somewhere else? */
@@ -108,7 +119,8 @@
/* Notify the client */
NotifySoundClient(Instance, WOM_OPEN, 0);
- return MMSYSERR_NOERROR;
+ Result = MMSYSERR_NOERROR;
+ break;
}
case WODM_CLOSE :
@@ -124,7 +136,10 @@
/* Must not be playing or paused */
if ( State != WAVE_DD_IDLE )
- return WAVERR_STILLPLAYING;
+ {
+ Result = WAVERR_STILLPLAYING;
+ break;
+ }
/* Notify the client */
NotifySoundClient(Instance, WOM_CLOSE, 0);
@@ -132,6 +147,9 @@
Result = DestroySoundDeviceInstance(Instance);
ASSERT(Result == MMSYSERR_NOERROR);
+ // HACK
+ StopSoundThread();
+
return Result;
}
@@ -140,52 +158,65 @@
ASSERT(Instance != NULL);
if ( ! parameter1 )
- return MMSYSERR_INVALPARAM;
-
- return QueueWaveDeviceBuffer(Instance, (PWAVEHDR) parameter1);
+ Result = MMSYSERR_INVALPARAM;
+ else
+ Result = QueueWaveDeviceBuffer(Instance, (PWAVEHDR) parameter1);
+
+ break;
}
case WODM_PAUSE :
{
ASSERT(Instance != NULL);
- return PauseWaveDevice(Instance);
+ Result = PauseWaveDevice(Instance);
+ break;
}
case WODM_RESTART :
{
ASSERT(Instance != NULL);
- return RestartWaveDevice(Instance);
+ Result = RestartWaveDevice(Instance);
+ break;
}
case WODM_RESET :
{
ASSERT(Instance != NULL);
- return ResetWaveDevice(Instance);
+ Result = ResetWaveDevice(Instance);
+ break;
}
case WODM_BREAKLOOP :
{
ASSERT(Instance != NULL);
- return BreakWaveDeviceLoop(Instance);
+ Result = BreakWaveDeviceLoop(Instance);
+ break;
}
/* Let WINMM take care of these */
case WODM_PREPARE :
case WODM_UNPREPARE :
- return MMSYSERR_NOTSUPPORTED;
+ Result = MMSYSERR_NOTSUPPORTED;
+ break;
/* TODO */
case WODM_SETVOLUME :
case WODM_GETVOLUME :
case WODM_SETPITCH :
case WODM_GETPITCH :
- return MMSYSERR_NOTSUPPORTED;
+ Result = MMSYSERR_NOTSUPPORTED;
+ break;
default :
- return MMSYSERR_NOTSUPPORTED;
+ Result = MMSYSERR_NOTSUPPORTED;
+ break;
}
+
+ ReleaseEntrypointMutex();
+
+ return Result;
}