Author: silverblade
Date: Sun Jul 6 07:49:03 2008
New Revision: 34328
URL:
http://svn.reactos.org/svn/reactos?rev=34328&view=rev
Log:
Added callbacks for sound device open (CreateSoundDeviceInstance) and close
(DestroySoundDeviceInstance) to MME-Buddy, allowing modules using this
library to implement custom functionality. The default callbacks just
open and close a named kernel sound device. Various other adjustments made,
mostly to improve code structure.
Modified:
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
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/mme/wodMessage.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.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
6 07:49:03 2008
@@ -10,6 +10,9 @@
Notes:
MME Buddy was the best name I could come up with...
+
+ The structures etc. here should be treated as internal to the
+ library so should not be directly accessed elsewhere.
*/
#ifndef ROS_AUDIO_MMEBUDDY_H
@@ -119,15 +122,14 @@
/*
Audio device function table
-*/
-
-typedef MMRESULT (*MMOPEN_FUNC)(
- IN UCHAR DeviceType,
- IN LPWSTR DevicePath,
- OUT PHANDLE Handle);
-
-typedef MMRESULT (*MMCLOSE_FUNC)(
- IN HANDLE Handle);
+ TODO - create/destroy instance need to work
+*/
+
+typedef MMRESULT (*MMCREATEINSTANCE_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
+
+typedef VOID (*MMDESTROYINSTANCE_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
typedef MMRESULT (*MMGETCAPS_FUNC)(
IN struct _SOUND_DEVICE* Device,
@@ -143,14 +145,19 @@
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
+typedef MMRESULT (*MMWAVEQUEUEBUFFER_FUNC)(
+ IN struct _SOUND_DEVICE_INSTANCE* Instance,
+ IN PWAVEHDR WaveHeader);
+
typedef struct _MMFUNCTION_TABLE
{
- MMOPEN_FUNC Open;
- MMCLOSE_FUNC Close;
+ MMCREATEINSTANCE_FUNC Constructor;
+ MMDESTROYINSTANCE_FUNC Destructor;
MMGETCAPS_FUNC GetCapabilities;
MMWAVEQUERYFORMAT_FUNC QueryWaveFormat;
MMWAVESETFORMAT_FUNC SetWaveFormat;
+ MMWAVEQUEUEBUFFER_FUNC QueueWaveBuffer;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
@@ -178,6 +185,12 @@
struct _SOUND_DEVICE_INSTANCE* Next;
PSOUND_DEVICE Device;
PSOUND_THREAD Thread;
+
+ /* Stuff generously donated to us from WinMM */
+ struct
+ {
+ DWORD ClientCallback;
+ } WinMM;
/* Everything below this is used by the worker thread only */
OVERLAPPED Overlapped;
@@ -222,7 +235,7 @@
ULONG
GetSoundDeviceCount(
- UCHAR DeviceType);
+ IN UCHAR DeviceType);
MMRESULT
GetSoundDevice(
@@ -236,21 +249,26 @@
OUT LPWSTR* DevicePath);
VOID
-DestroyAllSoundDevices();
+RemoveAllSoundDevices();
BOOLEAN
-DestroySoundDevices(
- UCHAR DeviceType);
+RemoveSoundDevices(
+ IN UCHAR DeviceType);
BOOLEAN
AddSoundDevice(
- UCHAR DeviceType,
- PWSTR DevicePath);
+ IN UCHAR DeviceType,
+ IN PWSTR DevicePath);
BOOLEAN
RemoveSoundDevice(
- UCHAR DeviceType,
- ULONG Index);
+ IN UCHAR DeviceType,
+ IN ULONG Index);
+
+MMRESULT
+GetSoundDeviceType(
+ IN PSOUND_DEVICE Device,
+ OUT PUCHAR DeviceType);
/*
@@ -275,15 +293,15 @@
MMRESULT
EnumerateNt4ServiceSoundDevices(
- LPWSTR ServiceName,
- UCHAR DeviceType,
- SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+ IN LPWSTR ServiceName,
+ IN UCHAR DeviceType,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
MMRESULT
DetectNt4SoundDevices(
- UCHAR DeviceType,
- PWSTR BaseDevicePath,
- SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+ IN UCHAR DeviceType,
+ IN PWSTR BaseDevicePath,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
/*
@@ -292,50 +310,54 @@
MMRESULT
OpenKernelSoundDeviceByName(
- PWSTR DeviceName,
- DWORD AccessRights,
- PHANDLE Handle);
+ IN PWSTR DeviceName,
+ IN DWORD AccessRights,
+ IN PHANDLE Handle);
MMRESULT
OpenKernelSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD AccessRights);
+ IN PSOUND_DEVICE SoundDevice,
+ IN DWORD AccessRights);
+
+MMRESULT
+CloseKernelSoundDevice(
+ PSOUND_DEVICE SoundDevice);
MMRESULT
PerformSoundDeviceIo(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID InBuffer,
- DWORD InBufferSize,
- LPVOID OutBuffer,
- DWORD OutBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped);
+ IN PSOUND_DEVICE SoundDevice,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
MMRESULT
ReadSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID OutBuffer,
- DWORD OutBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped);
+ IN PSOUND_DEVICE SoundDevice,
+ IN DWORD IoControlCode,
+ OUT LPVOID OutBuffer,
+ IN DWORD OutBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
MMRESULT
WriteSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD IoControlCode,
- LPVOID InBuffer,
- DWORD InBufferSize,
- LPDWORD BytesReturned,
- LPOVERLAPPED Overlapped);
+ IN PSOUND_DEVICE SoundDevice,
+ IN DWORD IoControlCode,
+ IN LPVOID InBuffer,
+ IN DWORD InBufferSize,
+ OUT LPDWORD BytesReturned,
+ IN LPOVERLAPPED Overlapped);
MMRESULT
WriteSoundDeviceBuffer(
- PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- LPVOID Buffer,
- DWORD BufferSize,
- LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine);
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN LPVOID Buffer,
+ IN DWORD BufferSize,
+ IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine);
/*
@@ -344,10 +366,10 @@
ULONG
GetDigitCount(
- ULONG Number);
-
-MMRESULT
-Win32ErrorToMmResult(UINT error_code);
+ IN ULONG Number);
+
+MMRESULT
+Win32ErrorToMmResult(IN UINT error_code);
/*
@@ -366,6 +388,11 @@
MMRESULT
DestroyAllInstancesOfSoundDevice(
IN PSOUND_DEVICE SoundDevice);
+
+MMRESULT
+GetSoundDeviceFromInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PSOUND_DEVICE* SoundDevice);
/*
@@ -405,6 +432,14 @@
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);
MMRESULT
QueueWaveDeviceBuffer(
@@ -442,4 +477,17 @@
IN PSOUND_DEVICE_INSTANCE Instance);
+/*
+ mme/wodMessage.c
+*/
+
+APIENTRY DWORD
+wodMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2);
+
+
#endif
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
6 07:49:03 2008
@@ -31,14 +31,14 @@
ULONG
GetSoundDeviceCount(
- UCHAR DeviceType)
+ IN UCHAR DeviceType)
{
if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
{
return 0;
}
- return SoundDeviceTotals[DeviceType];
+ return SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE];
}
@@ -96,7 +96,7 @@
VOID
-DestroyAllSoundDevices()
+RemoveAllSoundDevices()
{
ULONG i;
@@ -104,14 +104,14 @@
for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i )
{
- DestroySoundDevices(i);
+ RemoveSoundDevices(i);
}
}
BOOLEAN
-DestroySoundDevices(
- UCHAR DeviceType)
+RemoveSoundDevices(
+ IN UCHAR DeviceType)
{
PSOUND_DEVICE CurrentDevice;
PSOUND_DEVICE NextDevice;
@@ -149,6 +149,9 @@
InitSoundDeviceFunctionTable(
IN PSOUND_DEVICE Device)
{
+ Device->Functions.Constructor = DefaultInstanceConstructor;
+ Device->Functions.Destructor = DefaultInstanceDestructor;
+
Device->Functions.GetCapabilities = DefaultGetSoundDeviceCapabilities;
Device->Functions.QueryWaveFormat = DefaultQueryWaveDeviceFormatSupport;
Device->Functions.SetWaveFormat = DefaultSetWaveDeviceFormat;
@@ -157,8 +160,8 @@
BOOLEAN
AddSoundDevice(
- UCHAR DeviceType,
- LPWSTR DevicePath)
+ IN UCHAR DeviceType,
+ IN LPWSTR DevicePath)
{
PSOUND_DEVICE NewDevice;
UCHAR TypeIndex;
@@ -240,8 +243,8 @@
BOOLEAN
RemoveSoundDevice(
- UCHAR DeviceType,
- ULONG Index)
+ IN UCHAR DeviceType,
+ IN ULONG Index)
{
ULONG Counter = 0;
ULONG TypeIndex;
@@ -309,14 +312,31 @@
}
+MMRESULT
+GetSoundDeviceType(
+ IN PSOUND_DEVICE Device,
+ OUT PUCHAR DeviceType)
+{
+ if ( ! Device )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! DeviceType )
+ return MMSYSERR_INVALPARAM;
+
+ *DeviceType = Device->DeviceType;
+
+ return MMSYSERR_NOERROR;
+}
+
+
#include <ntddk.h> /* How do I avoid this? */
/* Should these go somewhere else? */
MMRESULT
GetSoundDeviceCapabilities(
- PSOUND_DEVICE Device,
- PUNIVERSAL_CAPS Capabilities)
+ IN PSOUND_DEVICE Device,
+ OUT PUNIVERSAL_CAPS Capabilities)
{
if ( ! Device )
return MMSYSERR_INVALPARAM;
@@ -496,6 +516,62 @@
}
MMRESULT
+DefaultInstanceConstructor(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance)
+{
+ PSOUND_DEVICE SoundDevice;
+ UCHAR DeviceType;
+ DWORD AccessRights = GENERIC_READ;
+ MMRESULT Result;
+
+ SOUND_DEBUG(L"Default instance ctor");
+
+ SOUND_ASSERT(SoundDeviceInstance != NULL);
+ GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ SOUND_ASSERT(SoundDevice != NULL);
+
+ /* If this fails, we have an internal error somewhere */
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SOUND_ASSERT(Result != MMSYSERR_NOERROR);
+ return MMSYSERR_ERROR;
+ }
+
+ if ( DeviceType == WAVE_OUT_DEVICE_TYPE )
+ AccessRights |= GENERIC_WRITE;
+
+ Result = OpenKernelSoundDevice(SoundDevice, AccessRights);
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ SOUND_DEBUG(L"Returning from default ctor");
+
+ return MMSYSERR_NOERROR;
+}
+
+
+VOID
+DefaultInstanceDestructor(
+ IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance)
+{
+ PSOUND_DEVICE SoundDevice;
+ MMRESULT Result;
+
+ /* TODO: Close device */
+ SOUND_DEBUG(L"Default instance dtor");
+
+ SOUND_ASSERT(SoundDeviceInstance);
+ GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ SOUND_ASSERT(SoundDevice);
+
+ Result = CloseKernelSoundDevice(SoundDevice);
+
+ ASSERT(Result == MMSYSERR_NOERROR);
+}
+
+
+MMRESULT
QueueWaveDeviceBuffer(
IN PSOUND_DEVICE_INSTANCE Instance,
IN PWAVEHDR BufferHeader)
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
6 07:49:03 2008
@@ -19,109 +19,185 @@
#include <mmebuddy.h>
/*
- Instances
-*/
-
-MMRESULT
-CreateSoundDeviceInstance(
+ Init / New / Delete handlers
+*/
+
+VOID
+InitSoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ /* Initialise */
+ SoundDeviceInstance->Next = NULL;
+ SoundDeviceInstance->Device = NULL;
+ SoundDeviceInstance->Thread = NULL;
+}
+
+PSOUND_DEVICE_INSTANCE
+AllocateSoundDeviceInstance()
+{
+ PSOUND_DEVICE_INSTANCE ptr;
+ ptr = AllocateMemoryFor(SOUND_DEVICE_INSTANCE);
+
+ if ( ! ptr )
+ return NULL;
+
+ InitSoundDeviceInstance(ptr);
+
+ return ptr;
+}
+
+VOID
+FreeSoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ FreeMemory(SoundDeviceInstance);
+}
+
+
+/*
+ List management
+*/
+
+VOID
+ListSoundDeviceInstance(
IN PSOUND_DEVICE SoundDevice,
- OUT PSOUND_DEVICE_INSTANCE* Instance)
-{
- PSOUND_DEVICE_INSTANCE NewInstance = NULL;
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
- if ( ! SoundDevice )
- return MMSYSERR_INVALPARAM;
-
- if ( ! Instance )
- return MMSYSERR_INVALPARAM;
-
- NewInstance = AllocateMemoryFor(SOUND_DEVICE_INSTANCE);
-/*
- NewInstance = (PSOUND_DEVICE_INSTANCE)
- HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(SOUND_DEVICE_INSTANCE));
-*/
-
- if ( ! NewInstance )
- return MMSYSERR_NOMEM;
-
- /* Initialise */
- NewInstance->Next = NULL;
- NewInstance->Device = SoundDevice;
- NewInstance->Thread = NULL;
+ SOUND_ASSERT(SoundDevice != NULL);
+ SOUND_ASSERT(SoundDeviceInstance != NULL);
+ SOUND_ASSERT(SoundDeviceInstance->Device == NULL);
+
+ SoundDeviceInstance->Device = SoundDevice;
/* Search for an appropriate place in the list to put this instance */
- CurrentInstance = SoundDevice->FirstInstance;
-
- if ( ! CurrentInstance )
+ if ( ! SoundDevice->FirstInstance )
{
/* This is going to be the first instance */
- SoundDevice->FirstInstance = CurrentInstance;
+ SoundDevice->FirstInstance = SoundDeviceInstance;
}
else
{
/* There is already one or more instances */
+ CurrentInstance = SoundDevice->FirstInstance;
+
while ( CurrentInstance )
{
if ( ! CurrentInstance->Next )
{
/* Add to the end and get outta here */
- CurrentInstance->Next = NewInstance;
+ CurrentInstance->Next = SoundDeviceInstance;
break;
}
CurrentInstance = CurrentInstance->Next;
}
}
-
- /* Fill the output parameter with this */
- *Instance = NewInstance;
-
- return MMSYSERR_NOERROR;
-}
-
-MMRESULT
-DestroySoundDeviceInstance(
- IN PSOUND_DEVICE_INSTANCE Instance)
-{
- PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
- PSOUND_DEVICE SoundDevice = NULL;
-
- if ( ! Instance )
- return MMSYSERR_INVALPARAM;
-
- SoundDevice = Instance->Device;
-
- /* TODO - Perform cleanup, stop playback etc. */
-
- if ( SoundDevice->FirstInstance == Instance )
- {
- /* Deleting the first instance */
+}
+
+VOID
+UnlistSoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ PSOUND_DEVICE SoundDevice;
+ PSOUND_DEVICE_INSTANCE CurrentInstance;
+
+ ASSERT(SoundDeviceInstance != NULL);
+ ASSERT(SoundDeviceInstance->Device != NULL);
+
+ SoundDevice = SoundDeviceInstance->Device;
+
+ if ( SoundDevice->FirstInstance == SoundDeviceInstance )
+ {
+ /* Removing the first instance */
SoundDevice->FirstInstance = NULL;
}
else
{
- /* Deleting an instance beyond the first */
+ /* Removing an instance beyond the first */
CurrentInstance = SoundDevice->FirstInstance;
/* If we hit the end of the list, evidently there's a bug */
- while ( CurrentInstance->Next != Instance )
+ while ( CurrentInstance->Next != SoundDeviceInstance )
{
CurrentInstance = CurrentInstance->Next;
- ASSERT(CurrentInstance);
+ ASSERT(CurrentInstance != NULL);
}
/* This is actually the one before the one we want to remove */
- CurrentInstance->Next = Instance->Next;
- }
+ CurrentInstance->Next = SoundDeviceInstance->Next;
+ }
+}
+
+
+/*
+ Public routines
+*/
+
+MMRESULT
+CreateSoundDeviceInstance(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance)
+{
+ PSOUND_DEVICE_INSTANCE CreatedInstance = NULL;
+ MMRESULT Result;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ CreatedInstance = AllocateSoundDeviceInstance();
+ if ( ! CreatedInstance )
+ return MMSYSERR_NOMEM;
+
+ /* Add the new instance to the device's instance list */
+ ListSoundDeviceInstance(SoundDevice, CreatedInstance);
+
+ /* Consult the custom construction function */
+ Result = SoundDevice->Functions.Constructor(CreatedInstance);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SOUND_DEBUG(L"Custom ctor returned failure - unlisting");
+ UnlistSoundDeviceInstance(CreatedInstance);
+ SOUND_DEBUG(L"Freeing");
+ FreeSoundDeviceInstance(CreatedInstance);
+ CreatedInstance = NULL;
+ //DestroySoundDeviceInstance(CreatedInstance);
+ }
+
+ /* Fill the output parameter with this */
+ *SoundDeviceInstance = CreatedInstance;
+
+ return Result;
+}
+
+MMRESULT
+DestroySoundDeviceInstance(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
+{
+ PSOUND_DEVICE SoundDevice = NULL;
+
+ if ( ! SoundDeviceInstance )
+ return MMSYSERR_INVALPARAM;
+
+ SoundDevice = SoundDeviceInstance->Device;
+
+ /* TODO - Perform cleanup, stop playback etc. */
+
+ /* Call the custom destructor */
+ SoundDevice->Functions.Destructor(SoundDeviceInstance);
+
+ /* Remove the isntance from the device's instance list */
+ UnlistSoundDeviceInstance(SoundDeviceInstance);
/* Kill it! */
- FreeMemory(Instance);
+ FreeSoundDeviceInstance(SoundDeviceInstance);
/*HeapFree(GetProcessHeap(), 0, Instance);*/
- return MMSYSERR_NOTSUPPORTED;
+ return MMSYSERR_NOERROR;
}
MMRESULT
@@ -148,3 +224,18 @@
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/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 6
07:49:03 2008
@@ -88,6 +88,22 @@
&SoundDevice->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
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wodMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wodMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wodMessage.c [iso-8859-1]
Sun Jul 6 07:49:03 2008
@@ -42,6 +42,9 @@
{
UNIVERSAL_CAPS Capabilities;
+ if ( parameter2 < sizeof(WAVEOUTCAPS) )
+ return MMSYSERR_INVALPARAM;
+
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, device_id, &Device);
if ( Result != MMSYSERR_NOERROR )
return Result;
@@ -63,16 +66,14 @@
if ( Result != MMSYSERR_NOERROR )
return Result;
-/*
if ( parameter2 & WAVE_FORMAT_QUERY )
{
- Result = QueryWaveDeviceFormat(Device,
+ Result = QueryWaveDeviceFormatSupport(Device,
OpenParameters->lpFormat,
sizeof(WAVEFORMATEX));
return Result;
}
-*/
Result = CreateSoundDeviceInstance(Device, &Instance);
if ( Result != MMSYSERR_NOERROR )
@@ -88,7 +89,7 @@
return Result;
}
-
+ /* TODO: Provide winmm with instance handle */
/* TODO: Send callback... */
return MMSYSERR_NOERROR;
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] Sun Jul 6
07:49:03 2008
@@ -49,11 +49,6 @@
/* Allocate memory for the string */
ParametersKeyName = AllocateWideString(KeyLength);
-/*
- ParametersKeyName = (PWCHAR) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- KeyLength);
-*/
if ( ! ParametersKeyName )
return MMSYSERR_NOMEM;
@@ -76,12 +71,10 @@
{
/* Couldn't open the key */
FreeMemory(ParametersKeyName);
- /*HeapFree(GetProcessHeap(), 0, ParametersKeyName);*/
return MMSYSERR_ERROR;
}
FreeMemory(ParametersKeyName);
- /*HeapFree(GetProcessHeap(), 0, ParametersKeyName);*/
return MMSYSERR_NOERROR;
}
@@ -121,11 +114,6 @@
/* Allocate storage for the string */
RegPath = AllocateWideString(PathLength);
-/*
- RegPath = (PWCHAR) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- PathSize);
-*/
if ( ! RegPath )
{
@@ -152,12 +140,10 @@
{
/* Couldn't open the key */
FreeMemory(RegPath);
- /*HeapFree(GetProcessHeap(), 0, RegPath);*/
return MMSYSERR_ERROR;
}
FreeMemory(RegPath);
- /*HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, RegPath);*/
return MMSYSERR_NOERROR;
}
@@ -170,9 +156,9 @@
*/
MMRESULT
EnumerateNt4ServiceSoundDevices(
- LPWSTR ServiceName,
- UCHAR DeviceType,
- SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+ IN LPWSTR ServiceName,
+ IN UCHAR DeviceType,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
{
HKEY Key;
DWORD KeyIndex = 0;
@@ -211,13 +197,6 @@
return MMSYSERR_ERROR;
}
- /* Account for terminating NULL */
-/* ++ MaxNameLength;
-
- DevicePath = (PWSTR) AllocateMemory((MaxNameLength +
- strlen("\\\\.\\")) *
- sizeof(WCHAR));
-*/
DevicePath = AllocateWideString(MaxNameLength +
strlen("\\\\.\\"));
@@ -271,7 +250,6 @@
}
FreeMemory(DevicePath);
- /*HeapFree(GetProcessHeap(), 0, DevicePath);*/
RegCloseKey(DevicesKey);
}
@@ -295,9 +273,9 @@
*/
MMRESULT
DetectNt4SoundDevices(
- UCHAR DeviceType,
- PWSTR BaseDeviceName,
- SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+ IN UCHAR DeviceType,
+ IN PWSTR BaseDeviceName,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
{
ULONG DeviceNameLength = 0;
PWSTR DeviceName = NULL;
@@ -317,10 +295,6 @@
DeviceNameLength += GetDigitCount(Index);
DeviceName = AllocateWideString(DeviceNameLength);
-/*
- DeviceName = (PWSTR)
- HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DeviceNameSize);
-*/
if ( ! DeviceName )
{
@@ -331,14 +305,14 @@
{
/* Nothing like a nice clean device name */
ZeroWideString(DeviceName);
-/* ZeroMemory(DeviceName, DeviceNameSize);*/
wsprintf(DeviceName, L"%ls%d", BaseDeviceName, Index);
if ( OpenKernelSoundDeviceByName(DeviceName,
GENERIC_READ,
&DeviceHandle) == MMSYSERR_NOERROR )
{
- DPRINT("Found device %d\n", Index);
+ //DPRINT("Found device %d\n", Index);
+ MessageBox(0, DeviceName, L"Opened device", MB_OK | MB_TASKMODAL);
/* Notify the callback function */
if ( SoundDeviceDetectedProc(DeviceType, DeviceName, DeviceHandle) )
@@ -357,7 +331,6 @@
}
FreeMemory(DeviceName);
- /*HeapFree(GetProcessHeap(), 0, DeviceName);*/
return MMSYSERR_NOERROR;
}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1] Sun Jul
6 07:49:03 2008
@@ -14,11 +14,13 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddsnd.h>
#include <debug.h>
#include <ntddk.h>
#include <mmebuddy.h>
+
/*
@@ -40,7 +42,7 @@
PWSTR DevicePath,
HANDLE Handle)
{
- MessageBox(0, DevicePath, L"CALLBACK", MB_OK | MB_TASKMODAL);
+/* MessageBox(0, DevicePath, L"CALLBACK", MB_OK | MB_TASKMODAL);*/
AddSoundDevice(DeviceType, DevicePath);
@@ -48,8 +50,8 @@
}
-APIENTRY VOID
-Test()
+VOID
+TestDeviceDetection()
{
ULONG WaveInCount, WaveOutCount;
ULONG MidiInCount, MidiOutCount;
@@ -196,7 +198,7 @@
return;
}
- Result = OpenKernelSoundDevice(Device, GENERIC_READ | GENERIC_WRITE);
+/* Result = OpenKernelSoundDevice(Device, GENERIC_READ | GENERIC_WRITE);
if ( Result != MMSYSERR_NOERROR )
{
MessageBox(0, L"Fail open", L"Fail", MB_OK | MB_TASKMODAL);
@@ -204,6 +206,7 @@
}
wsprintf(msg, L"Opened handle %x", Device->Handle);
MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL);
+*/
Result = CreateSoundDeviceInstance(Device, &Instance);
if ( Result != MMSYSERR_NOERROR )
@@ -249,6 +252,9 @@
*/
wsprintf(msg, L"Play result: %d", Result);
MessageBox(0, msg, L"Result", MB_OK | MB_TASKMODAL);
+
+ StopWaveThread(Instance);
+ DestroySoundDeviceInstance(Instance);
}
@@ -312,12 +318,42 @@
}
+VOID
+wodTest()
+{
+ //MMRESULT Result;
+ DWORD NumWaveOuts;
+ WAVEOUTCAPS Caps;
+ MMRESULT Result;
+ WCHAR String[1024];
+
+ /* Report the number of wave output devices */
+ NumWaveOuts = wodMessage(0, WODM_GETNUMDEVS, 0, 0, 0);
+ SOUND_DEBUG_HEX(NumWaveOuts);
+
+ if ( NumWaveOuts < 1 )
+ {
+ SOUND_DEBUG(L"Nothing to do as no waveout devices!");
+ return;
+ }
+
+ Result = wodMessage(0, WODM_GETDEVCAPS, 0,
+ (DWORD) &Caps, sizeof(WAVEOUTCAPS));
+
+ wsprintf(String, L"Device name: %hS\nManufacturer ID: %d\nProduct ID: %d\nDriver
version: %x\nChannels: %d", Caps.szPname, Caps.wMid, Caps.wPid, Caps.vDriverVersion,
Caps.wChannels);
+
+ MessageBox(0, String, L"Device caps", MB_OK | MB_TASKMODAL);
+}
+
+
int APIENTRY wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow)
{
+// TestDeviceDetection();
+// wodTest();
// TestFormatQuery();
TestPlaybackHackingly();
// TestDevEnum();