Author: silverblade
Date: Sun Jul 20 14:24:21 2008
New Revision: 34612
URL:
http://svn.reactos.org/svn/reactos?rev=34612&view=rev
Log:
Reimplemented sound device capabilities retrieval. "Multimedia" control
panel applet on Windows NT4 calls our sndblst.dll which in turn retrieves
capabilities about the appropriate sound device and fills in the device
name, which the applet displays.
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/auxiliary/auxMessage.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
branches/silverblade-audio/lib/drivers/sound/mmebuddy/reentrancy.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c
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] Sun Jul 20
14:24:21 2008
@@ -10,6 +10,8 @@
History:
6 July 2008 - Created
+
+ TODO: Adhere to maximum device name length!
*/
#include <windows.h>
@@ -18,9 +20,55 @@
#include <mmebuddy.h>
//#include <debug.h>
-PWSTR SBWaveOutDeviceName = L"ROS Sound Blaster Playback";
-PWSTR SBWaveInDeviceName = L"ROS Sound Blaster Recording";
+PWSTR SBWaveOutDeviceName = L"ROS Sound Blaster Out";
+PWSTR SBWaveInDeviceName = L"ROS Sound Blaster In";
/* TODO: Mixer etc */
+
+MMRESULT
+GetSoundBlasterDeviceCapabilities(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID Capabilities,
+ IN DWORD CapabilitiesSize)
+{
+ MMRESULT Result;
+ MMDEVICE_TYPE DeviceType;
+
+ SND_ASSERT( SoundDevice );
+ SND_ASSERT( Capabilities );
+
+ SND_TRACE(L"Sndblst - GetSoundBlasterDeviceCapabilities\n");
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+ /* Use the default method of obtaining device capabilities */
+ Result = DefaultGetSoundDeviceCapabilities(SoundDevice,
+ Capabilities,
+ CapabilitiesSize);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ /* Inject the appropriate device name */
+ switch ( DeviceType )
+ {
+ case WAVE_OUT_DEVICE_TYPE :
+ {
+ LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities;
+ CopyWideString(WaveOutCaps->szPname, SBWaveOutDeviceName);
+ break;
+ }
+ case WAVE_IN_DEVICE_TYPE :
+ {
+ LPWAVEINCAPS WaveInCaps = (LPWAVEINCAPS) Capabilities;
+ CopyWideString(WaveInCaps->szPname, SBWaveInDeviceName);
+ break;
+ }
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
BOOLEAN FoundDevice(
UCHAR DeviceType,
@@ -28,11 +76,13 @@
{
MMRESULT Result;
PSOUND_DEVICE SoundDevice = NULL;
+ MMFUNCTION_TABLE FuncTable;
SND_TRACE(L"Callback received: %wS\n", DevicePath);
+ FuncTable.GetCapabilities = GetSoundBlasterDeviceCapabilities;
+
/*
- MMFUNCTION_TABLE FuncTable;
ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
@@ -47,6 +97,7 @@
}
/* TODO: Set up function table */
+ SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
return TRUE;
}
@@ -85,6 +136,16 @@
return 0L;
}
+/*
+ PSOUND_DEVICE snd;
+ GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &snd);
+ GetSoundDevice(AUX_DEVICE_TYPE, 0, &snd);
+ GetSoundDevice(AUX_DEVICE_TYPE, 1, &snd);
+ GetSoundDevice(AUX_DEVICE_TYPE, 2, &snd);
+*/
+
+ SND_TRACE(L"Initialisation complete\n");
+
return 1L;
}
@@ -102,6 +163,20 @@
return 1L;
}
+ case DRV_ENABLE :
+ case DRV_DISABLE :
+ {
+ SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
+ return 1L;
+ }
+
+ case DRV_OPEN :
+ case DRV_CLOSE :
+ {
+ SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
+ return 1L;
+ }
+
case DRV_QUERYCONFIGURE :
{
SND_TRACE(L"DRV_QUERYCONFIGURE");
@@ -111,6 +186,7 @@
return DRVCNF_OK;
default :
+ SND_TRACE(L"Unhandled message %d\n", Message);
return DefDriverProc(DriverId,
DriverHandle,
Message,
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
20 14:24:21 2008
@@ -126,12 +126,58 @@
*/
typedef UCHAR MMDEVICE_TYPE, *PMMDEVICE_TYPE;
+struct _SOUND_DEVICE;
+
+
+#define DEFINE_GETCAPS_FUNCTYPE(func_typename, caps_type) \
+ typedef MMRESULT (*func_typename)( \
+ IN struct _SOUND_DEVICE* SoundDevice, \
+ OUT caps_type Capabilities, \
+ IN DWORD CapabilitiesSize);
+
+/* This one is for those of us who don't care */
+DEFINE_GETCAPS_FUNCTYPE(MMGETCAPS_FUNC, PVOID);
+
+/* These are for those of us that do */
+DEFINE_GETCAPS_FUNCTYPE(MMGETWAVEOUTCAPS_FUNC, LPWAVEOUTCAPS);
+DEFINE_GETCAPS_FUNCTYPE(MMGETWAVEINCAPS_FUNC, LPWAVEINCAPS );
+DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIOUTCAPS_FUNC, LPMIDIOUTCAPS);
+DEFINE_GETCAPS_FUNCTYPE(MMGETMIDIINCAPS_FUNC, LPMIDIINCAPS );
+
+typedef struct _MMFUNCTION_TABLE
+{
+ union
+ {
+ MMGETCAPS_FUNC GetCapabilities;
+ MMGETWAVEOUTCAPS_FUNC GetWaveOutCapabilities;
+ MMGETWAVEINCAPS_FUNC GetWaveInCapabilities;
+ MMGETMIDIOUTCAPS_FUNC GetMidiOutCapabilities;
+ MMGETMIDIINCAPS_FUNC GetMidiInCapabilities;
+ };
+
+/*
+ MMCREATEINSTANCE_FUNC Constructor;
+ MMDESTROYINSTANCE_FUNC Destructor;
+ MMGETCAPS_FUNC GetCapabilities;
+
+ MMWAVEQUERYFORMAT_FUNC QueryWaveFormat;
+ MMWAVESETFORMAT_FUNC SetWaveFormat;
+ MMWAVEQUEUEBUFFER_FUNC QueueWaveBuffer;
+
+ MMGETWAVESTATE_FUNC GetWaveDeviceState;
+ MMSETWAVESTATE_FUNC PauseWaveDevice;
+ MMSETWAVESTATE_FUNC RestartWaveDevice;
+ MMSETWAVESTATE_FUNC ResetWaveDevice;
+ MMSETWAVESTATE_FUNC BreakWaveDeviceLoop;
+*/
+} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
typedef struct _SOUND_DEVICE
{
struct _SOUND_DEVICE* Next;
MMDEVICE_TYPE Type;
PWSTR Path;
+ MMFUNCTION_TABLE FunctionTable;
} SOUND_DEVICE, *PSOUND_DEVICE;
typedef struct _SOUND_DEVICE_INSTANCE
@@ -157,6 +203,30 @@
VOID
ReleaseEntrypointMutex(
IN MMDEVICE_TYPE DeviceType);
+
+
+/*
+ capabilities.c
+*/
+
+MMRESULT
+MmeGetSoundDeviceCapabilities(
+ IN MMDEVICE_TYPE DeviceType,
+ IN DWORD DeviceId,
+ IN PVOID Capabilities,
+ IN DWORD CapabilitiesSize);
+
+MMRESULT
+GetSoundDeviceCapabilities(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID Capabilities,
+ IN DWORD CapabilitiesSize);
+
+MMRESULT
+DefaultGetSoundDeviceCapabilities(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID Capabilities,
+ IN DWORD CapabilitiesSize);
/*
@@ -194,6 +264,31 @@
IN MMDEVICE_TYPE DeviceType,
IN DWORD DeviceIndex,
OUT PSOUND_DEVICE* Device);
+
+MMRESULT
+GetSoundDevicePath(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT LPWSTR* DevicePath);
+
+MMRESULT
+GetSoundDeviceType(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PMMDEVICE_TYPE DeviceType);
+
+
+/*
+ functiontable.c
+*/
+
+MMRESULT
+SetSoundDeviceFunctionTable(
+ IN PSOUND_DEVICE SoundDevice,
+ IN PMMFUNCTION_TABLE FunctionTable OPTIONAL);
+
+MMRESULT
+GetSoundDeviceFunctionTable(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PMMFUNCTION_TABLE* FunctionTable);
/*
@@ -289,7 +384,7 @@
MMRESULT
OpenKernelSoundDeviceByName(
- IN PWSTR DeviceName,
+ IN PWSTR DevicePath,
IN BOOLEAN ReadOnly,
OUT PHANDLE Handle);
@@ -492,432 +587,6 @@
} Streaming;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
-
-/*
- Thread requests
-*/
-
-#define THREADREQUEST_EXIT 0
-#define WAVEREQUEST_QUEUE_BUFFER 1
-
-
-/*
- entry.c
-*/
-
-LONG
-DefaultDriverProc(
- DWORD driver_id,
- HANDLE driver_handle,
- UINT message,
- LONG parameter1,
- LONG parameter2);
-
-
-/*
- devices.c
-*/
-
-ULONG
-GetSoundDeviceCount(
- IN UCHAR DeviceType);
-
-MMRESULT
-GetSoundDevice(
- IN UCHAR DeviceType,
- IN ULONG DeviceIndex,
- OUT PSOUND_DEVICE* Device);
-
-MMRESULT
-GetSoundDevicePath(
- IN PSOUND_DEVICE SoundDevice,
- OUT LPWSTR* DevicePath);
-
-BOOLEAN
-AddSoundDevice(
- IN UCHAR DeviceType,
- IN PWSTR DevicePath,
- IN PMMFUNCTION_TABLE FunctionTable);
-
-MMRESULT
-RemoveSoundDevice(
- IN PSOUND_DEVICE SoundDevice);
-
-MMRESULT
-RemoveSoundDevices(
- IN UCHAR DeviceType);
-
-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(
- IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
-
-VOID
-DefaultInstanceDestructor(
- IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance);
-
-
-/*
- nt4.c
-*/
-
-typedef BOOLEAN (*SOUND_DEVICE_DETECTED_PROC)(
- UCHAR DeviceType,
- PWSTR DevicePath,
- HANDLE Handle);
-
-MMRESULT
-OpenSoundDriverParametersRegKey(
- IN LPWSTR ServiceName,
- OUT PHKEY KeyHandle);
-
-MMRESULT
-OpenSoundDeviceRegKey(
- IN LPWSTR ServiceName,
- IN DWORD DeviceIndex,
- OUT PHKEY KeyHandle);
-
-MMRESULT
-EnumerateNt4ServiceSoundDevices(
- IN LPWSTR ServiceName,
- IN UCHAR DeviceType,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
-
-MMRESULT
-DetectNt4SoundDevices(
- IN UCHAR DeviceType,
- IN PWSTR BaseDevicePath,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
-
-
-/*
- kernel.c
-*/
-
-MMRESULT
-OpenKernelSoundDeviceByName(
- IN PWSTR DeviceName,
- IN DWORD AccessRights,
- IN PHANDLE Handle);
-
-MMRESULT
-OpenKernelSoundDevice(
- PSOUND_DEVICE SoundDevice,
- DWORD AccessRights,
- PHANDLE Handle);
-
-MMRESULT
-CloseKernelSoundDevice(
- IN HANDLE Handle);
-
-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);
-
-MMRESULT
-RetrieveFromDeviceHandle(
- IN HANDLE Handle,
- IN DWORD IoControlCode,
- OUT LPVOID OutBuffer,
- IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned,
- IN LPOVERLAPPED Overlapped);
-
-MMRESULT
-SendToDeviceHandle(
- IN HANDLE Handle,
- IN DWORD IoControlCode,
- IN LPVOID InBuffer,
- IN DWORD InBufferSize,
- OUT LPDWORD BytesReturned,
- 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);
-
-MMRESULT
-RetrieveFromSoundDevice(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN DWORD IoControlCode,
- OUT LPVOID OutBuffer,
- IN DWORD OutBufferSize,
- OUT LPDWORD BytesReturned);
-
-MMRESULT
-SendToSoundDevice(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN DWORD IoControlCode,
- IN LPVOID InBuffer,
- IN DWORD InBufferSize,
- OUT LPDWORD BytesReturned);
-
-MMRESULT
-WriteSoundDeviceBuffer(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN LPVOID Buffer,
- IN DWORD BufferSize,
- IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine,
- LPOVERLAPPED Overlapped);
-
-
-/*
- utility.c
-*/
-
-PVOID
-AllocateTaggedMemory(
- IN DWORD Tag,
- IN DWORD Size);
-
-VOID
-FreeTaggedMemory(
- IN DWORD Tag,
- IN PVOID Pointer);
-
-DWORD
-GetMemoryAllocations();
-
-ULONG
-GetDigitCount(
- IN ULONG Number);
-
-MMRESULT
-Win32ErrorToMmResult(IN UINT error_code);
-
-MMRESULT
-TranslateInternalMmResult(MMRESULT Result);
-
-MMRESULT
-InitEntrypointMutexes();
-
-VOID
-CleanupEntrypointMutexes();
-
-VOID
-AcquireEntrypointMutex(
- IN MMDEVICE_TYPE DeviceType);
-
-VOID
-ReleaseEntrypointMutex(
- IN MMDEVICE_TYPE DeviceType);
-
-
-BOOLEAN
-InitMmeBuddyLib();
-
-VOID
-CleanupMmeBuddyLib();
-
-
-/*
- instances.c
-*/
-
-MMRESULT
-CreateSoundDeviceInstance(
- IN PSOUND_DEVICE SoundDevice,
- OUT PSOUND_DEVICE_INSTANCE* Instance);
-
-MMRESULT
-DestroySoundDeviceInstance(
- IN PSOUND_DEVICE_INSTANCE Instance);
-
-MMRESULT
-DestroyAllInstancesOfSoundDevice(
- IN PSOUND_DEVICE SoundDevice);
-
-MMRESULT
-GetSoundDeviceFromInstance(
- 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
-*/
-
-MMRESULT
-GetSoundDeviceCapabilities(
- IN PSOUND_DEVICE SoundDevice,
- OUT PUNIVERSAL_CAPS Capabilities);
-
-MMRESULT
-DefaultGetSoundDeviceCapabilities(
- IN PSOUND_DEVICE Device,
- OUT PUNIVERSAL_CAPS Capabilities);
-
-
-/*
- wave/format.c
-*/
-
-MMRESULT
-QueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE SoundDevice,
- IN PWAVEFORMATEX WaveFormat,
- IN DWORD WaveFormatSize);
-
-MMRESULT
-DefaultQueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE SoundDevice,
- IN PWAVEFORMATEX WaveFormat,
- IN DWORD WaveFormatSize);
-
-MMRESULT
-SetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PWAVEFORMATEX WaveFormat,
- IN DWORD WaveFormatSize);
-
-MMRESULT
-DefaultSetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PWAVEFORMATEX WaveFormat,
- IN DWORD WaveFormatSize);
-
-
-/*
- thread.c
-*/
-
-MMRESULT
-OverlappedSoundDeviceIo(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN PVOID Buffer,
- IN DWORD BufferSize,
- IN SOUND_THREAD_IO_COMPLETION_HANDLER IoCompletionHandler,
- IN PVOID CompletionParameter OPTIONAL);
-
-MMRESULT
-StartSoundThread();
-
-MMRESULT
-StopSoundThread();
-
-MMRESULT
-CallUsingSoundThread(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN SOUND_THREAD_REQUEST_HANDLER RequestHandler,
- IN PVOID Parameter);
-
-
-/*
- wave/streamcontrol.c
-*/
-
-MMRESULT
-InitWaveStreamData(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
-
-MMRESULT
-QueueWaveDeviceBuffer(
- IN PSOUND_DEVICE_INSTANCE Instance,
- IN PWAVEHDR BufferHeader);
-
-MMRESULT
-GetWaveDeviceState(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PULONG State);
-
-MMRESULT
-DefaultGetWaveDeviceState(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- OUT PULONG 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);
-
-MMRESULT
-ResetWaveDevice(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
-
-MMRESULT
-DefaultResetWaveDevice(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
-
-MMRESULT
-BreakWaveDeviceLoop(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
-
-MMRESULT
-DefaultBreakWaveDeviceLoop(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
-
-
-/*
- wave/wodMessage.c
-*/
-
-APIENTRY DWORD
-wodMessage(
- DWORD device_id,
- DWORD message,
- DWORD private_handle,
- DWORD parameter1,
- DWORD parameter2);
-
-
-/*
- mme/callback.c
-*/
-
-VOID
-NotifySoundClient(
- PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- DWORD Message,
- DWORD Parameter);
#endif
#endif
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c
[iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/auxiliary/auxMessage.c
[iso-8859-1] Sun Jul 20 14:24:21 2008
@@ -17,6 +17,9 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to auxiliary devices.
+*/
APIENTRY DWORD
auxMessage(
DWORD DeviceId,
@@ -25,9 +28,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(AUX_DEVICE_TYPE);
+
+ SND_TRACE(L"auxMessage - Message type %d\n", Message);
switch ( Message )
{
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c [iso-8859-1] Sun
Jul 20 14:24:21 2008
@@ -54,8 +54,6 @@
CopyWideString(NewDevice->Path, DevicePath);
}
- /* TODO: Initialise function table */
-
/* Return the new structure to the caller and report success */
*SoundDevice = NewDevice;
@@ -78,6 +76,8 @@
FreeMemory(SoundDevice->Path);
}
+ /* For safety the whole struct gets zeroed */
+ ZeroMemory(SoundDevice, sizeof(SOUND_DEVICE));
FreeMemory(SoundDevice);
}
@@ -97,6 +97,7 @@
return 0;
}
+ SND_TRACE(L"Returning a count of %d devices\n", SoundDeviceCounts[Index]);
return SoundDeviceCounts[Index];
}
@@ -109,11 +110,31 @@
IsValidSoundDevice(
IN PSOUND_DEVICE SoundDevice)
{
+ UCHAR TypeIndex;
+ PSOUND_DEVICE CurrentDevice;
+
if ( ! SoundDevice )
return FALSE;
- /* TODO */
- return TRUE;
+ /* Go through all the device lists */
+ for ( TypeIndex = 0; TypeIndex < SOUND_DEVICE_TYPES; ++ TypeIndex )
+ {
+ CurrentDevice = SoundDeviceListHeads[TypeIndex];
+
+ while ( CurrentDevice )
+ {
+ if ( CurrentDevice == SoundDevice )
+ {
+ /* Found the device */
+ return TRUE;
+ }
+
+ CurrentDevice = CurrentDevice->Next;
+ }
+ }
+
+ /* If we get here, nothing was found */
+ return FALSE;
}
/*
@@ -164,6 +185,9 @@
/* Add to the count */
++ SoundDeviceCounts[TypeIndex];
+
+ /* Set up the default function table */
+ SetSoundDeviceFunctionTable(NewDevice, NULL);
/* Fill in the caller's PSOUND_DEVICE */
if ( SoundDevice )
@@ -232,6 +256,9 @@
return MMSYSERR_NOERROR;
}
+/*
+ Removes all devices from one of the device lists.
+*/
MMRESULT
UnlistSoundDevices(
IN MMDEVICE_TYPE DeviceType)
@@ -254,6 +281,9 @@
return MMSYSERR_NOERROR;
}
+/*
+ Removes all devices from all lists.
+*/
VOID
UnlistAllSoundDevices()
{
@@ -269,11 +299,76 @@
}
}
+/*
+ Provides the caller with a pointer to its desired sound device, based on
+ the device type and index.
+*/
MMRESULT
GetSoundDevice(
IN MMDEVICE_TYPE DeviceType,
IN DWORD DeviceIndex,
- OUT PSOUND_DEVICE* Device OPTIONAL)
-{
- return MMSYSERR_NOTSUPPORTED;
-}
+ OUT PSOUND_DEVICE* SoundDevice)
+{
+ UCHAR TypeIndex = SOUND_DEVICE_TYPE_TO_INDEX(DeviceType);
+ DWORD CurrentIndex = 0;
+ PSOUND_DEVICE CurrentDevice;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) );
+
+ if ( DeviceIndex >= SoundDeviceCounts[TypeIndex] )
+ {
+ SND_ERR(L"Invalid device ID %d for type %d\n", DeviceIndex,
DeviceType);
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ CurrentDevice = SoundDeviceListHeads[TypeIndex];
+
+ /* Following the earlier checks, the index should be valid here. */
+ for ( CurrentIndex = 0; CurrentIndex != DeviceIndex; ++ CurrentIndex )
+ {
+ SND_ASSERT( CurrentDevice );
+ CurrentDevice = CurrentDevice->Next;
+ }
+
+ SND_TRACE(L"Returning sound device %x\n", CurrentDevice);
+
+ *SoundDevice = CurrentDevice;
+
+ return MMSYSERR_NOERROR;
+}
+
+/*
+ Provides the caller with the device path of the specified sound device.
+ This will normally be the path to a device provided by a kernel-mode
+ driver.
+*/
+MMRESULT
+GetSoundDevicePath(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT LPWSTR* DevicePath)
+{
+ VALIDATE_MMSYS_PARAMETER( SoundDevice );
+ VALIDATE_MMSYS_PARAMETER( DevicePath );
+
+ /* The caller should not modify this! */
+ *DevicePath = SoundDevice->Path;
+
+ return MMSYSERR_NOERROR;
+}
+
+/*
+ Provides the caller with the device type of the specified sound device.
+ This will be, for example, WAVE_OUT_DEVICE_TYPE, WAVE_IN_DEVICE_TYPE ...
+*/
+MMRESULT
+GetSoundDeviceType(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PMMDEVICE_TYPE DeviceType)
+{
+ VALIDATE_MMSYS_PARAMETER( SoundDevice );
+ VALIDATE_MMSYS_PARAMETER( DeviceType );
+
+ *DeviceType = SoundDevice->Type;
+
+ 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 20
14:24:21 2008
@@ -14,20 +14,28 @@
#include <ntddsnd.h>
#include <mmebuddy.h>
+/*
+ Wraps around CreateFile in order to provide a simpler interface tailored
+ towards sound driver support code. This simply takes a device path and
+ opens the device in either read-only mode, or read/write mode (depending on
+ the ReadOnly parameter).
+
+ If the device is opened in read/write mode, it is opened for overlapped I/O.
+*/
MMRESULT
OpenKernelSoundDeviceByName(
- IN PWSTR DeviceName,
+ IN PWSTR DevicePath,
IN BOOLEAN ReadOnly,
OUT PHANDLE Handle)
{
DWORD AccessRights;
- VALIDATE_MMSYS_PARAMETER( DeviceName );
+ VALIDATE_MMSYS_PARAMETER( DevicePath );
VALIDATE_MMSYS_PARAMETER( Handle );
AccessRights = ReadOnly ? GENERIC_READ : GENERIC_WRITE;
- *Handle = CreateFile(DeviceName,
+ *Handle = CreateFile(DevicePath,
AccessRights,
FILE_SHARE_WRITE, /* FIXME? Should be read also? */
NULL,
@@ -43,6 +51,9 @@
return MMSYSERR_NOERROR;
}
+/*
+ Just a wrapped around CloseHandle.
+*/
MMRESULT
CloseKernelSoundDevice(
IN HANDLE Handle)
@@ -54,6 +65,12 @@
return MMSYSERR_NOERROR;
}
+/*
+ This is a wrapper around DeviceIoControl which provides control over
+ instantiated sound devices. It takes a sound device instance rather than
+ a handle, and waits for I/O to complete (since an instantiated sound
+ device is opened in overlapped mode, this is necessary).
+*/
MMRESULT
SoundDeviceIoControl(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/midMessage.c [iso-8859-1]
Sun Jul 20 14:24:21 2008
@@ -17,6 +17,9 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to MIDI input.
+*/
APIENTRY DWORD
midMessage(
DWORD DeviceId,
@@ -25,9 +28,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(MIDI_IN_DEVICE_TYPE);
+
+ SND_TRACE(L"midMessage - Message type %d\n", Message);
switch ( Message )
{
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/modMessage.c [iso-8859-1]
Sun Jul 20 14:24:21 2008
@@ -17,6 +17,9 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to MIDI output.
+*/
APIENTRY DWORD
modMessage(
DWORD DeviceId,
@@ -25,9 +28,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(MIDI_OUT_DEVICE_TYPE);
+
+ SND_TRACE(L"modMessage - Message type %d\n", Message);
switch ( Message )
{
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mixer/mxdMessage.c [iso-8859-1]
Sun Jul 20 14:24:21 2008
@@ -17,6 +17,9 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to mixers.
+*/
APIENTRY DWORD
mxdMessage(
DWORD DeviceId,
@@ -25,9 +28,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(MIXER_DEVICE_TYPE);
+
+ SND_TRACE(L"mxdMessage - Message type %d\n", Message);
switch ( Message )
{
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Sun
Jul 20 14:24:21 2008
@@ -3,8 +3,10 @@
<module name="mmebuddy" type="staticlibrary"
allowwarnings="false" unicode="yes">
<include base="ReactOS">include/reactos/libs/sound</include>
<define name="DEBUG_NT4">1</define>
+ <file>capabilities.c</file>
<file>devicelist.c</file>
<file>deviceinstance.c</file>
+ <file>functiontable.c</file>
<file>reentrancy.c</file>
<file>utility.c</file>
<file>nt4.c</file>
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/reentrancy.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/reentrancy.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/reentrancy.c [iso-8859-1] Sun
Jul 20 14:24:21 2008
@@ -15,6 +15,11 @@
HANDLE EntrypointMutexes[SOUND_DEVICE_TYPES];
+/*
+ Creates a set of mutexes which are used for the purpose of guarding the
+ device-type specific module entry-points. If any of these fail creation,
+ all of them will be destroyed and the failure reported.
+*/
MMRESULT
InitEntrypointMutexes()
{
@@ -45,6 +50,11 @@
return Result;
}
+/*
+ Cleans up any of the entry-point guard mutexes. This will only close the
+ handles of mutexes which have been created, making it safe for use as a
+ cleanup routine even within the InitEntrypointMutexes routine above.
+*/
VOID
CleanupEntrypointMutexes()
{
@@ -61,6 +71,9 @@
}
}
+/*
+ Grabs an entry-point mutex.
+*/
VOID
AcquireEntrypointMutex(
IN MMDEVICE_TYPE DeviceType)
@@ -75,6 +88,9 @@
WaitForSingleObject(EntrypointMutexes[i], INFINITE);
}
+/*
+ Releases an entry-point mutex.
+*/
VOID
ReleaseEntrypointMutex(
IN MMDEVICE_TYPE DeviceType)
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] Sun Jul
20 14:24:21 2008
@@ -17,7 +17,7 @@
static UINT CurrentAllocations = 0;
/*
- Memory allocation helper
+ Allocates memory, zeroes it, and increases the allocation count.
*/
PVOID
AllocateMemory(
@@ -38,6 +38,9 @@
return Pointer;
}
+/*
+ Frees memory and reduces the allocation count.
+*/
VOID
FreeMemory(
IN PVOID Pointer)
@@ -50,6 +53,10 @@
-- CurrentAllocations;
}
+/*
+ Returns the current number of memory allocations outstanding. Useful for
+ detecting/tracing memory leaks.
+*/
UINT
GetMemoryAllocationCount()
{
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/widMessage.c [iso-8859-1]
Sun Jul 20 14:24:21 2008
@@ -17,6 +17,10 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to wave audio
+ input.
+*/
APIENTRY DWORD
widMessage(
DWORD DeviceId,
@@ -25,9 +29,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(WAVE_IN_DEVICE_TYPE);
+
+ SND_TRACE(L"widMessage - Message type %d\n", Message);
switch ( Message )
{
@@ -36,6 +42,15 @@
Result = GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE);
break;
}
+
+ case WIDM_GETDEVCAPS :
+ {
+ Result = MmeGetSoundDeviceCapabilities(WAVE_IN_DEVICE_TYPE,
+ DeviceId,
+ (PVOID) Parameter1,
+ Parameter2);
+ break;
+ }
}
ReleaseEntrypointMutex(WAVE_IN_DEVICE_TYPE);
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 20 14:24:21 2008
@@ -17,6 +17,10 @@
#include <mmebuddy.h>
+/*
+ Standard MME driver entry-point for messages relating to wave audio
+ output.
+*/
APIENTRY DWORD
wodMessage(
DWORD DeviceId,
@@ -25,9 +29,11 @@
DWORD Parameter1,
DWORD Parameter2)
{
- MMRESULT Result = MMSYSERR_NOERROR;
+ MMRESULT Result = MMSYSERR_NOTSUPPORTED;
AcquireEntrypointMutex(WAVE_OUT_DEVICE_TYPE);
+
+ SND_TRACE(L"wodMessage - Message type %d\n", Message);
switch ( Message )
{
@@ -36,6 +42,15 @@
Result = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
break;
}
+
+ case WODM_GETDEVCAPS :
+ {
+ Result = MmeGetSoundDeviceCapabilities(WAVE_OUT_DEVICE_TYPE,
+ DeviceId,
+ (PVOID) Parameter1,
+ Parameter2);
+ break;
+ }
}
ReleaseEntrypointMutex(WAVE_OUT_DEVICE_TYPE);