Author: silverblade
Date: Fri Jul 11 18:03:31 2008
New Revision: 34429
URL:
http://svn.reactos.org/svn/reactos?rev=34429&view=rev
Log:
Fixed bug that was causing crash when no more buffers were queued up. Turned out
to be a NULL pointer being read from (as it was set as the "current buffer").
Partial changeover from ugly custom printf/messagebox debug output to using the
proper tools (ie, DPRINT etc.) Issuing a WODM_CLOSE before playack is complete
results in memory leak and lots of errors at present (need to take care of this)
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/kernel.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.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] Fri Jul 11
18:03:31 2008
@@ -90,7 +90,7 @@
switch ( message )
{
case DRV_LOAD :
- SOUND_DEBUG(L"DRV_LOAD");
+ DPRINT("DRV_LOAD");
EnumerateNt4ServiceSoundDevices(L"sndblst",
0,
@@ -102,7 +102,7 @@
return 1L;
case DRV_FREE :
- SOUND_DEBUG(L"DRV_FREE");
+ DPRINT("DRV_FREE");
StopSoundThread();
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 Jul
11 18:03:31 2008
@@ -43,6 +43,8 @@
WCHAR dbgmsg[1024], dbgtitle[1024]; \
wsprintf(dbgtitle, L"%hS[%d]", __FILE__, __LINE__); \
wsprintf(dbgmsg, L"ASSERT FAILED:\n%hS", #x); \
+ MessageBox(0, dbgmsg, dbgtitle, MB_OK | MB_TASKMODAL); \
+ exit(1); \
} \
}
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] Fri Jul 11
18:03:31 2008
@@ -225,6 +225,13 @@
/*wsprintf(msg, L"Writing to handle %x",
SoundDeviceInstance->Device->Handle);*/
/*SOUND_DEBUG(msg);*/
+ SOUND_TRACE("WriteFileEx(%p, %p, %d, %p, %p)\n",
+ SoundDeviceInstance->Device->Handle,
+ Buffer,
+ (int) BufferSize,
+ Overlapped,
+ CompletionRoutine);
+
if ( ! WriteFileEx(SoundDeviceInstance->Device->Handle,
Buffer,
BufferSize,
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] Fri Jul 11
18:03:31 2008
@@ -18,6 +18,8 @@
#include <windows.h>
#include <mmsystem.h>
+#include <debug.h>
+
#include <mmebuddy.h>
/* HAX */
@@ -53,7 +55,7 @@
PSOUND_THREAD_COMPLETED_IO CompletionData;
PSOUND_THREAD_OVERLAPPED SoundOverlapped;
- printf("Overlapped I/O completion APC called\n");
+ DPRINT("** I/O has completed\n");
SoundOverlapped = (PSOUND_THREAD_OVERLAPPED) lpOverlapped;
SOUND_ASSERT(SoundOverlapped);
@@ -66,7 +68,7 @@
/* Is this the first completion? */
if ( ! CompletedIoListHead )
{
- printf("First completion - making new head and tail\n");
+ DPRINT("First completion - making new head and tail\n");
/* This is the first completion */
SOUND_ASSERT(CompletedIoListTail == NULL);
@@ -78,18 +80,22 @@
}
else
{
- printf("Not the first completion - making new tail\n");
+ DPRINT("Not the first completion - making new tail\n");
+ SOUND_ASSERT(CompletionData);
/* This is not the first completion */
CompletionData->Previous = CompletedIoListTail;
CompletionData->Next = NULL;
/* Completion data gets made the new tail */
+ SOUND_ASSERT(CompletedIoListTail);
CompletedIoListTail->Next = CompletionData;
CompletedIoListTail = CompletionData;
}
/* We keep the completion data, but no longer need this: */
FreeMemory(SoundOverlapped);
+
+ DPRINT("** Leaving completion routine\n");
}
MMRESULT
@@ -135,7 +141,7 @@
Overlapped->CompletionData->Parameter = CompletionParameter;
Overlapped->CompletionData->BytesTransferred = 0;
- printf("Performing overlapped I/O\n");
+ DPRINT("Performing overlapped I/O\n");
return WriteSoundDeviceBuffer(SoundDeviceInstance,
Buffer,
BufferSize,
@@ -148,7 +154,7 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance OPTIONAL,
IN PVOID Parameter OPTIONAL)
{
- printf("ProcessThreadExitRequest called\n");
+ DPRINT("ProcessThreadExitRequest called\n");
ThreadRunning = FALSE;
return MMSYSERR_NOERROR;
}
@@ -195,29 +201,37 @@
PSOUND_THREAD_COMPLETED_IO CurrentCompletion;
/* Process the I/O Completion */
+ SOUND_TRACE("Returned from I/O completion APC\n");
CurrentCompletion = CompletedIoListHead;
SOUND_ASSERT(CurrentCompletion);
+ SOUND_TRACE("Beginning enumeration of completions\n");
while ( CurrentCompletion )
{
PSOUND_THREAD_COMPLETED_IO PreviousCompletion;
+ SOUND_TRACE("Calling completion handler\n");
/* Call the completion handler */
CurrentCompletion->CompletionHandler(
CurrentCompletion->SoundDeviceInstance,
CurrentCompletion->Parameter,
CurrentCompletion->BytesTransferred);
+ SOUND_TRACE("Advancing to next completion\n");
/* Get the next completion but destroy the previous */
PreviousCompletion = CurrentCompletion;
CurrentCompletion = CurrentCompletion->Next;
+ /*CompletedIoListHead = CurrentCompletion;*/
+
+ SOUND_TRACE("Freeing memory\n");
FreeMemory(PreviousCompletion);
}
/* Nothing in the completion queue/list now */
CompletedIoListHead = NULL;
CompletedIoListTail = NULL;
+ SOUND_TRACE("Ended enumeration of completions\n");
}
else
{
@@ -226,7 +240,7 @@
}
}
- printf("THREAD: Exiting\n");
+ DPRINT("THREAD: Exiting\n");
ExitThread(0);
return 0;
@@ -311,7 +325,7 @@
return Win32ErrorToMmResult(GetLastError());
}
- printf("Starting sound thread\n");
+ DPRINT("Starting sound thread\n");
/* We're all set to go, so let's start the thread up */
ResumeThread(SoundThread);
@@ -363,7 +377,7 @@
return MMSYSERR_ERROR;
}
- printf("Calling thread shutdown function\n");
+ DPRINT("Calling thread shutdown function\n");
Result = CallUsingSoundThread(NULL,
ProcessThreadExitRequest,
@@ -376,7 +390,7 @@
WaitForSingleObject(SoundThread, INFINITE);
- printf("Sound thread has quit\n");
+ DPRINT("Sound thread has quit\n");
/* Clean up */
CloseHandle(SoundThread);
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c [iso-8859-1]
Fri Jul 11 18:03:31 2008
@@ -18,6 +18,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include <debug.h>
#include <mmebuddy.h>
@@ -43,7 +44,7 @@
StreamReadyForData(
IN PWAVE_STREAM_INFO StreamInfo)
{
- SOUND_ASSERT(StreamInfo);
+ ASSERT(StreamInfo);
return (StreamInfo->BuffersOutstanding < MAX_SOUND_BUFFERS);
}
@@ -52,7 +53,7 @@
StreamHasBuffersQueued(
IN PWAVE_STREAM_INFO StreamInfo)
{
- SOUND_ASSERT(StreamInfo);
+ ASSERT(StreamInfo);
return (StreamInfo->CurrentBuffer != NULL);
}
@@ -64,17 +65,26 @@
PWAVE_STREAM_INFO StreamInfo;
DWORD BytesToStream, BytesStreamed = 0;
+ DPRINT("PerformWaveIo\n");
+
SOUND_ASSERT(SoundDeviceInstance);
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- SOUND_ASSERT(StreamInfo->CurrentBuffer);
+
+ /* If we're out of buffers, do nothing */
+ if ( ! StreamInfo->CurrentBuffer )
+ {
+ return 0;
+ }
/* Work out how much buffer can be submitted */
BytesToStream = MinimumOf(StreamInfo->CurrentBuffer->dwBufferLength -
StreamInfo->CurrentBuffer->reserved,
MAX_SOUND_BUFFER_SIZE);
- SOUND_TRACE("Writing %p + %d (%d bytes) - buffer length is %d bytes\n",
+ DPRINT("About to report what I'm about to write...\n");
+
+ DPRINT("Writing %p + %d (%d bytes) - buffer length is %d bytes\n",
StreamInfo->CurrentBuffer->lpData,
(int) StreamInfo->CurrentBuffer->reserved,
(int) BytesToStream,
@@ -98,7 +108,7 @@
if ( StreamInfo->CurrentBuffer->reserved ==
StreamInfo->CurrentBuffer->dwBufferLength )
{
- SOUND_TRACE("Advancing to next buffer\n");
+ DPRINT("Advancing to next buffer\n");
StreamInfo->CurrentBuffer = StreamInfo->CurrentBuffer->lpNext;
}
@@ -117,14 +127,14 @@
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- SOUND_TRACE("<== Streaming wave I/O ==>\n");
+ DPRINT("<== Streaming wave I/O ==>\n");
while ( StreamReadyForData(StreamInfo) &&
StreamHasBuffersQueued(StreamInfo) )
{
- SOUND_TRACE("Performing wave I/O ...\n");
+ DPRINT("Performing wave I/O ...\n");
PerformWaveIo(SoundDeviceInstance);
}
- SOUND_TRACE("<== Done streaming ==>\n");
+ DPRINT("<== Done streaming ==>\n");
return MMSYSERR_NOERROR;
}
@@ -137,7 +147,10 @@
{
PWAVE_STREAM_INFO StreamInfo;
- SOUND_TRACE("Wave completion routine\n");
+ DPRINT("CompleteWaveBuffer(%p, %p, %d)\n",
+ SoundDeviceInstance,
+ Parameter,
+ (int) BytesWritten);
SOUND_ASSERT(SoundDeviceInstance);
@@ -149,7 +162,7 @@
PerformWaveIo(SoundDeviceInstance);
- SOUND_TRACE("Wave completion routine done\n");
+ DPRINT("Wave completion routine done\n");
}
MMRESULT
@@ -169,7 +182,7 @@
/* To avoid stupidly long variable names we alias this */
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
- SOUND_TRACE("QueueBuffer_Request\n");
+ DPRINT("QueueBuffer_Request\n");
/* Initialise fields of interest to us */
WaveHeader->lpNext = NULL;
@@ -181,7 +194,7 @@
*/
if ( ! StreamInfo->BufferQueueHead )
{
- SOUND_TRACE("This is the first buffer being queued\n");
+ DPRINT("This is the first buffer being queued\n");
/* Set head, tail and current to this buffer */
StreamInfo->BufferQueueHead = WaveHeader;
@@ -198,7 +211,7 @@
}
else
{
- SOUND_TRACE("This is not the first buffer being queued\n");
+ DPRINT("This is not the first buffer being queued\n");
/* Point the existing tail to the new buffer */
StreamInfo->BufferQueueTail->lpNext = WaveHeader;