Author: silverblade
Date: Sun Jul 13 11:26:02 2008
New Revision: 34462
URL:
http://svn.reactos.org/svn/reactos?rev=34462&view=rev
Log:
Store the open device handle in the instance structure rather than the device
structure, to allow devices to be opened multiple times.
Modified:
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/devices.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.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/wave.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
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 11:26:02 2008
@@ -181,6 +181,13 @@
IN struct _SOUND_DEVICE_INSTANCE* Instance,
IN PWAVEHDR WaveHeader);
+typedef MMRESULT (*MMGETWAVESTATE_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* Instance,
+ OUT PUCHAR State);
+
+typedef MMRESULT (*MMSETWAVESTATE_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* Instance);
+
typedef struct _MMFUNCTION_TABLE
{
MMCREATEINSTANCE_FUNC Constructor;
@@ -190,6 +197,10 @@
MMWAVEQUERYFORMAT_FUNC QueryWaveFormat;
MMWAVESETFORMAT_FUNC SetWaveFormat;
MMWAVEQUEUEBUFFER_FUNC QueueWaveBuffer;
+
+ MMGETWAVESTATE_FUNC GetWaveDeviceState;
+ MMSETWAVESTATE_FUNC PauseWaveDevice;
+ MMSETWAVESTATE_FUNC RestartWaveDevice;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
@@ -203,7 +214,6 @@
struct _SOUND_DEVICE_INSTANCE* FirstInstance;
UCHAR DeviceType;
LPWSTR DevicePath;
- HANDLE Handle;
MMFUNCTION_TABLE Functions;
} SOUND_DEVICE, *PSOUND_DEVICE;
@@ -231,6 +241,9 @@
{
struct _SOUND_DEVICE_INSTANCE* Next;
PSOUND_DEVICE Device;
+
+ /* The currently opened handle to the device */
+ HANDLE Handle;
/* PSOUND_THREAD Thread;*/
/* Stuff generously donated to us from WinMM */
@@ -304,10 +317,19 @@
VOID
RemoveAllSoundDevices();
+BOOLEAN
+IsValidSoundDevice(
+ IN PSOUND_DEVICE SoundDevice);
+
MMRESULT
GetSoundDeviceType(
IN PSOUND_DEVICE Device,
OUT PUCHAR DeviceType);
+
+MMRESULT
+GetSoundDeviceFunctionTable(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PMMFUNCTION_TABLE* FunctionTable);
MMRESULT
DefaultInstanceConstructor(
@@ -363,16 +385,17 @@
MMRESULT
OpenKernelSoundDevice(
- IN PSOUND_DEVICE SoundDevice,
- IN DWORD AccessRights);
+ PSOUND_DEVICE SoundDevice,
+ DWORD AccessRights,
+ PHANDLE Handle);
MMRESULT
CloseKernelSoundDevice(
- PSOUND_DEVICE SoundDevice);
-
-MMRESULT
-PerformSoundDeviceIo(
- IN PSOUND_DEVICE SoundDevice,
+ IN HANDLE Handle);
+
+MMRESULT
+PerformDeviceIo(
+ IN HANDLE Handle,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
@@ -382,8 +405,8 @@
IN LPOVERLAPPED Overlapped);
MMRESULT
-ReadSoundDevice(
- IN PSOUND_DEVICE SoundDevice,
+ReadFromDeviceHandle(
+ IN HANDLE Handle,
IN DWORD IoControlCode,
OUT LPVOID OutBuffer,
IN DWORD OutBufferSize,
@@ -391,8 +414,8 @@
IN LPOVERLAPPED Overlapped);
MMRESULT
-WriteSoundDevice(
- IN PSOUND_DEVICE SoundDevice,
+WriteToDeviceHandle(
+ IN HANDLE Handle,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
@@ -400,6 +423,35 @@
IN LPOVERLAPPED Overlapped);
MMRESULT
+PerformSoundDeviceIo(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
+
+MMRESULT
+ReadFromSoundDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
+
+MMRESULT
+WriteToSoundDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
+
+MMRESULT
WriteSoundDeviceBuffer(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN LPVOID Buffer,
@@ -453,6 +505,15 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PSOUND_DEVICE* SoundDevice);
+BOOLEAN
+IsValidSoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
+MMRESULT
+GetSoundDeviceTypeFromInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR DeviceType);
+
/*
capabilities.c
@@ -475,25 +536,25 @@
MMRESULT
QueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
MMRESULT
DefaultQueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
MMRESULT
SetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE Instance,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
MMRESULT
DefaultSetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE Instance,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
@@ -535,6 +596,32 @@
QueueWaveDeviceBuffer(
IN PSOUND_DEVICE_INSTANCE Instance,
IN PWAVEHDR BufferHeader);
+
+MMRESULT
+GetWaveDeviceState(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR State);
+
+MMRESULT
+DefaultGetWaveDeviceState(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR State);
+
+MMRESULT
+PauseWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
+MMRESULT
+DefaultPauseWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
+MMRESULT
+RestartWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
+
+MMRESULT
+DefaultRestartWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
/*
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 11:26:02 2008
@@ -31,9 +31,10 @@
MMRESULT
DefaultGetSoundDeviceCapabilities(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
OUT PUNIVERSAL_CAPS Capabilities)
{
+ HANDLE Handle;
PVOID RawCapsPtr = NULL;
ULONG CapsSize = 0;
DWORD Ioctl;
@@ -42,14 +43,14 @@
ZeroMemory(Capabilities, sizeof(UNIVERSAL_CAPS));
- if ( ! Device )
+ if ( ! SoundDevice )
return MMSYSERR_INVALPARAM;
if ( ! Capabilities )
return MMSYSERR_INVALPARAM;
/* Select appropriate IOCTL and capabilities structure */
- switch ( Device->DeviceType )
+ switch ( SoundDevice->DeviceType )
{
case WAVE_OUT_DEVICE_TYPE :
Ioctl = IOCTL_WAVE_GET_CAPABILITIES;
@@ -89,14 +90,25 @@
return MMSYSERR_NOTSUPPORTED;
}
+ Result = OpenKernelSoundDevice(SoundDevice,
+ GENERIC_READ,
+ &Handle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ return Result; /* OK? */
+ }
+
/* Call the driver */
- Result = ReadSoundDevice(
- Device,
+ Result = ReadFromDeviceHandle(
+ Handle,
Ioctl,
(LPVOID) RawCapsPtr,
CapsSize,
&BytesReturned,
NULL);
+ CloseKernelSoundDevice(Handle);
+
return Result;
}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] Sun Jul
13 11:26:02 2008
@@ -42,22 +42,70 @@
IN PSOUND_DEVICE Device,
IN PMMFUNCTION_TABLE SourceFunctionTable)
{
- /* Defaults... TODO - Make all these over-rideable! */
Device->Functions.Constructor = DefaultInstanceConstructor;
Device->Functions.Destructor = DefaultInstanceDestructor;
Device->Functions.GetCapabilities = DefaultGetSoundDeviceCapabilities;
+
+ /* Wave device specific */
Device->Functions.QueryWaveFormat = DefaultQueryWaveDeviceFormatSupport;
Device->Functions.SetWaveFormat = DefaultSetWaveDeviceFormat;
+ Device->Functions.GetWaveDeviceState = DefaultGetWaveDeviceState;
+ Device->Functions.PauseWaveDevice = DefaultPauseWaveDevice;
+ Device->Functions.RestartWaveDevice = DefaultRestartWaveDevice;
+
if ( ! SourceFunctionTable )
return;
/* If we get here, the function table is being over-ridden */
+
+ if ( SourceFunctionTable->Constructor )
+ {
+ Device->Functions.Constructor =
+ SourceFunctionTable->Constructor;
+ }
+
+ if ( SourceFunctionTable->Destructor )
+ {
+ Device->Functions.Destructor =
+ SourceFunctionTable->Destructor;
+ }
+
if ( SourceFunctionTable->GetCapabilities )
{
Device->Functions.GetCapabilities =
SourceFunctionTable->GetCapabilities;
+ }
+
+ if ( SourceFunctionTable->QueryWaveFormat )
+ {
+ Device->Functions.QueryWaveFormat =
+ SourceFunctionTable->QueryWaveFormat;
+ }
+
+ if ( SourceFunctionTable->SetWaveFormat )
+ {
+ Device->Functions.SetWaveFormat =
+ SourceFunctionTable->SetWaveFormat;
+ }
+
+ if ( SourceFunctionTable->GetWaveDeviceState )
+ {
+ Device->Functions.GetWaveDeviceState =
+ SourceFunctionTable->GetWaveDeviceState;
+ }
+
+ if ( SourceFunctionTable->PauseWaveDevice )
+ {
+ Device->Functions.PauseWaveDevice =
+ SourceFunctionTable->PauseWaveDevice;
+ }
+
+ if ( SourceFunctionTable->RestartWaveDevice )
+ {
+ Device->Functions.RestartWaveDevice =
+ SourceFunctionTable->RestartWaveDevice;
}
}
@@ -94,7 +142,6 @@
NewDevice->Next = NULL;
NewDevice->FirstInstance = NULL;
NewDevice->DeviceType = DeviceType;
- NewDevice->Handle = INVALID_HANDLE_VALUE;
NewDevice->DevicePath = AllocateWideString(wcslen(DevicePath));
/*
@@ -167,13 +214,6 @@
DestroyAllInstancesOfSoundDevice(SoundDevice);
}
- /* Close handle (if open) */
- if ( SoundDevice->Handle != INVALID_HANDLE_VALUE )
- {
- CloseHandle(SoundDevice->Handle);
- SoundDevice->Handle = INVALID_HANDLE_VALUE;
- }
-
if ( SoundDeviceLists[TypeIndex] == SoundDevice )
{
SoundDeviceLists[TypeIndex] = SoundDevice->Next;
@@ -252,6 +292,14 @@
}
}
+BOOLEAN
+IsValidSoundDevice(
+ IN PSOUND_DEVICE SoundDevice)
+{
+ /* TODO */
+ return ( SoundDevice != NULL );
+}
+
MMRESULT
GetSoundDevice(
@@ -308,16 +356,32 @@
MMRESULT
GetSoundDeviceType(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
OUT PUCHAR DeviceType)
{
- if ( ! Device )
+ if ( ! SoundDevice )
return MMSYSERR_INVALPARAM;
if ( ! DeviceType )
return MMSYSERR_INVALPARAM;
- *DeviceType = Device->DeviceType;
+ *DeviceType = SoundDevice->DeviceType;
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+GetSoundDeviceFunctionTable(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PMMFUNCTION_TABLE* FunctionTable)
+{
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! FunctionTable )
+ return MMSYSERR_INVALPARAM;
+
+ *FunctionTable = &SoundDevice->Functions;
return MMSYSERR_NOERROR;
}
@@ -353,7 +417,9 @@
if ( DeviceType == WAVE_OUT_DEVICE_TYPE )
AccessRights |= GENERIC_WRITE;
- Result = OpenKernelSoundDevice(SoundDevice, AccessRights);
+ Result = OpenKernelSoundDevice(SoundDevice,
+ AccessRights,
+ &SoundDeviceInstance->Handle);
if ( Result != MMSYSERR_NOERROR )
return Result;
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 11:26:02 2008
@@ -254,3 +254,33 @@
return MMSYSERR_NOERROR;
}
+
+BOOLEAN
+IsValidSoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ /* TODO - Once multiple instances are supported */
+ return ( SoundDeviceInstance != NULL );
+}
+
+MMRESULT
+GetSoundDeviceTypeFromInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR DeviceType)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+
+ if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! DeviceType )
+ return MMSYSERR_INVALPARAM;
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ return GetSoundDeviceType(SoundDevice, DeviceType);
+}
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
11:26:02 2008
@@ -63,7 +63,8 @@
MMRESULT
OpenKernelSoundDevice(
PSOUND_DEVICE SoundDevice,
- DWORD AccessRights)
+ DWORD AccessRights,
+ PHANDLE Handle)
{
MMRESULT Result;
@@ -73,74 +74,54 @@
return MMSYSERR_INVALPARAM;
}
- if ( SoundDevice->Handle != INVALID_HANDLE_VALUE )
- {
- ERR_("Already open?");
- return MMSYSERR_ERROR; /*MMSYSERR_ALLOC;*/
+ if ( ! Handle )
+ {
+ return MMSYSERR_INVALPARAM;
}
Result = OpenKernelSoundDeviceByName(SoundDevice->DevicePath,
AccessRights,
- &SoundDevice->Handle);
+ Handle);
return Result;
}
MMRESULT
CloseKernelSoundDevice(
- PSOUND_DEVICE SoundDevice)
-{
- if ( ! SoundDevice )
- return MMSYSERR_INVALPARAM;
-
- if ( SoundDevice->Handle == INVALID_HANDLE_VALUE )
- return MMSYSERR_ERROR; /* ok? */
-
- CloseHandle(SoundDevice->Handle);
- SoundDevice->Handle = INVALID_HANDLE_VALUE;
-
- return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-PerformSoundDeviceIo(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID InBuffer,
- DWORD InBufferSize,
- LPVOID OutBuffer,
- DWORD OutBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped)
-{
- BOOLEAN TemporaryOpen = FALSE;
+ HANDLE Handle)
+{
+ if ( Handle == INVALID_HANDLE_VALUE )
+ return MMSYSERR_INVALPARAM;
+
+ CloseHandle(Handle);
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+PerformDeviceIo(
+ IN HANDLE Handle,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
BOOLEAN IoResult = FALSE;
DWORD AccessRights = GENERIC_READ;
- MMRESULT Result;
-
- if ( ! SoundDevice )
+
+ if ( Handle == INVALID_HANDLE_VALUE )
return MMSYSERR_INVALPARAM;
/* Determine if we actually need to write stuff */
if ( InBuffer != NULL )
AccessRights |= GENERIC_WRITE;
- /* Open the device temporarily,if it's not open */
- TemporaryOpen = (SoundDevice->Handle == INVALID_HANDLE_VALUE);
-
- if ( TemporaryOpen )
- {
- MessageBox(0, L"Opening sound device", L"Info", MB_OK |
MB_TASKMODAL);
-
- Result = OpenKernelSoundDevice(SoundDevice, AccessRights);
-
- if ( Result != MMSYSERR_NOERROR )
- return Result;
- }
-
MessageBox(0, L"Doing IO", L"Info", MB_OK | MB_TASKMODAL);
IoResult = DeviceIoControl(
- SoundDevice->Handle,
+ Handle,
IoControlCode,
InBuffer,
InBufferSize,
@@ -154,27 +135,84 @@
return Win32ErrorToMmResult(GetLastError());
}
- /* If we opened the device, we must close it here */
- if ( TemporaryOpen )
- {
- MessageBox(0, L"Closing sound device", L"Info", MB_OK |
MB_TASKMODAL);
- CloseHandle(SoundDevice->Handle);
- SoundDevice->Handle = INVALID_HANDLE_VALUE;
- }
-
- return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-ReadSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID OutBuffer,
- DWORD OutBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped)
-{
- return PerformSoundDeviceIo(SoundDevice,
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+ReadFromDeviceHandle(
+ IN HANDLE Handle,
+ IN DWORD IoControlCode,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
+ return PerformDeviceIo(Handle,
+ IoControlCode,
+ NULL,
+ 0,
+ OutBuffer,
+ OutBufferSize,
+ BytesReturned,
+ Overlapped);
+}
+
+MMRESULT
+WriteToDeviceHandle(
+ IN HANDLE Handle,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
+ return PerformDeviceIo(Handle,
+ IoControlCode,
+ InBuffer,
+ InBufferSize,
+ NULL,
+ 0,
+ BytesReturned,
+ Overlapped);
+}
+
+MMRESULT
+PerformSoundDeviceIo(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
+ 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(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
+ return PerformSoundDeviceIo(SoundDeviceInstance,
IoControlCode,
NULL,
0,
@@ -185,15 +223,15 @@
}
MMRESULT
-WriteSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID InBuffer,
- DWORD InBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped)
-{
- return PerformSoundDeviceIo(SoundDevice,
+WriteToSoundDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped)
+{
+ return PerformSoundDeviceIo(SoundDeviceInstance,
IoControlCode,
InBuffer,
InBufferSize,
@@ -203,6 +241,8 @@
Overlapped);
}
+
+/* TODO: move somewhere else */
MMRESULT
WriteSoundDeviceBuffer(
PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
@@ -221,13 +261,13 @@
/*SOUND_DEBUG(msg);*/
TRACE_("WriteFileEx(%p, %p, %d, %p, %p)\n",
- SoundDeviceInstance->Device->Handle,
+ SoundDeviceInstance->Handle,
Buffer,
(int) BufferSize,
Overlapped,
CompletionRoutine);
- if ( ! WriteFileEx(SoundDeviceInstance->Device->Handle,
+ if ( ! WriteFileEx(SoundDeviceInstance->Handle,
Buffer,
BufferSize,
Overlapped,
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 11:26:02 2008
@@ -17,96 +17,155 @@
MMRESULT
QueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize)
{
- if ( ! Device )
+ PMMFUNCTION_TABLE FunctionTable;
+ UCHAR DeviceType;
+ MMRESULT Result;
+
+ if ( ! IsValidSoundDevice(SoundDevice) )
return MMSYSERR_INVALPARAM;
if ( ! WaveFormat )
return MMSYSERR_INVALPARAM;
- /* TODO: Should we check the size? */
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ ASSERT(Result == MMSYSERR_NOERROR);
- return Device->Functions.QueryWaveFormat(Device, WaveFormat, WaveFormatSize);
+ /* Make sure we have a wave device */
+ if ( ! IS_WAVE_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_ERROR; /* FIXME? */
+
+ /* TODO: Should we check the size here? */
+
+ Result = GetSoundDeviceFunctionTable(SoundDevice,
+ &FunctionTable);
+ ASSERT(Result == MMSYSERR_NOERROR);
+ ASSERT(FunctionTable->QueryWaveFormat);
+
+ return FunctionTable->QueryWaveFormat(SoundDevice,
+ WaveFormat,
+ WaveFormatSize);
}
MMRESULT
DefaultQueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE Device,
+ IN PSOUND_DEVICE SoundDevice,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize)
{
+ HANDLE Handle;
+ UCHAR DeviceType;
+ DWORD BytesReturned = 0;
MMRESULT Result;
- DWORD BytesReturned = 0;
- if ( ! Device )
+ if ( ! IsValidSoundDevice(SoundDevice) )
return MMSYSERR_INVALPARAM;
if ( ! WaveFormat )
return MMSYSERR_INVALPARAM;
+ Result = GetSoundDeviceType(SoundDevice,
+ &DeviceType);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
/* Make sure we have a wave device */
- if ( ! IS_WAVE_DEVICE_TYPE(Device->DeviceType) )
- {
- return MMSYSERR_INVALPARAM;
- }
+ if ( ! IS_WAVE_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_INVALPARAM; /* FIXME? */
- Result = WriteSoundDevice(Device,
- IOCTL_WAVE_QUERY_FORMAT,
- (LPVOID) WaveFormat,
- WaveFormatSize,
- &BytesReturned,
- NULL);
+ Result = OpenKernelSoundDevice(SoundDevice,
+ GENERIC_READ | GENERIC_WRITE,
+ &Handle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ Result = WriteToSoundDevice(Handle,
+ IOCTL_WAVE_QUERY_FORMAT,
+ (LPVOID) WaveFormat,
+ WaveFormatSize,
+ &BytesReturned,
+ NULL);
+
+ CloseKernelSoundDevice(Handle);
return Result;
}
MMRESULT
SetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE Instance,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize)
{
- if ( ! Instance )
+ UCHAR DeviceType;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE FunctionTable;
+ MMRESULT Result;
+
+ if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
return MMSYSERR_INVALPARAM;
if ( ! WaveFormat )
return MMSYSERR_INVALPARAM;
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ /* Make sure we have a wave device */
+ if ( ! IS_WAVE_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_INVALPARAM; /* FIXME? */
+
/* TODO: Should we check the size? */
- return Instance->Device->Functions.SetWaveFormat(Instance, WaveFormat,
WaveFormatSize);
+ Result = GetSoundDeviceFunctionTable(SoundDevice,
+ &FunctionTable);
+ ASSERT(Result == MMSYSERR_NOERROR);
+ ASSERT(FunctionTable->SetWaveFormat);
+
+ return FunctionTable->SetWaveFormat(SoundDeviceInstance,
+ WaveFormat,
+ WaveFormatSize);
}
MMRESULT
DefaultSetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE Instance,
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize)
{
+ PSOUND_DEVICE SoundDevice;
+ UCHAR DeviceType;
MMRESULT Result;
DWORD BytesReturned = 0;
- if ( ! Instance )
+ if ( ! IsValidSoundDeviceInstance(SoundDeviceInstance) )
return MMSYSERR_INVALPARAM;
if ( ! WaveFormat )
return MMSYSERR_INVALPARAM;
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ ASSERT(Result == MMSYSERR_NOERROR);
+
/* Make sure we have a wave device */
- if ( ! IS_WAVE_DEVICE_TYPE(Instance->Device->DeviceType) )
- {
- return MMSYSERR_INVALPARAM;
- }
+ if ( ! IS_WAVE_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_INVALPARAM; /* FIXME? */
- Result = WriteSoundDevice(Instance->Device,
- IOCTL_WAVE_SET_FORMAT,
- (LPVOID) WaveFormat,
- WaveFormatSize,
- &BytesReturned,
- NULL);
+ Result = WriteToSoundDevice(SoundDeviceInstance,
+ IOCTL_WAVE_SET_FORMAT,
+ (LPVOID) WaveFormat,
+ WaveFormatSize,
+ &BytesReturned,
+ NULL);
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 11:26:02 2008
@@ -86,13 +86,67 @@
}
MMRESULT
+DefaultGetWaveDeviceState(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PUCHAR State)
+{
+// MMRESULT Result;
+
+ 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;
+}
+
+MMRESULT
PauseWaveDevice(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
if ( ! SoundDeviceInstance )
return MMSYSERR_INVALPARAM;
+ return CallUsingSoundThread(SoundDeviceInstance,
+ PauseWaveDevice_Request,
+ NULL);
+}
+
+MMRESULT
+DefaultPauseWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ TRACE_("Pausing device\n");
/* TODO */
-
return MMSYSERR_NOERROR;
}
+
+MMRESULT
+RestartWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ return CallUsingSoundThread(SoundDeviceInstance,
+ RestartWaveDevice_Request,
+ NULL);
+}
+
+MMRESULT
+DefaultRestartWaveDevice(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ TRACE_("Restarting device\n");
+ /* 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 11:26:02 2008
@@ -270,6 +270,9 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PVOID Parameter)
{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE Functions;
PUCHAR State = (PUCHAR) Parameter;
if ( ! SoundDeviceInstance )
@@ -278,33 +281,56 @@
if ( ! State )
return MMSYSERR_INVALPARAM;
- *State = SoundDeviceInstance->Streaming.Wave.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
+PauseWaveDevice_Request(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN PVOID Parameter)
+{
+ MMRESULT Result;
+ PSOUND_DEVICE SoundDevice;
+ PMMFUNCTION_TABLE Functions;
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ 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)
+{
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( SoundDeviceInstance->Streaming.Wave.State != WAVE_DD_STOPPED )
+ {
+ WARN_("Nothing to do\n");
+ return MMSYSERR_NOERROR;
+ }
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 11:26:02 2008
@@ -28,7 +28,7 @@
IN PVOID Parameter);
MMRESULT
-ContinueWaveDevice_Request(
+RestartWaveDevice_Request(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter);
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 11:26:02 2008
@@ -117,13 +117,23 @@
case WODM_WRITE :
{
ASSERT(Instance != NULL);
- ASSERT(parameter1 != 0);
+
+ if ( ! parameter1 )
+ return MMSYSERR_INVALPARAM;
return QueueWaveDeviceBuffer(Instance, (PWAVEHDR) parameter1);
}
case WODM_PAUSE :
+ {
+ return PauseWaveDevice(Instance);
+ }
+
case WODM_RESTART :
+ {
+ return RestartWaveDevice(Instance);
+ }
+
case WODM_RESET :
case WODM_BREAKLOOP :
return MMSYSERR_INVALHANDLE;