Author: silverblade
Date: Fri Jan 2 18:36:19 2009
New Revision: 38514
URL:
http://svn.reactos.org/svn/reactos?rev=38514&view=rev
Log:
Split NT4-specific part of MME-Buddy off into its own support library (using
NT4 audio driver IOCTLs for unspecified functions was a stupid idea.)
Reimplemented routines for querying wave format, setting wave format, and
opening/closing devices. The new implementation can cater for multiple
instances of a sound device.
Added:
branches/silverblade-audio/include/reactos/libs/sound/mment4.h (with props)
branches/silverblade-audio/lib/drivers/sound/mment4/
branches/silverblade-audio/lib/drivers/sound/mment4/control.c (with props)
branches/silverblade-audio/lib/drivers/sound/mment4/detect.c (with props)
branches/silverblade-audio/lib/drivers/sound/mment4/mment4.rbuild (with props)
branches/silverblade-audio/lib/drivers/sound/mment4/registry.c (with props)
Removed:
branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
Modified:
branches/silverblade-audio/dll/win32/sndblst/sndblst.c
branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild
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/deviceinstance.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devicelist.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.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/format.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wodMessage.c
branches/silverblade-audio/lib/drivers/sound/sound.rbuild
Modified: branches/silverblade-audio/dll/win32/sndblst/sndblst.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/snd…
==============================================================================
--- branches/silverblade-audio/dll/win32/sndblst/sndblst.c [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/sndblst/sndblst.c [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -18,6 +18,7 @@
#include <ntddsnd.h>
#include <mmddk.h>
#include <mmebuddy.h>
+#include <mment4.h>
//#include <debug.h>
PWSTR SBWaveOutDeviceName = L"ROS Sound Blaster Out";
@@ -42,9 +43,9 @@
SND_ASSERT( Result == MMSYSERR_NOERROR );
/* Use the default method of obtaining device capabilities */
- Result = DefaultGetSoundDeviceCapabilities(SoundDevice,
- Capabilities,
- CapabilitiesSize);
+ Result = GetNt4SoundDeviceCapabilities(SoundDevice,
+ Capabilities,
+ CapabilitiesSize);
if ( Result != MMSYSERR_NOERROR )
return Result;
@@ -68,7 +69,6 @@
return MMSYSERR_NOERROR;
}
-
BOOLEAN FoundDevice(
UCHAR DeviceType,
@@ -77,26 +77,31 @@
MMRESULT Result;
PSOUND_DEVICE SoundDevice = NULL;
MMFUNCTION_TABLE FuncTable;
-
- SND_TRACE(L"Callback received: %wS\n", DevicePath);
-
+ PWSTR PathCopy;
+
+ SND_TRACE(L"(Callback) Found device: %wS\n", DevicePath);
+
+ PathCopy = AllocateWideString(wcslen(DevicePath));
+
+ if ( ! PathCopy )
+ return FALSE;
+
+ CopyWideString(PathCopy, DevicePath);
+
+ Result = ListSoundDevice(DeviceType, (PVOID) PathCopy, &SoundDevice);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ return TranslateInternalMmResult(Result);
+ return FALSE;
+ }
+
+ /* Set up our function table */
FuncTable.GetCapabilities = GetSoundBlasterDeviceCapabilities;
-
-/*
-
- ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
-
- FuncTable.GetCapabilities = GetSoundBlasterDeviceCapabilities;
-*/
-
- Result = ListSoundDevice(DeviceType, DevicePath, &SoundDevice);
-
- if ( Result != MMSYSERR_NOERROR )
- {
- return FALSE;
- }
-
- /* TODO: Set up function table */
+ FuncTable.QueryWaveFormatSupport = QueryNt4WaveDeviceFormatSupport;
+ FuncTable.SetWaveFormat = SetNt4WaveDeviceFormat;
+ FuncTable.Open = OpenNt4SoundDevice;
+
SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
return TRUE;
@@ -153,6 +158,7 @@
{
SND_TRACE(L"DRV_FREE\n");
+ /* TODO: Clean up the path names! */
UnlistAllSoundDevices();
CleanupEntrypointMutexes();
Modified: branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/snd…
==============================================================================
--- branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/sndblst/sndblst.rbuild [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -5,6 +5,7 @@
<include base="ReactOS">include/reactos/libs/sound</include>
<include base="sndblst">.</include>
<define name="DEBUG_NT4" />
+ <library>mment4</library>
<library>mmebuddy</library>
<library>ntdll</library>
<library>kernel32</library>
Modified: branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/react…
==============================================================================
--- branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1]
(original)
+++ branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Fri Jan
2 18:36:19 2009
@@ -7,6 +7,7 @@
History:
4 July 2008 - Created
+ 31 Dec 2008 - Split off NT4-specific code into a separate library
Notes:
MME Buddy was the best name I could come up with...
@@ -60,7 +61,10 @@
} \
}
#else
- /* TODO */
+ #define SND_ERR(...) while ( 0 ) do {}
+ #define SND_WARN(...) while ( 0 ) do {}
+ #define SND_TRACE(...) while ( 0 ) do {}
+ #define SND_ASSERT(condition) while ( 0 ) do {}
#endif
/*
@@ -155,6 +159,14 @@
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
+typedef MMRESULT (*MMOPEN_FUNC)(
+ IN struct _SOUND_DEVICE* SoundDevice,
+ OUT PVOID* Handle);
+
+typedef MMRESULT (*MMCLOSE_FUNC)(
+ IN struct _SOUND_DEVICE* SoundDevice,
+ IN PVOID Handle); /* not sure about this */
+
typedef struct _MMFUNCTION_TABLE
{
union
@@ -166,6 +178,9 @@
MMGETMIDIINCAPS_FUNC GetMidiInCapabilities;
};
+ MMOPEN_FUNC Open;
+ MMCLOSE_FUNC Close;
+
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport;
MMWAVESETFORMAT_FUNC SetWaveFormat;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
@@ -174,13 +189,15 @@
{
struct _SOUND_DEVICE* Next;
MMDEVICE_TYPE Type;
- PWSTR Path;
+ PVOID Identifier; /* Path for NT4 drivers */
+ /*PWSTR Path;*/
MMFUNCTION_TABLE FunctionTable;
} SOUND_DEVICE, *PSOUND_DEVICE;
typedef struct _SOUND_DEVICE_INSTANCE
{
- HANDLE KernelDeviceHandle;
+ struct _SOUND_DEVICE* Device;
+ PVOID Handle;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
@@ -220,12 +237,6 @@
OUT PVOID Capabilities,
IN DWORD CapabilitiesSize);
-MMRESULT
-DefaultGetSoundDeviceCapabilities(
- IN PSOUND_DEVICE SoundDevice,
- OUT PVOID Capabilities,
- IN DWORD CapabilitiesSize);
-
/*
devicelist.c
@@ -242,7 +253,7 @@
MMRESULT
ListSoundDevice(
IN MMDEVICE_TYPE DeviceType,
- IN LPWSTR DevicePath OPTIONAL,
+ IN PVOID Identifier OPTIONAL,
OUT PSOUND_DEVICE* SoundDevice OPTIONAL);
MMRESULT
@@ -264,9 +275,9 @@
OUT PSOUND_DEVICE* Device);
MMRESULT
-GetSoundDevicePath(
- IN PSOUND_DEVICE SoundDevice,
- OUT LPWSTR* DevicePath);
+GetSoundDeviceIdentifier(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID* Identifier);
MMRESULT
GetSoundDeviceType(
@@ -281,7 +292,7 @@
MMRESULT
SetSoundDeviceFunctionTable(
IN PSOUND_DEVICE SoundDevice,
- IN PMMFUNCTION_TABLE FunctionTable OPTIONAL);
+ IN PMMFUNCTION_TABLE FunctionTable);
MMRESULT
GetSoundDeviceFunctionTable(
@@ -315,37 +326,10 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PSOUND_DEVICE* SoundDevice);
-
-/*
- nt4.c
-*/
-
-typedef BOOLEAN (*SOUND_DEVICE_DETECTED_PROC)(
- UCHAR DeviceType,
- PWSTR DevicePath);
-
-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 MMDEVICE_TYPE DeviceType,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
-
-MMRESULT
-DetectNt4SoundDevices(
- IN MMDEVICE_TYPE DeviceType,
- IN PWSTR BaseDeviceName,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+MMRESULT
+GetSoundDeviceInstanceHandle(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PVOID* Handle);
/*
@@ -381,13 +365,15 @@
*/
MMRESULT
+MmeOpenWaveDevice(
+ IN MMDEVICE_TYPE DeviceType,
+ IN DWORD DeviceId,
+ IN LPWAVEOPENDESC OpenParameters,
+ IN DWORD Flags,
+ OUT DWORD* PrivateHandle);
+
+MMRESULT
QueryWaveDeviceFormatSupport(
- IN PSOUND_DEVICE SoundDevice,
- IN LPWAVEFORMATEX Format,
- IN DWORD FormatSize);
-
-MMRESULT
-DefaultQueryWaveDeviceFormatSupport(
IN PSOUND_DEVICE SoundDevice,
IN LPWAVEFORMATEX Format,
IN DWORD FormatSize);
@@ -398,17 +384,12 @@
IN LPWAVEFORMATEX Format,
IN DWORD FormatSize);
-MMRESULT
-DefaultSetWaveDeviceFormat(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
- IN LPWAVEFORMATEX Format,
- IN DWORD FormatSize);
-
/*
kernel.c
*/
+#if 0
#define QueryDevice(h, ctl, o, o_size, xfer, ovl) \
Win32ErrorToMmResult( \
DeviceIoControl(h, ctl, NULL, 0, o, o_size, xfer, ovl) != 0 \
@@ -426,6 +407,7 @@
#define ControlSoundDevice(sd, ctl, i, i_size, xfer) \
SoundDeviceIoControl(sd, ctl, i, i_size, NULL, 0, xfer)
+#endif
MMRESULT
OpenKernelSoundDeviceByName(
@@ -434,12 +416,18 @@
OUT PHANDLE Handle);
MMRESULT
+OpenKernelSoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ IN BOOLEAN ReadOnly,
+ OUT PHANDLE Handle);
+
+MMRESULT
CloseKernelSoundDevice(
IN HANDLE Handle);
MMRESULT
-SoundDeviceIoControl(
- IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+SyncOverlappedDeviceIoControl(
+ IN HANDLE SoundDeviceInstance,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
Added: branches/silverblade-audio/include/reactos/libs/sound/mment4.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/react…
==============================================================================
--- branches/silverblade-audio/include/reactos/libs/sound/mment4.h (added)
+++ branches/silverblade-audio/include/reactos/libs/sound/mment4.h [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -1,0 +1,88 @@
+/*
+ ReactOS Sound System
+ MME Support Helper (NT4 Specific Parts)
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 31 December 2008 - Created
+
+ Notes:
+ This is intended for use in building NT4 compatible audio device
+ drivers. Include mmebuddy.h first.
+*/
+
+#ifndef ROS_AUDIO_MMENT4_H
+#define ROS_AUDIO_MMENT4_H
+
+/*
+ detect.c
+*/
+
+typedef BOOLEAN (*SOUND_DEVICE_DETECTED_PROC)(
+ UCHAR DeviceType,
+ PWSTR DevicePath);
+
+MMRESULT
+EnumerateNt4ServiceSoundDevices(
+ IN LPWSTR ServiceName,
+ IN MMDEVICE_TYPE DeviceType,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+
+MMRESULT
+DetectNt4SoundDevices(
+ IN MMDEVICE_TYPE DeviceType,
+ IN PWSTR BaseDeviceName,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+
+
+/*
+ registry.c
+*/
+
+MMRESULT
+OpenSoundDriverParametersRegKey(
+ IN LPWSTR ServiceName,
+ OUT PHKEY KeyHandle);
+
+MMRESULT
+OpenSoundDeviceRegKey(
+ IN LPWSTR ServiceName,
+ IN DWORD DeviceIndex,
+ OUT PHKEY KeyHandle);
+
+
+/*
+ general.c - UNSORTED
+*/
+
+MMRESULT
+GetNt4SoundDeviceCapabilities(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID Capabilities,
+ IN DWORD CapabilitiesSize);
+
+MMRESULT
+QueryNt4WaveDeviceFormatSupport(
+ IN PSOUND_DEVICE SoundDevice,
+ IN LPWAVEFORMATEX Format,
+ IN DWORD FormatSize);
+
+MMRESULT
+SetNt4WaveDeviceFormat(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN LPWAVEFORMATEX Format,
+ IN DWORD FormatSize);
+
+MMRESULT
+OpenNt4SoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID* Handle);
+
+MMRESULT
+CloseNt4SoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ IN PVOID Handle);
+
+#endif
Propchange: branches/silverblade-audio/include/reactos/libs/sound/mment4.h
------------------------------------------------------------------------------
svn:eol-style = native
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] Fri
Jan 2 18:36:19 2009
@@ -10,6 +10,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
@@ -29,6 +30,10 @@
MMRESULT Result;
SND_TRACE(L"MME *_GETCAPS for device %d of type %d\n", DeviceId,
DeviceType);
+
+ /* FIXME: Validate device type and ID */
+ VALIDATE_MMSYS_PARAMETER( Capabilities );
+ VALIDATE_MMSYS_PARAMETER( CapabilitiesSize > 0 );
/* Our parameter checks are done elsewhere */
Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
@@ -126,82 +131,3 @@
Capabilities,
CapabilitiesSize);
}
-
-/*
- Provides a default implementation for the "get capabilities" request,
- using the standard IOCTLs used by NT4 sound drivers.
-*/
-MMRESULT
-DefaultGetSoundDeviceCapabilities(
- IN PSOUND_DEVICE SoundDevice,
- OUT PVOID Capabilities,
- IN DWORD CapabilitiesSize)
-{
- MMRESULT Result;
- MMDEVICE_TYPE DeviceType;
- PWSTR DevicePath;
- DWORD IoCtl;
- DWORD BytesTransferred;
- HANDLE DeviceHandle;
-
- /* If these are bad there's an internal error with MME-Buddy! */
- SND_ASSERT( SoundDevice );
- SND_ASSERT( Capabilities );
- SND_ASSERT( CapabilitiesSize > 0 );
-
- SND_TRACE(L"Default get-capabilities routine called\n");
-
- /* Get the device type */
- Result = GetSoundDeviceType(SoundDevice, &DeviceType);
- SND_ASSERT( Result == MMSYSERR_NOERROR );
-
- if ( Result != MMSYSERR_NOERROR );
- return TranslateInternalMmResult(Result);
-
- /* Get the device path */
- Result = GetSoundDevicePath(SoundDevice, &DevicePath);
- SND_ASSERT( Result == MMSYSERR_NOERROR );
-
- if ( Result != MMSYSERR_NOERROR );
- return TranslateInternalMmResult(Result);
-
- /* Choose the appropriate IOCTL */
- if ( IS_WAVE_DEVICE_TYPE(DeviceType) )
- {
- IoCtl = IOCTL_WAVE_GET_CAPABILITIES;
- }
- else if ( IS_MIDI_DEVICE_TYPE(DeviceType) )
- {
- IoCtl = IOCTL_MIDI_GET_CAPABILITIES;
- }
- else
- {
- /* TODO */
- SND_ASSERT( FALSE );
- }
-
- /* Get the capabilities information from the driver */
- Result = OpenKernelSoundDeviceByName(DevicePath, TRUE, &DeviceHandle);
-
- if ( Result != MMSYSERR_NOERROR )
- {
- SND_ERR(L"Failed to open %wS\n", DevicePath);
- return TranslateInternalMmResult(Result);
- }
-
- Result = QueryDevice(DeviceHandle,
- IoCtl,
- Capabilities,
- CapabilitiesSize,
- &BytesTransferred,
- NULL);
-
- CloseKernelSoundDevice(DeviceHandle);
-
- if ( Result != MMSYSERR_NOERROR )
- {
- SND_ERR(L"Retrieval of capabilities information failed\n");
- }
-
- return Result;
-}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/deviceinstance.c [iso-8859-1]
Fri Jan 2 18:36:19 2009
@@ -10,6 +10,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <mmebuddy.h>
MMRESULT
@@ -68,7 +69,45 @@
IN PSOUND_DEVICE SoundDevice,
OUT PSOUND_DEVICE_INSTANCE* SoundDeviceInstance)
{
- return MMSYSERR_NOTSUPPORTED;
+ MMRESULT Result;
+ PMMFUNCTION_TABLE FunctionTable;
+
+ SND_TRACE(L"Creating a sound device instance\n");
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
+ VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance != NULL );
+
+ Result = AllocateSoundDeviceInstance(SoundDeviceInstance);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ /* Get the "open" routine from the function table, and validate it */
+ Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ FreeSoundDeviceInstance(*SoundDeviceInstance);
+ return TranslateInternalMmResult(Result);
+ }
+
+ if ( FunctionTable->Open == NULL )
+ {
+ FreeSoundDeviceInstance(*SoundDeviceInstance);
+ return MMSYSERR_NOTSUPPORTED;
+ }
+
+ /* Set up the members of the structure */
+ (*SoundDeviceInstance)->Device = SoundDevice;
+
+ /* Try and open the device */
+ Result = FunctionTable->Open(SoundDevice,
(&(*SoundDeviceInstance)->Handle));
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ FreeSoundDeviceInstance(*SoundDeviceInstance);
+ return TranslateInternalMmResult(Result);
+ }
+
+ return MMSYSERR_NOERROR;
}
MMRESULT
@@ -90,5 +129,23 @@
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
OUT PSOUND_DEVICE* SoundDevice)
{
- return MMSYSERR_NOTSUPPORTED;
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( SoundDevice );
+
+ *SoundDevice = SoundDeviceInstance->Device;
+
+ return MMSYSERR_NOERROR;
}
+
+MMRESULT
+GetSoundDeviceInstanceHandle(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ OUT PVOID* Handle)
+{
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Handle );
+
+ *Handle = SoundDeviceInstance->Handle;
+
+ return MMSYSERR_NOERROR;
+}
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] Fri
Jan 2 18:36:19 2009
@@ -9,6 +9,8 @@
*/
#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
@@ -22,7 +24,6 @@
MMRESULT
AllocateSoundDevice(
IN MMDEVICE_TYPE DeviceType,
- IN PWSTR DevicePath OPTIONAL,
OUT PSOUND_DEVICE* SoundDevice)
{
PSOUND_DEVICE NewDevice;
@@ -30,7 +31,7 @@
SND_ASSERT( IsValidSoundDeviceType(DeviceType) );
SND_ASSERT( SoundDevice );
- SND_TRACE(L"Allocating SOUND_DEVICE for %wS\n", DevicePath);
+ SND_TRACE(L"Allocating a SOUND_DEVICE structure\n");
NewDevice = AllocateStruct(SOUND_DEVICE);
@@ -38,21 +39,6 @@
return MMSYSERR_NOMEM;
NewDevice->Type = DeviceType;
-
- /* Only copy the device path if one was actually passed in */
- if ( DevicePath )
- {
- NewDevice->Path = AllocateWideString(wcslen(DevicePath));
-
- if ( ! NewDevice->Path )
- {
- FreeMemory(NewDevice);
- NewDevice = NULL;
- return MMSYSERR_NOMEM;
- }
-
- CopyWideString(NewDevice->Path, DevicePath);
- }
/* Return the new structure to the caller and report success */
*SoundDevice = NewDevice;
@@ -69,12 +55,7 @@
{
SND_ASSERT( SoundDevice );
- SND_TRACE(L"Freeing SOUND_DEVICE for %wS\n", SoundDevice->Path);
-
- if ( SoundDevice->Path )
- {
- FreeMemory(SoundDevice->Path);
- }
+ SND_TRACE(L"Freeing a SOUND_DEVICE structure");
/* For safety the whole struct gets zeroed */
ZeroMemory(SoundDevice, sizeof(SOUND_DEVICE));
@@ -153,7 +134,7 @@
MMRESULT
ListSoundDevice(
IN MMDEVICE_TYPE DeviceType,
- IN LPWSTR DevicePath OPTIONAL,
+ IN PVOID Identifier OPTIONAL,
OUT PSOUND_DEVICE* SoundDevice OPTIONAL)
{
MMRESULT Result;
@@ -162,7 +143,7 @@
VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) );
- Result = AllocateSoundDevice(DeviceType, DevicePath, &NewDevice);
+ Result = AllocateSoundDevice(DeviceType, &NewDevice);
if ( Result != MMSYSERR_NOERROR )
{
@@ -188,6 +169,9 @@
/* Set up the default function table */
SetSoundDeviceFunctionTable(NewDevice, NULL);
+
+ /* Set up other members of the structure */
+ NewDevice->Identifier = Identifier;
/* Fill in the caller's PSOUND_DEVICE */
if ( SoundDevice )
@@ -343,15 +327,15 @@
driver.
*/
MMRESULT
-GetSoundDevicePath(
+GetSoundDeviceIdentifier(
IN PSOUND_DEVICE SoundDevice,
- OUT LPWSTR* DevicePath)
+ OUT PVOID* Identifier)
{
VALIDATE_MMSYS_PARAMETER( SoundDevice );
- VALIDATE_MMSYS_PARAMETER( DevicePath );
+ VALIDATE_MMSYS_PARAMETER( Identifier );
/* The caller should not modify this! */
- *DevicePath = SoundDevice->Path;
+ *Identifier = SoundDevice->Identifier;
return MMSYSERR_NOERROR;
}
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/functiontable.c [iso-8859-1] Fri
Jan 2 18:36:19 2009
@@ -11,6 +11,8 @@
*/
#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
#include <mmebuddy.h>
/*
@@ -22,40 +24,18 @@
MMRESULT
SetSoundDeviceFunctionTable(
IN PSOUND_DEVICE SoundDevice,
- IN PMMFUNCTION_TABLE FunctionTable OPTIONAL)
+ IN PMMFUNCTION_TABLE FunctionTable)
{
VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
- /*VALIDATE_MMSYS_PARAMETER( FunctionTable );*/
+ VALIDATE_MMSYS_PARAMETER( FunctionTable );
/* Zero out the existing function table (if present) */
ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE));
- /* Fill in the client-supplied functions, if provided */
- if ( FunctionTable )
- {
- CopyMemory(&SoundDevice->FunctionTable,
- FunctionTable,
- sizeof(MMFUNCTION_TABLE));
- }
-
- /* Plug any gaps in the function table */
- if ( ! SoundDevice->FunctionTable.GetCapabilities )
- {
- SoundDevice->FunctionTable.GetCapabilities =
- DefaultGetSoundDeviceCapabilities;
- }
-
- if ( ! SoundDevice->FunctionTable.QueryWaveFormatSupport )
- {
- SoundDevice->FunctionTable.QueryWaveFormatSupport =
- DefaultQueryWaveDeviceFormatSupport;
- }
-
- if ( ! SoundDevice->FunctionTable.SetWaveFormat )
- {
- SoundDevice->FunctionTable.SetWaveFormat =
- DefaultSetWaveDeviceFormat;
- }
+ /* Fill in the client-supplied functions */
+ CopyMemory(&SoundDevice->FunctionTable,
+ FunctionTable,
+ sizeof(MMFUNCTION_TABLE));
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] Fri Jan 2
18:36:19 2009
@@ -11,6 +11,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
@@ -33,8 +34,9 @@
VALIDATE_MMSYS_PARAMETER( DevicePath );
VALIDATE_MMSYS_PARAMETER( Handle );
- AccessRights = ReadOnly ? GENERIC_READ : GENERIC_WRITE;
+ AccessRights = ReadOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE;
+ SND_TRACE(L"OpenKernelSoundDeviceByName: %wS\n", DevicePath);
*Handle = CreateFile(DevicePath,
AccessRights,
FILE_SHARE_WRITE, /* FIXME? Should be read also? */
@@ -45,11 +47,13 @@
if ( *Handle == INVALID_HANDLE_VALUE )
{
+ SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
return Win32ErrorToMmResult(GetLastError());
}
return MMSYSERR_NOERROR;
}
+
/*
Just a wrapped around CloseHandle.
@@ -67,13 +71,12 @@
/*
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).
+ instantiated sound devices. It 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,
+SyncOverlappedDeviceIoControl(
+ IN HANDLE Handle,
IN DWORD IoControlCode,
IN LPVOID InBuffer,
IN DWORD InBufferSize,
@@ -85,8 +88,6 @@
BOOLEAN IoResult;
DWORD Transferred;
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
-
/* Overlapped I/O is done here - this is used for waiting for completion */
ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
@@ -95,7 +96,7 @@
return Win32ErrorToMmResult(GetLastError());
/* Talk to the device */
- IoResult = DeviceIoControl(SoundDeviceInstance->KernelDeviceHandle,
+ IoResult = DeviceIoControl(Handle,
IoControlCode,
InBuffer,
InBufferSize,
@@ -115,7 +116,7 @@
}
/* Wait for the I/O to complete */
- IoResult = GetOverlappedResult(SoundDeviceInstance->KernelDeviceHandle,
+ IoResult = GetOverlappedResult(Handle,
&Overlapped,
&Transferred,
TRUE);
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] Fri
Jan 2 18:36:19 2009
@@ -9,11 +9,11 @@
<file>functiontable.c</file>
<file>reentrancy.c</file>
<file>utility.c</file>
- <file>nt4.c</file>
<file>kernel.c</file>
<directory name="wave">
<file>widMessage.c</file>
<file>wodMessage.c</file>
+ <file>format.c</file>
</directory>
<directory name="midi">
<file>midMessage.c</file>
@@ -25,4 +25,4 @@
<directory name="auxiliary">
<file>auxMessage.c</file>
</directory>
-</module>
+</module>
Removed: 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 (removed)
@@ -1,317 +1,0 @@
-/*
- * PROJECT: ReactOS Sound System "MME Buddy" Library
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: lib/sound/mmebuddy/nt4.c
- *
- * PURPOSE: Assists in locating Windows NT4 compatible sound devices,
- * which mostly use the same device naming convention and/or
- * store their created device names within their service key
- * within the registry.
- *
- * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
-*/
-
-#include <windows.h>
-#include <mmsystem.h>
-#include <ntddsnd.h>
-
-#include <mmebuddy.h>
-
-/*
- Open the parameters key of a sound driver.
- NT4 only.
-*/
-MMRESULT
-OpenSoundDriverParametersRegKey(
- IN LPWSTR ServiceName,
- OUT PHKEY KeyHandle)
-{
- ULONG KeyLength;
- PWCHAR ParametersKeyName;
-
- VALIDATE_MMSYS_PARAMETER( ServiceName );
- VALIDATE_MMSYS_PARAMETER( KeyHandle );
-
- /* Work out how long the string will be */
- KeyLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
- + wcslen(ServiceName) + 1
- + wcslen(REG_PARAMETERS_KEY_NAME_U);
-
- /* Allocate memory for the string */
- ParametersKeyName = AllocateWideString(KeyLength);
-
- if ( ! ParametersKeyName )
- return MMSYSERR_NOMEM;
-
- /* Construct the registry path */
- wsprintf(ParametersKeyName,
- L"%s\\%s\\%s",
- REG_SERVICES_KEY_NAME_U,
- ServiceName,
- REG_PARAMETERS_KEY_NAME_U);
-
- SND_TRACE(L"Opening reg key: %wS\n", ParametersKeyName);
-
- /* Perform the open */
- if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- ParametersKeyName,
- 0,
- KEY_READ,
- KeyHandle) != ERROR_SUCCESS )
- {
- /* Couldn't open the key */
- SND_ERR(L"Failed to open reg key: %wS\n", ParametersKeyName);
- FreeMemory(ParametersKeyName);
- return MMSYSERR_ERROR;
- }
-
- FreeMemory(ParametersKeyName);
-
- return MMSYSERR_NOERROR;
-}
-
-/*
- Open one of the Device sub-keys belonging to the sound driver.
- NT4 only.
-*/
-MMRESULT
-OpenSoundDeviceRegKey(
- IN LPWSTR ServiceName,
- IN DWORD DeviceIndex,
- OUT PHKEY KeyHandle)
-{
- DWORD PathLength;
- PWCHAR RegPath;
-
- VALIDATE_MMSYS_PARAMETER( ServiceName );
- VALIDATE_MMSYS_PARAMETER( KeyHandle );
-
- /*
- Work out the space required to hold the path:
-
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
- sndblst\
- Parameters\
- Device123\
- */
- PathLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
- + wcslen(ServiceName) + 1
- + wcslen(REG_PARAMETERS_KEY_NAME_U) + 1
- + wcslen(REG_DEVICE_KEY_NAME_U)
- + GetDigitCount(DeviceIndex);
-
- /* Allocate storage for the string */
- RegPath = AllocateWideString(PathLength);
-
- if ( ! RegPath )
- {
- return MMSYSERR_NOMEM;
- }
-
- /* Write the path */
- wsprintf(RegPath,
- L"%ls\\%ls\\%ls\\%ls%d",
- REG_SERVICES_KEY_NAME_U,
- ServiceName,
- REG_PARAMETERS_KEY_NAME_U,
- REG_DEVICE_KEY_NAME_U,
- DeviceIndex);
-
- SND_TRACE(L"Opening reg key: %wS\n", RegPath);
-
- /* Perform the open */
- if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- RegPath,
- 0,
- KEY_READ,
- KeyHandle) != ERROR_SUCCESS )
- {
- /* Couldn't open the key */
- SND_ERR(L"Failed to open reg key: %wS\n", RegPath);
- FreeMemory(RegPath);
- return MMSYSERR_ERROR;
- }
-
- FreeMemory(RegPath);
-
- return MMSYSERR_NOERROR;
-}
-
-/*
- This is the "nice" way to discover audio devices in NT4 - go into the
- service registry key and enumerate the Parameters\Device*\Devices
- values. The value names represent the device name, whereas the data
- assigned to them identifies the type of device.
-*/
-MMRESULT
-EnumerateNt4ServiceSoundDevices(
- IN LPWSTR ServiceName,
- IN MMDEVICE_TYPE DeviceType,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
-{
- HKEY Key;
- DWORD KeyIndex = 0;
-
- VALIDATE_MMSYS_PARAMETER( ServiceName );
-
- /* Device type zero means "all" */
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) ||
- DeviceType == 0 );
-
- while ( OpenSoundDeviceRegKey(ServiceName, KeyIndex, &Key) == MMSYSERR_NOERROR )
- {
- HKEY DevicesKey;
- DWORD ValueType = REG_NONE, ValueIndex = 0;
- DWORD MaxNameLength = 0, ValueNameLength = 0;
- PWSTR DevicePath = NULL, ValueName = NULL;
- DWORD ValueDataLength = sizeof(DWORD);
- DWORD ValueData;
-
- if ( RegOpenKeyEx(Key,
- REG_DEVICES_KEY_NAME_U,
- 0,
- KEY_READ,
- &DevicesKey) == ERROR_SUCCESS )
- {
- /* Find out how much memory is needed for the key name */
- if ( RegQueryInfoKey(DevicesKey,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &MaxNameLength,
- NULL, NULL, NULL) != ERROR_SUCCESS )
- {
- SND_ERR(L"Failed to query registry key information\n");
- RegCloseKey(DevicesKey);
- RegCloseKey(Key);
-
- return MMSYSERR_ERROR;
- }
-
- DevicePath = AllocateWideString(MaxNameLength +
- strlen("\\\\.\\"));
-
- /* Check that the memory allocation was successful */
- if ( ! DevicePath )
- {
- /* There's no point in going further */
- RegCloseKey(DevicesKey);
- RegCloseKey(Key);
-
- return MMSYSERR_NOMEM;
- }
-
- /* Insert the device path prefix */
- wsprintf(DevicePath, L"\\\\.\\");
-
- /* The offset of the string following this prefix */
- ValueName = DevicePath + strlen("\\\\.\\");
-
- /* Copy this so that it may be overwritten - include NULL */
- ValueNameLength = MaxNameLength + sizeof(WCHAR);
-
- while ( RegEnumValue(DevicesKey,
- ValueIndex,
- ValueName,
- &ValueNameLength,
- NULL,
- &ValueType,
- (LPBYTE) &ValueData,
- &ValueDataLength) == ERROR_SUCCESS )
- {
- /* Device types are stored as DWORDs */
- if ( ( ValueType == REG_DWORD ) &&
- ( ValueDataLength == sizeof(DWORD) ) )
- {
- if ( ( DeviceType == 0 ) ||
- ( DeviceType == ValueData ) )
- {
- SND_TRACE(L"Found device: %wS\n", DevicePath);
- SoundDeviceDetectedProc(ValueData, DevicePath);
- }
- }
-
- /* Reset variables for the next iteration */
- ValueNameLength = MaxNameLength + sizeof(WCHAR);
- ZeroMemory(ValueName, (MaxNameLength+1)*sizeof(WCHAR));
- /*ZeroWideString(ValueName);*/
- ValueDataLength = sizeof(DWORD);
- ValueData = 0;
- ValueType = REG_NONE;
-
- ++ ValueIndex;
- }
-
- FreeMemory(DevicePath);
-
- RegCloseKey(DevicesKey);
- }
-
- ++ KeyIndex;
-
- RegCloseKey(Key);
- }
-
- return MMSYSERR_NOERROR;
-}
-
-/*
- Brute-force device detection, using a base device name (eg: \\.\WaveOut).
-
- This will add the device number as a suffix to the end of the string and
- attempt to open the device based on that name. On success, it will
- increment the device number and repeat this process.
-
- When it runs out of devices, it will give up.
-*/
-MMRESULT
-DetectNt4SoundDevices(
- IN MMDEVICE_TYPE DeviceType,
- IN PWSTR BaseDeviceName,
- IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
-{
- ULONG DeviceNameLength = 0;
- PWSTR DeviceName = NULL;
- ULONG Index = 0;
- HANDLE DeviceHandle;
- BOOLEAN DoSearch = TRUE;
-
- VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) );
-
- DeviceNameLength = wcslen(BaseDeviceName);
- /* Consider the length of the number */
- DeviceNameLength += GetDigitCount(Index);
-
- DeviceName = AllocateWideString(DeviceNameLength);
-
- if ( ! DeviceName )
- {
- return MMSYSERR_NOMEM;
- }
-
- while ( DoSearch )
- {
- /* Nothing like a nice clean device name */
- ZeroWideString(DeviceName);
- wsprintf(DeviceName, L"%ls%d", BaseDeviceName, Index);
-
- if ( OpenKernelSoundDeviceByName(DeviceName,
- TRUE,
- &DeviceHandle) == MMSYSERR_NOERROR )
- {
- /* Notify the callback function */
- SND_TRACE(L"Found device: %wS\n", DeviceName);
- SoundDeviceDetectedProc(DeviceType, DeviceName);
-
- CloseHandle(DeviceHandle);
-
- ++ Index;
- }
- else
- {
- DoSearch = FALSE;
- }
- }
-
- FreeMemory(DeviceName);
-
- return MMSYSERR_NOERROR;
-}
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] Fri
Jan 2 18:36:19 2009
@@ -9,6 +9,8 @@
*/
#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
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] Fri Jan
2 18:36:19 2009
@@ -10,6 +10,7 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <mmebuddy.h>
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] Fri
Jan 2 18:36:19 2009
@@ -10,9 +10,76 @@
#include <windows.h>
#include <mmsystem.h>
+#include <mmddk.h>
#include <ntddk.h>
#include <ntddsnd.h>
#include <mmebuddy.h>
+
+/* Adapted from MmeQueryWaveFormat... TODO: Move elsewhere */
+MMRESULT
+MmeOpenWaveDevice(
+ IN MMDEVICE_TYPE DeviceType,
+ IN DWORD DeviceId,
+ IN LPWAVEOPENDESC OpenParameters,
+ IN DWORD Flags,
+ OUT DWORD* PrivateHandle)
+{
+ MMRESULT Result;
+
+ PSOUND_DEVICE SoundDevice;
+ PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
+ LPWAVEFORMATEX Format;
+
+ SND_TRACE(L"Opening wave device (WIM_OPEN / WOM_OPEN)");
+
+ VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) ); /* FIXME? wave in
too? */
+ VALIDATE_MMSYS_PARAMETER( OpenParameters );
+
+ Format = OpenParameters->lpFormat;
+
+ Result = GetSoundDevice(DeviceType, DeviceId, &SoundDevice);
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ /* Does this device support the format? */
+ Result = QueryWaveDeviceFormatSupport(SoundDevice, Format, sizeof(WAVEFORMATEX));
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Format not supported\n");
+ return TranslateInternalMmResult(Result);
+ }
+
+ /* If the caller just wanted to know if a format is supported, end here */
+ if ( Flags & WAVE_FORMAT_QUERY )
+ return MMSYSERR_NOERROR;
+
+ /* Check that winmm gave us a private handle to fill */
+ VALIDATE_MMSYS_PARAMETER( PrivateHandle );
+
+ /* Create a sound device instance and open the sound device */
+ Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance);
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ Result = SetWaveDeviceFormat(SoundDeviceInstance, Format, sizeof(WAVEFORMATEX));
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ /* TODO: Destroy sound instance */
+ return TranslateInternalMmResult(Result);
+ }
+
+ /* Store the device instance pointer in the private handle - is DWORD safe here? */
+ *PrivateHandle = (DWORD) SoundDeviceInstance;
+
+ /* TODO: Call the client application back to say the device is open */
+ ReleaseEntrypointMutex(DeviceType);
+ /* ... */
+ AcquireEntrypointMutex(DeviceType);
+
+ SND_TRACE(L"Wave device now open\n");
+
+ return MMSYSERR_NOERROR;
+}
MMRESULT
QueryWaveDeviceFormatSupport(
@@ -22,7 +89,7 @@
{
MMRESULT Result;
MMDEVICE_TYPE DeviceType;
- MMFUNCTION_TABLE FunctionTable;
+ PMMFUNCTION_TABLE FunctionTable;
SND_TRACE(L"Querying wave format support\n");
@@ -33,7 +100,7 @@
Result = GetSoundDeviceType(SoundDevice, &DeviceType);
SND_ASSERT( Result == MMSYSERR_NOERROR );
- /* Ensure we have a wave device (TODO: check if wavein as well) */
+ /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) );
/* Obtain the function table */
@@ -43,7 +110,8 @@
if ( Result != MMSYSERR_NOERROR )
return TranslateInternalMmResult(Result);
- SND_ASSERT( FunctionTable->QueryWaveFormatSupport );
+ if ( ! FunctionTable->QueryWaveFormatSupport )
+ return MMSYSERR_NOTSUPPORTED;
return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize);
}
@@ -54,6 +122,36 @@
IN LPWAVEFORMATEX Format,
IN DWORD FormatSize)
{
+ MMRESULT Result;
+ MMDEVICE_TYPE DeviceType;
+ PMMFUNCTION_TABLE FunctionTable;
+ PSOUND_DEVICE SoundDevice;
+
SND_TRACE(L"Setting wave format\n");
- return MMSYSERR_NOTSUPPORTED;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Format );
+ VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
+
+ Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+ /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
+ VALIDATE_MMSYS_PARAMETER( IS_WAVE_DEVICE_TYPE(DeviceType) );
+
+ /* Obtain the function table */
+ Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable);
+ SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ if ( ! FunctionTable->SetWaveFormat )
+ return MMSYSERR_NOTSUPPORTED;
+
+ return FunctionTable->SetWaveFormat(SoundDeviceInstance, Format, FormatSize);
}
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]
Fri Jan 2 18:36:19 2009
@@ -54,6 +54,45 @@
case WODM_OPEN :
{
+ Result = MmeOpenWaveDevice(WAVE_OUT_DEVICE_TYPE,
+ DeviceId,
+ (LPWAVEOPENDESC) Parameter1,
+ Parameter2,
+ (DWORD*) PrivateHandle);
+#if 0
+ PSOUND_DEVICE SoundDevice;
+ PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
+ LPWAVEOPENDESC OpenDescriptor = (LPWAVEOPENDESC) Parameter1;
+
+ /* FIXME? Do we need the 2nd parameter to go to this routine? */
+ Result = MmeQueryWaveDeviceFormatSupport(WAVE_OUT_DEVICE_TYPE,
+ DeviceId,
+ OpenDescriptor);
+
+ if ( ( Parameter2 & WAVE_FORMAT_QUERY ) ||
+ ( Result == MMSYSERR_NOTSUPPORTED) )
+ {
+ /* Nothing more to be done */
+ break;
+ }
+
+ /* The MME API should provide us with a place to store a handle */
+ if ( ! PrivateHandle )
+ {
+ /* Not so much an invalid parameter as something messed up!! */
+ SND_ERR(L"MME API supplied a NULL private handle pointer!\n");
+ Result = MMSYSERR_ERROR;
+ break;
+ }
+
+ /* Spawn an instance of the sound device */
+ /*Result = MmeOpenWaveDevice(WAVE_OUT_DEVICE_TYPE, DeviceId,
OpenDescriptor);*/
+ /*GetSoundDevice(WAVE_OUT_DEVICE_TYPE, DeviceId, &SoundDevice);
+ Result = CreateSoundDeviceInstance(SoundDevice, &SoundDeviceInstance);*/
+
+ /* TODO... */
+#endif
+#if 0
PSOUND_DEVICE SoundDevice;
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
LPWAVEOPENDESC OpenParameters = (LPWAVEOPENDESC) Parameter1;
@@ -61,8 +100,11 @@
/* Obtain the sound device */
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, DeviceId, &SoundDevice);
- if ( Result != MMSYSERR_NOERROR );
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ Result = TranslateInternalMmResult(Result);
break;
+ }
/* See if the device supports this format */
Result = QueryWaveDeviceFormatSupport(SoundDevice,
@@ -72,10 +114,11 @@
if ( Parameter2 & WAVE_FORMAT_QUERY )
{
/* Nothing more to be done - keep the result */
+ Result = TranslateInternalMmResult(Result);
break;
}
- /* The MME API should provide us with a place to store a handle */
+
SND_ASSERT( PrivateHandle );
if ( ! PrivateHandle )
{
@@ -106,11 +149,17 @@
break;
}
+#endif
break;
}
case WODM_CLOSE :
{
+ /*
+ What should happen here?
+ - Validate the sound device instance
+ - Destroy it
+ */
break;
}
}
Added: branches/silverblade-audio/lib/drivers/sound/mment4/control.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mment4/control.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mment4/control.c [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -1,0 +1,231 @@
+/*
+ * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/sound/mment4/control.c
+ *
+ * PURPOSE: Device control for NT4 audio devices
+ *
+ * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <ntddk.h>
+#include <ntddsnd.h>
+#include <mmebuddy.h>
+#include <mment4.h>
+
+/*
+ Convenience routine for getting the path of a device and opening it.
+*/
+MMRESULT
+OpenNt4KernelSoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ IN BOOLEAN ReadOnly,
+ OUT PHANDLE Handle)
+{
+ PWSTR Path;
+ MMRESULT Result;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
+ VALIDATE_MMSYS_PARAMETER( Handle );
+
+ Result = GetSoundDeviceIdentifier(SoundDevice, (PVOID*) &Path);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Unable to get sound device path");
+ return TranslateInternalMmResult(Result);
+ }
+
+ SND_ASSERT( Path );
+
+ return OpenKernelSoundDeviceByName(Path, ReadOnly, Handle);
+}
+
+/*
+ Device open/close. These are basically wrappers for the MME-Buddy
+ open and close routines, which provide a Windows device handle.
+ These may seem simple but as you can return pretty much anything
+ as the handle, we could just as easily return a structure etc.
+*/
+MMRESULT
+OpenNt4SoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID* Handle)
+{
+ SND_TRACE(L"Opening NT4 style sound device\n");
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
+ VALIDATE_MMSYS_PARAMETER( Handle );
+
+ return OpenNt4KernelSoundDevice(SoundDevice, FALSE, Handle);
+}
+
+MMRESULT
+CloseNt4SoundDevice(
+ IN PSOUND_DEVICE SoundDevice,
+ IN PVOID Handle)
+{
+ SND_TRACE(L"Closing NT4 style sound device\n");
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
+ return CloseKernelSoundDevice((HANDLE) Handle);
+}
+
+/*
+ Provides an implementation for the "get capabilities" request,
+ using the standard IOCTLs used by NT4 sound drivers.
+*/
+MMRESULT
+GetNt4SoundDeviceCapabilities(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PVOID Capabilities,
+ IN DWORD CapabilitiesSize)
+{
+ MMRESULT Result;
+ MMDEVICE_TYPE DeviceType;
+ DWORD IoCtl;
+ HANDLE DeviceHandle;
+
+ /* If these are bad there's an internal error with MME-Buddy! */
+ SND_ASSERT( SoundDevice );
+ SND_ASSERT( Capabilities );
+ SND_ASSERT( CapabilitiesSize > 0 );
+
+ SND_TRACE(L"NT4 get-capabilities routine called\n");
+
+ /* Get the device type */
+ Result = GetSoundDeviceType(SoundDevice, &DeviceType);
+ SND_ASSERT( Result == MMSYSERR_NOERROR );
+
+ if ( Result != MMSYSERR_NOERROR );
+ return TranslateInternalMmResult(Result);
+
+ /* Choose the appropriate IOCTL */
+ if ( IS_WAVE_DEVICE_TYPE(DeviceType) )
+ {
+ IoCtl = IOCTL_WAVE_GET_CAPABILITIES;
+ }
+ else if ( IS_MIDI_DEVICE_TYPE(DeviceType) )
+ {
+ IoCtl = IOCTL_MIDI_GET_CAPABILITIES;
+ }
+ else
+ {
+ /* FIXME - need to support AUX and mixer devices */
+ SND_ASSERT( FALSE );
+ }
+
+ /* Get the capabilities information from the driver */
+ Result = OpenNt4KernelSoundDevice(SoundDevice, TRUE, &DeviceHandle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Failed to open device");
+ return TranslateInternalMmResult(Result);
+ }
+
+ Result = SyncOverlappedDeviceIoControl(DeviceHandle,
+ IoCtl,
+ Capabilities,
+ CapabilitiesSize,
+ NULL,
+ 0,
+ NULL);
+
+ CloseKernelSoundDevice(DeviceHandle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Retrieval of capabilities information failed\n");
+ Result = TranslateInternalMmResult(Result);
+ }
+
+ return Result;
+}
+
+/*
+ Querying/setting the format of a wave device. Querying format support
+ requires us to first open the device, whereas setting format is done
+ on an already opened device.
+*/
+MMRESULT
+QueryNt4WaveDeviceFormatSupport(
+ IN PSOUND_DEVICE SoundDevice,
+ IN LPWAVEFORMATEX Format,
+ IN DWORD FormatSize)
+{
+ MMRESULT Result;
+ HANDLE Handle;
+
+ SND_TRACE(L"NT4 wave format support querying routine called\n");
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
+ VALIDATE_MMSYS_PARAMETER( Format );
+ VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
+
+ /* Get the device path */
+ Result = OpenNt4KernelSoundDevice(SoundDevice,
+ FALSE,
+ &Handle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Unable to open kernel sound device\n");
+ return TranslateInternalMmResult(Result);
+ }
+
+ Result = SyncOverlappedDeviceIoControl(Handle,
+ IOCTL_WAVE_QUERY_FORMAT,
+ (LPVOID) Format,
+ FormatSize,
+ NULL,
+ 0,
+ NULL);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ SND_ERR(L"Sync overlapped I/O failed - MMSYS_ERROR %d\n", Result);
+ Result = TranslateInternalMmResult(Result);
+ }
+
+ CloseKernelSoundDevice(Handle);
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+SetNt4WaveDeviceFormat(
+ IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
+ IN LPWAVEFORMATEX Format,
+ IN DWORD FormatSize)
+{
+ MMRESULT Result;
+ HANDLE Handle;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) );
+ VALIDATE_MMSYS_PARAMETER( Format );
+ VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
+
+ Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ SND_TRACE(L"Setting wave device format on handle %x\n", Handle);
+
+ Result = SyncOverlappedDeviceIoControl(Handle,
+ IOCTL_WAVE_SET_FORMAT,
+ (LPVOID) Format,
+ FormatSize,
+ NULL,
+ 0,
+ NULL);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return TranslateInternalMmResult(Result);
+
+ return MMSYSERR_NOERROR;
+}
+
Propchange: branches/silverblade-audio/lib/drivers/sound/mment4/control.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mment4/detect.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mment4/detect.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mment4/detect.c [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -1,0 +1,205 @@
+/*
+ * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/sound/mment4/detect.c
+ *
+ * PURPOSE: Assists in locating Windows NT4 compatible sound devices,
+ * which mostly use the same device naming convention and/or
+ * store their created device names within their service key
+ * within the registry.
+ *
+ * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <ntddsnd.h>
+
+#include <mmebuddy.h>
+#include <mment4.h>
+
+/*
+ This is the "nice" way to discover audio devices in NT4 - go into the
+ service registry key and enumerate the Parameters\Device*\Devices
+ values. The value names represent the device name, whereas the data
+ assigned to them identifies the type of device.
+*/
+MMRESULT
+EnumerateNt4ServiceSoundDevices(
+ IN LPWSTR ServiceName,
+ IN MMDEVICE_TYPE DeviceType,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+{
+ HKEY Key;
+ DWORD KeyIndex = 0;
+
+ VALIDATE_MMSYS_PARAMETER( ServiceName );
+
+ /* Device type zero means "all" */
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) ||
+ DeviceType == 0 );
+
+ while ( OpenSoundDeviceRegKey(ServiceName, KeyIndex, &Key) == MMSYSERR_NOERROR )
+ {
+ HKEY DevicesKey;
+ DWORD ValueType = REG_NONE, ValueIndex = 0;
+ DWORD MaxNameLength = 0, ValueNameLength = 0;
+ PWSTR DevicePath = NULL, ValueName = NULL;
+ DWORD ValueDataLength = sizeof(DWORD);
+ DWORD ValueData;
+
+ if ( RegOpenKeyEx(Key,
+ REG_DEVICES_KEY_NAME_U,
+ 0,
+ KEY_READ,
+ &DevicesKey) == ERROR_SUCCESS )
+ {
+ /* Find out how much memory is needed for the key name */
+ if ( RegQueryInfoKey(DevicesKey,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &MaxNameLength,
+ NULL, NULL, NULL) != ERROR_SUCCESS )
+ {
+ SND_ERR(L"Failed to query registry key information\n");
+ RegCloseKey(DevicesKey);
+ RegCloseKey(Key);
+
+ return MMSYSERR_ERROR;
+ }
+
+ DevicePath = AllocateWideString(MaxNameLength +
+ strlen("\\\\.\\"));
+
+ /* Check that the memory allocation was successful */
+ if ( ! DevicePath )
+ {
+ /* There's no point in going further */
+ RegCloseKey(DevicesKey);
+ RegCloseKey(Key);
+
+ return MMSYSERR_NOMEM;
+ }
+
+ /* Insert the device path prefix */
+ wsprintf(DevicePath, L"\\\\.\\");
+
+ /* The offset of the string following this prefix */
+ ValueName = DevicePath + strlen("\\\\.\\");
+
+ /* Copy this so that it may be overwritten - include NULL */
+ ValueNameLength = MaxNameLength + sizeof(WCHAR);
+
+ SND_TRACE(L"Interested in devices beginning with %wS\n",
DevicePath);
+
+ while ( RegEnumValue(DevicesKey,
+ ValueIndex,
+ ValueName,
+ &ValueNameLength,
+ NULL,
+ &ValueType,
+ (LPBYTE) &ValueData,
+ &ValueDataLength) == ERROR_SUCCESS )
+ {
+ /* Device types are stored as DWORDs */
+ if ( ( ValueType == REG_DWORD ) &&
+ ( ValueDataLength == sizeof(DWORD) ) )
+ {
+ if ( ( DeviceType == 0 ) ||
+ ( DeviceType == ValueData ) )
+ {
+ SND_TRACE(L"Found device: %wS\n", DevicePath);
+ SoundDeviceDetectedProc(ValueData, DevicePath);
+ }
+ }
+
+ /* Reset variables for the next iteration */
+ ValueNameLength = MaxNameLength + sizeof(WCHAR);
+ ZeroMemory(ValueName, (MaxNameLength+1)*sizeof(WCHAR));
+ /*ZeroWideString(ValueName);*/
+ ValueDataLength = sizeof(DWORD);
+ ValueData = 0;
+ ValueType = REG_NONE;
+
+ ++ ValueIndex;
+ }
+
+ FreeMemory(DevicePath);
+
+ RegCloseKey(DevicesKey);
+ }
+ else
+ {
+ SND_WARN(L"Unable to open the Devices key!\n");
+ }
+
+ ++ KeyIndex;
+
+ RegCloseKey(Key);
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+/*
+ Brute-force device detection, using a base device name (eg: \\.\WaveOut).
+
+ This will add the device number as a suffix to the end of the string and
+ attempt to open the device based on that name. On success, it will
+ increment the device number and repeat this process.
+
+ When it runs out of devices, it will give up.
+*/
+MMRESULT
+DetectNt4SoundDevices(
+ IN MMDEVICE_TYPE DeviceType,
+ IN PWSTR BaseDeviceName,
+ IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+{
+ ULONG DeviceNameLength = 0;
+ PWSTR DeviceName = NULL;
+ ULONG Index = 0;
+ HANDLE DeviceHandle;
+ BOOLEAN DoSearch = TRUE;
+
+ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) );
+
+ DeviceNameLength = wcslen(BaseDeviceName);
+ /* Consider the length of the number */
+ DeviceNameLength += GetDigitCount(Index);
+
+ DeviceName = AllocateWideString(DeviceNameLength);
+
+ if ( ! DeviceName )
+ {
+ return MMSYSERR_NOMEM;
+ }
+
+ while ( DoSearch )
+ {
+ /* Nothing like a nice clean device name */
+ ZeroWideString(DeviceName);
+ wsprintf(DeviceName, L"%ls%d", BaseDeviceName, Index);
+
+ if ( OpenKernelSoundDeviceByName(DeviceName,
+ TRUE,
+ &DeviceHandle) == MMSYSERR_NOERROR )
+ {
+ /* Notify the callback function */
+ SND_TRACE(L"Found device: %wS\n", DeviceName);
+ SoundDeviceDetectedProc(DeviceType, DeviceName);
+
+ CloseHandle(DeviceHandle);
+
+ ++ Index;
+ }
+ else
+ {
+ DoSearch = FALSE;
+ }
+ }
+
+ FreeMemory(DeviceName);
+
+ return MMSYSERR_NOERROR;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mment4/detect.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mment4/mment4.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mment4/mment4.rbuild (added)
+++ branches/silverblade-audio/lib/drivers/sound/mment4/mment4.rbuild [iso-8859-1] Fri Jan
2 18:36:19 2009
@@ -1,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
+<module name="mment4" type="staticlibrary"
allowwarnings="false" unicode="yes">
+ <include base="ReactOS">include/reactos/libs/sound</include>
+ <define name="DEBUG_NT4">1</define>
+ <file>detect.c</file>
+ <file>registry.c</file>
+ <file>control.c</file>
+</module>
Propchange: branches/silverblade-audio/lib/drivers/sound/mment4/mment4.rbuild
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mment4/registry.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mment4/registry.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mment4/registry.c [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -1,0 +1,137 @@
+/*
+ * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: lib/sound/mment4/registry.c
+ *
+ * PURPOSE: Registry operation helper for audio device drivers.
+ *
+ * PROGRAMMERS: Andrew Greenwood (silverblade(a)reactos.org)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <ntddsnd.h>
+
+#include <mmebuddy.h>
+#include <mment4.h>
+
+/*
+ Open the parameters key of a sound driver.
+ NT4 only.
+*/
+MMRESULT
+OpenSoundDriverParametersRegKey(
+ IN LPWSTR ServiceName,
+ OUT PHKEY KeyHandle)
+{
+ ULONG KeyLength;
+ PWCHAR ParametersKeyName;
+
+ VALIDATE_MMSYS_PARAMETER( ServiceName );
+ VALIDATE_MMSYS_PARAMETER( KeyHandle );
+
+ /* Work out how long the string will be */
+ KeyLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
+ + wcslen(ServiceName) + 1
+ + wcslen(REG_PARAMETERS_KEY_NAME_U);
+
+ /* Allocate memory for the string */
+ ParametersKeyName = AllocateWideString(KeyLength);
+
+ if ( ! ParametersKeyName )
+ return MMSYSERR_NOMEM;
+
+ /* Construct the registry path */
+ wsprintf(ParametersKeyName,
+ L"%s\\%s\\%s",
+ REG_SERVICES_KEY_NAME_U,
+ ServiceName,
+ REG_PARAMETERS_KEY_NAME_U);
+
+ SND_TRACE(L"Opening reg key: %wS\n", ParametersKeyName);
+
+ /* Perform the open */
+ if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ ParametersKeyName,
+ 0,
+ KEY_READ,
+ KeyHandle) != ERROR_SUCCESS )
+ {
+ /* Couldn't open the key */
+ SND_ERR(L"Failed to open reg key: %wS\n", ParametersKeyName);
+ FreeMemory(ParametersKeyName);
+ return MMSYSERR_ERROR;
+ }
+
+ FreeMemory(ParametersKeyName);
+
+ return MMSYSERR_NOERROR;
+}
+
+/*
+ Open one of the Device sub-keys belonging to the sound driver.
+ NT4 only.
+*/
+MMRESULT
+OpenSoundDeviceRegKey(
+ IN LPWSTR ServiceName,
+ IN DWORD DeviceIndex,
+ OUT PHKEY KeyHandle)
+{
+ DWORD PathLength;
+ PWCHAR RegPath;
+
+ VALIDATE_MMSYS_PARAMETER( ServiceName );
+ VALIDATE_MMSYS_PARAMETER( KeyHandle );
+
+ /*
+ Work out the space required to hold the path:
+
+ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
+ sndblst\
+ Parameters\
+ Device123\
+ */
+ PathLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1
+ + wcslen(ServiceName) + 1
+ + wcslen(REG_PARAMETERS_KEY_NAME_U) + 1
+ + wcslen(REG_DEVICE_KEY_NAME_U)
+ + GetDigitCount(DeviceIndex);
+
+ /* Allocate storage for the string */
+ RegPath = AllocateWideString(PathLength);
+
+ if ( ! RegPath )
+ {
+ return MMSYSERR_NOMEM;
+ }
+
+ /* Write the path */
+ wsprintf(RegPath,
+ L"%ls\\%ls\\%ls\\%ls%d",
+ REG_SERVICES_KEY_NAME_U,
+ ServiceName,
+ REG_PARAMETERS_KEY_NAME_U,
+ REG_DEVICE_KEY_NAME_U,
+ DeviceIndex);
+
+ SND_TRACE(L"Opening reg key: %wS\n", RegPath);
+
+ /* Perform the open */
+ if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ RegPath,
+ 0,
+ KEY_READ,
+ KeyHandle) != ERROR_SUCCESS )
+ {
+ /* Couldn't open the key */
+ SND_ERR(L"Failed to open reg key: %wS\n", RegPath);
+ FreeMemory(RegPath);
+ return MMSYSERR_ERROR;
+ }
+
+ FreeMemory(RegPath);
+
+ return MMSYSERR_NOERROR;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mment4/registry.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/silverblade-audio/lib/drivers/sound/sound.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/sound.rbuild [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/sound.rbuild [iso-8859-1] Fri Jan 2
18:36:19 2009
@@ -16,4 +16,7 @@
<directory name="mmebuddy">
<xi:include href="mmebuddy/mmebuddy.rbuild" />
</directory>
+ <directory name="mment4">
+ <xi:include href="mment4/mment4.rbuild" />
+ </directory>
</group>