Author: silverblade
Date: Sun Jul 13 08:22:54 2008
New Revision: 34459
URL:
http://svn.reactos.org/svn/reactos?rev=34459&view=rev
Log:
Started implementing wave stream state checking/controlling (eg play/stop).
Modified:
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.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
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 08:22:54 2008
@@ -214,6 +214,8 @@
typedef struct _WAVE_STREAM_INFO
{
+ /* Current wave stream state */
+ WORD State;
/* Buffer queue head and tail */
PWAVEHDR BufferQueueHead;
PWAVEHDR BufferQueueTail;
@@ -307,6 +309,14 @@
IN PSOUND_DEVICE Device,
OUT PUCHAR DeviceType);
+MMRESULT
+DefaultInstanceConstructor(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
+
+VOID
+DefaultInstanceDestructor(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
+
/*
nt4.c
@@ -445,7 +455,7 @@
/*
- ...
+ capabilities.c
*/
MMRESULT
@@ -457,6 +467,11 @@
DefaultGetSoundDeviceCapabilities(
IN PSOUND_DEVICE Device,
OUT PUNIVERSAL_CAPS Capabilities);
+
+
+/*
+ wave/format.c
+*/
MMRESULT
QueryWaveDeviceFormatSupport(
@@ -481,14 +496,6 @@
IN PSOUND_DEVICE_INSTANCE Instance,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
-
-MMRESULT
-DefaultInstanceConstructor(
- IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
-
-VOID
-DefaultInstanceDestructor(
- IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
/*
@@ -516,6 +523,13 @@
IN PVOID Parameter);
+/*
+ wave/streamcontrol.c
+*/
+
+MMRESULT
+InitWaveStreamData(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
MMRESULT
QueueWaveDeviceBuffer(
@@ -523,9 +537,8 @@
IN PWAVEHDR BufferHeader);
-
-/*
- mme/wodMessage.c
+/*
+ wave/wodMessage.c
*/
APIENTRY DWORD
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1] Sun Jul
13 08:22:54 2008
@@ -59,6 +59,7 @@
IN PSOUND_DEVICE SoundDevice,
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
+ MMRESULT Result;
PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
ASSERT(SoundDevice != NULL);
@@ -66,6 +67,26 @@
ASSERT(SoundDeviceInstance->Device == NULL);
SoundDeviceInstance->Device = SoundDevice;
+
+ if ( IS_WAVE_DEVICE_TYPE(SoundDevice->DeviceType) )
+ {
+ Result = InitWaveStreamData(SoundDeviceInstance);
+ ASSERT(Result == MMSYSERR_NOERROR);
+ }
+ else if ( IS_MIDI_DEVICE_TYPE(SoundDevice->DeviceType) )
+ {
+ }
+ else if ( IS_MIXER_DEVICE_TYPE(SoundDevice->DeviceType) )
+ {
+ }
+ else if ( IS_AUX_DEVICE_TYPE(SoundDevice->DeviceType) )
+ {
+ }
+ else
+ {
+ /* What kind of device do we have, then?!?! */
+ ASSERT(FALSE);
+ }
/* Search for an appropriate place in the list to put this instance */
if ( ! SoundDevice->FirstInstance )
@@ -171,6 +192,25 @@
}
MMRESULT
+GetSoundDeviceFromInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PSOUND_DEVICE* SoundDevice)
+{
+ ASSERT(SoundDeviceInstance);
+ ASSERT(SoundDevice);
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ *SoundDevice = SoundDeviceInstance->Device;
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
DestroySoundDeviceInstance(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
@@ -214,19 +254,3 @@
return MMSYSERR_NOERROR;
}
-
-MMRESULT
-GetSoundDeviceFromInstance(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PSOUND_DEVICE* SoundDevice)
-{
- if ( ! SoundDeviceInstance )
- return MMSYSERR_INVALPARAM;
-
- if ( ! SoundDevice )
- return MMSYSERR_INVALPARAM;
-
- *SoundDevice = SoundDeviceInstance->Device;
-
- return MMSYSERR_NOERROR;
-}
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 08:22:54 2008
@@ -11,8 +11,33 @@
#include <windows.h>
#include <mmsystem.h>
+#include <ntddk.h>
+#include <ntddsnd.h>
+
#include <mmebuddy.h>
#include "wave.h"
+
+MMRESULT
+InitWaveStreamData(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ PWAVE_STREAM_INFO StreamInfo;
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ StreamInfo = &SoundDeviceInstance->Streaming.Wave;
+
+ StreamInfo->State = WAVE_DD_IDLE;
+
+ StreamInfo->BufferQueueHead = NULL;
+ StreamInfo->BufferQueueTail = NULL;
+ StreamInfo->CurrentBuffer = NULL;
+
+ StreamInfo->BuffersOutstanding = 0;
+
+ return MMSYSERR_NOERROR;
+}
MMRESULT
QueueWaveDeviceBuffer(
@@ -40,6 +65,34 @@
BufferHeader->lpNext = NULL;
return CallUsingSoundThread(SoundDeviceInstance,
- QueueBuffer_Request,
+ QueueWaveBuffer_Request,
BufferHeader);
}
+
+MMRESULT
+GetWaveDeviceState(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR State)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! State )
+ return MMSYSERR_INVALPARAM;
+
+ return CallUsingSoundThread(SoundDeviceInstance,
+ GetWaveDeviceState_Request,
+ State);
+}
+
+MMRESULT
+PauseWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ /* TODO */
+
+ return MMSYSERR_NOERROR;
+}
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 08:22:54 2008
@@ -12,6 +12,9 @@
#include <windows.h>
#include <mmsystem.h>
+#include <ntddk.h>
+#include <ntddsnd.h>
+
#include <mmebuddy.h>
@@ -50,23 +53,40 @@
return (StreamInfo->CurrentBuffer != NULL);
}
-DWORD
+MMRESULT
PerformWaveIo(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
+ PSOUND_DEVICE SoundDevice;
+ MMRESULT Result;
PWAVE_STREAM_INFO StreamInfo;
DWORD BytesToStream, BytesStreamed = 0;
+ UCHAR DeviceType;
TRACE_("PerformWaveIo\n");
ASSERT(SoundDeviceInstance);
+
+ /* These shouldn't fail unless we pass them garbage */
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance,
+ &SoundDevice);
+
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ ASSERT(Result == MMSYSERR_NOERROR);
+ ASSERT(IS_WAVE_DEVICE_TYPE(DeviceType));
StreamInfo = &SoundDeviceInstance->Streaming.Wave;
/* If we're out of buffers, mark stream as stopped and do nothing */
if ( ! StreamInfo->CurrentBuffer )
{
- TRACE_("*** NOTHING TO DO ***\n");
+ TRACE_("*** NOTHING TO DO - state is now WAVE_DD_IDLE ***\n");
+
+ /* The stream is idle */
+ StreamInfo->State = WAVE_DD_IDLE;
+
return 0;
}
@@ -74,8 +94,6 @@
BytesToStream = MinimumOf(StreamInfo->CurrentBuffer->dwBufferLength -
StreamInfo->CurrentBuffer->reserved,
MAX_SOUND_BUFFER_SIZE);
-
- TRACE_("About to report what I'm about to write...\n");
TRACE_("Writing %p + %d (%d bytes) - buffer length is %d bytes\n",
StreamInfo->CurrentBuffer->lpData,
@@ -83,15 +101,37 @@
(int) BytesToStream,
(int) StreamInfo->CurrentBuffer->dwBufferLength);
- /* TODO: Error checking */
- OverlappedSoundDeviceIo(SoundDeviceInstance,
- (PCHAR) StreamInfo->CurrentBuffer->lpData +
+ /* Perform I/O */
+ Result = OverlappedSoundDeviceIo(
+ SoundDeviceInstance,
+ (PCHAR) StreamInfo->CurrentBuffer->lpData +
StreamInfo->CurrentBuffer->reserved,
- BytesToStream,
- CompleteWaveBuffer,
- (PVOID) StreamInfo->CurrentBuffer);
-
- /* FIXME? - find out how much was actually sent? */
+ BytesToStream,
+ CompleteWaveBuffer,
+ (PVOID) StreamInfo->CurrentBuffer);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ ERR_("Failed to perform wave device I/O! MMSYS Error %d\n",
+ (int) 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;
/* Advance the offset */
@@ -108,13 +148,14 @@
/* Increase the number of outstanding buffers */
++ StreamInfo->BuffersOutstanding;
- return BytesStreamed;
+ return MMSYSERR_NOERROR;
}
MMRESULT
StreamWaveBuffers(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
+ MMRESULT Result;
PWAVE_STREAM_INFO StreamInfo;
ASSERT(SoundDeviceInstance);
@@ -125,7 +166,10 @@
StreamHasBuffersQueued(StreamInfo) )
{
TRACE_("Performing wave I/O ...\n");
- PerformWaveIo(SoundDeviceInstance);
+ Result = PerformWaveIo(SoundDeviceInstance);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
}
TRACE_("<== Done streaming ==>\n");
@@ -159,7 +203,7 @@
}
MMRESULT
-QueueBuffer_Request(
+QueueWaveBuffer_Request(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter)
{
@@ -220,3 +264,47 @@
return MMSYSERR_NOERROR;
}
+
+MMRESULT
+GetWaveDeviceState_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PVOID Parameter)
+{
+ PUCHAR State = (PUCHAR) Parameter;
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! State )
+ return MMSYSERR_INVALPARAM;
+
+ *State = SoundDeviceInstance->Streaming.Wave.State;
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+PauseWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ /* TODO */
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+ContinueWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ /* TODO */
+
+ return MMSYSERR_NOERROR;
+}
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 08:22:54 2008
@@ -13,7 +13,22 @@
#define ROS_MMEBUDDY_WAVE_H
MMRESULT
-QueueBuffer_Request(
+QueueWaveBuffer_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter);
+
+MMRESULT
+GetWaveDeviceState_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PVOID Parameter);
+
+MMRESULT
+PauseWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter);
+
+MMRESULT
+ContinueWaveDevice_Request(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter);