Author: silverblade
Date: Fri Jul 4 21:43:17 2008
New Revision: 34299
URL:
http://svn.reactos.org/svn/reactos?rev=34299&view=rev
Log:
mmdrv.dll reimplementation begins, with a majority of its functionality
shifted into a support library ("mmebuddy") for future reuse with sndblst
and likely the WDM audio system. Locating NT4 sound devices is possible by
2 methods (search devices belonging to specific service, and brute-force search).
Some of the code is very hacky and for testing this compiles as an EXE.
No doubt a few bugs are present, however at the moment I'm satisfied (by testing)
that the code is doing what it is supposed to do.
Added:
branches/silverblade-audio/dll/win32/mmdrv/entry.c (with props)
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/midi/
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/aux.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/entry.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mid.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mod.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mxd.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wid.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wod.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c (with props)
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/
branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c (with
props)
Modified:
branches/silverblade-audio/dll/win32/mmdrv/mmdrv.def
branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild
branches/silverblade-audio/drivers/multimedia/audio/sb16_nt4/main.c
branches/silverblade-audio/include/ddk/ntddsnd.h
branches/silverblade-audio/lib/drivers/sound/legacy/devname.c
branches/silverblade-audio/lib/drivers/sound/sound.rbuild
Added: branches/silverblade-audio/dll/win32/mmdrv/entry.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/mmd…
==============================================================================
--- branches/silverblade-audio/dll/win32/mmdrv/entry.c (added)
+++ branches/silverblade-audio/dll/win32/mmdrv/entry.c [iso-8859-1] Fri Jul 4 21:43:17
2008
@@ -1,0 +1,45 @@
+/*
+ ReactOS Sound System
+ Default MME Driver
+
+ Purpose:
+ MME driver entry-point
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmddk.h>
+#include <mmebuddy.h>
+#include <debug.h>
+
+APIENTRY LONG
+DriverProc(
+ DWORD driver_id,
+ HANDLE driver_handle,
+ UINT message,
+ LONG parameter1,
+ LONG parameter2)
+{
+ switch ( message )
+ {
+ case DRV_LOAD :
+ DPRINT("DRV_LOAD\n");
+ return 1L;
+
+ case DRV_FREE :
+ DPRINT("DRV_FREE\n");
+ return 1L;
+
+ default :
+ return DefaultDriverProc(driver_id,
+ driver_handle,
+ message,
+ parameter1,
+ parameter2);
+ }
+}
Propchange: branches/silverblade-audio/dll/win32/mmdrv/entry.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/silverblade-audio/dll/win32/mmdrv/mmdrv.def
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/mmd…
==============================================================================
--- branches/silverblade-audio/dll/win32/mmdrv/mmdrv.def [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/mmdrv/mmdrv.def [iso-8859-1] Fri Jul 4 21:43:17
2008
@@ -11,4 +11,13 @@
;wodMessage@20
;midMessage@20
;modMessage@20
+;mxdMessage@20
;auxMessage@20
+;
+; These entries are here for testing purposes only!!!!
+; See testing.c
+;
+Test@0
+TestGetCaps@0
+TestDevEnum@0
+TestThreading@0
Modified: branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/dll/win32/mmd…
==============================================================================
--- branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild [iso-8859-1] (original)
+++ branches/silverblade-audio/dll/win32/mmdrv/mmdrv.rbuild [iso-8859-1] Fri Jul 4
21:43:17 2008
@@ -1,9 +1,14 @@
-<module name="mmdrv" type="win32dll"
baseaddress="${BASEADDRESS_MMDRV}" installbase="system32"
installname="mmdrv.dll" unicode="yes">
- <importlibrary definition="mmdrv.def" />
+<!--module name="mmdrv" type="win32dll"
baseaddress="${BASEADDRESS_MMDRV}" installbase="system32"
installname="mmdrv.dll" unicode="yes"-->
+<module name="mmdrv" type="win32cui"
installbase="system32" installname="mmdrv.exe"
unicode="yes">
+ <!--importlibrary definition="mmdrv.def" /-->
+ <include base="ReactOS">include/reactos/libs/sound</include>
<include base="mmdrv">.</include>
- <define name="NDEBUG" />
+ <!--define name="NDEBUG" /-->
+ <library>mmebuddy</library>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>winmm</library>
+ <library>advapi32</library>
+ <file>entry.c</file>
</module>
Modified: branches/silverblade-audio/drivers/multimedia/audio/sb16_nt4/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/drivers/multi…
==============================================================================
--- branches/silverblade-audio/drivers/multimedia/audio/sb16_nt4/main.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/drivers/multimedia/audio/sb16_nt4/main.c [iso-8859-1] Fri
Jul 4 21:43:17 2008
@@ -123,7 +123,7 @@
NTSTATUS result;
DbgPrint("Creating sound device\n");
- result = CreateSoundDeviceWithDefaultName(DriverObject, 0, 69, 0, &g_device);
+ result = CreateSoundDeviceWithDefaultName(DriverObject, WAVE_OUT_DEVICE_TYPE, 0, 0,
&g_device);
DbgPrint("Request returned status 0x%08x\n",
result);
Modified: branches/silverblade-audio/include/ddk/ntddsnd.h
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/include/ddk/n…
==============================================================================
--- branches/silverblade-audio/include/ddk/ntddsnd.h [iso-8859-1] (original)
+++ branches/silverblade-audio/include/ddk/ntddsnd.h [iso-8859-1] Fri Jul 4 21:43:17
2008
@@ -29,16 +29,24 @@
/*
Device types
- (not part of the original DDK header)
-*/
-
-#define WAVE_IN_DEVICE_TYPE 0
-#define WAVE_OUT_DEVICE_TYPE 1
-#define MIDI_IN_DEVICE_TYPE 2
-#define MIDI_OUT_DEVICE_TYPE 3
-#define MIXER_DEVICE_TYPE 4
+
+ Not part of the original DDK header, but based on the values stored in
+ registry by sndblst
+*/
+
+#define WAVE_IN_DEVICE_TYPE 1
+#define WAVE_OUT_DEVICE_TYPE 2
+#define MIDI_IN_DEVICE_TYPE 3
+#define MIDI_OUT_DEVICE_TYPE 4
#define AUX_DEVICE_TYPE 5
-#define MAX_DEVICE_TYPE AUX_DEVICE_TYPE
+#define MIXER_DEVICE_TYPE 6
+
+#define MIN_SOUND_DEVICE_TYPE WAVE_IN_DEVICE_TYPE
+#define MAX_SOUND_DEVICE_TYPE MIXER_DEVICE_TYPE
+#define SOUND_DEVICE_TYPES 6
+
+#define VALID_SOUND_DEVICE_TYPE(x) \
+ ( ( x >= MIN_SOUND_DEVICE_TYPE ) && ( x <= MAX_SOUND_DEVICE_TYPE ) )
/*
@@ -53,35 +61,57 @@
#define SOUND_MAX_DEVICE_NAME 80
-#define DD_WAVE_IN_DEVICE_NAME "\\Device\\WaveIn"
-#define DD_WAVE_IN_DEVICE_NAME_U L"\\Device\\WaveIn"
-#define DD_WAVE_IN_DOS_DEVICE_NAME "\\DosDevices\\WaveIn"
-#define DD_WAVE_IN_DOS_DEVICE_NAME_U L"\\DosDevices\\WaveIn"
-
-#define DD_WAVE_OUT_DEVICE_NAME "\\Device\\WaveOut"
-#define DD_WAVE_OUT_DEVICE_NAME_U L"\\Device\\WaveOut"
-#define DD_WAVE_OUT_DOS_DEVICE_NAME "\\DosDevices\\WaveOut"
-#define DD_WAVE_OUT_DOS_DEVICE_NAME_U L"\\DosDevices\\WaveOut"
-
-#define DD_MIDI_IN_DEVICE_NAME "\\Device\\MidiIn"
-#define DD_MIDI_IN_DEVICE_NAME_U L"\\Device\\MidiIn"
-#define DD_MIDI_IN_DOS_DEVICE_NAME "\\DosDevices\\MidiIn"
-#define DD_MIDI_IN_DOS_DEVICE_NAME_U L"\\DosDevices\\MidiIn"
-
-#define DD_MIDI_OUT_DEVICE_NAME "\\Device\\MidiOut"
-#define DD_MIDI_OUT_DEVICE_NAME_U L"\\Device\\MidiOut"
-#define DD_MIDI_OUT_DOS_DEVICE_NAME "\\DosDevices\\MidiOut"
-#define DD_MIDI_OUT_DOS_DEVICE_NAME_U L"\\DosDevices\\MidiOut"
-
-#define DD_MIX_DEVICE_NAME "\\Device\\MMMix"
-#define DD_MIX_DEVICE_NAME_U L"\\Device\\MMMix"
-#define DD_MIX_DOS_DEVICE_NAME "\\DosDevices\\MMMix"
-#define DD_MIX_DOS_DEVICE_NAME_U L"\\DosDevices\\MMMix"
-
-#define DD_AUX_DEVICE_NAME "\\Device\\MMAux"
-#define DD_AUX_DEVICE_NAME_U L"\\Device\\MMAux"
-#define DD_AUX_DOS_DEVICE_NAME "\\DosDevices\\MMAux"
-#define DD_AUX_DOS_DEVICE_NAME_U L"\\DosDevices\\MMAux"
+#define DD_WAVE_IN_DEVICE_NAME "\\Device\\WaveIn"
+#define DD_WAVE_IN_DEVICE_NAME_U L"\\Device\\WaveIn"
+#define DD_WAVE_IN_DOS_DEVICE_NAME "\\DosDevices\\WaveIn"
+#define DD_WAVE_IN_DOS_DEVICE_NAME_U L"\\DosDevices\\WaveIn"
+#define DD_WAVE_IN_WIN32_DEVICE_NAME "\\\\.\\WaveIn"
+#define DD_WAVE_IN_WIN32_DEVICE_NAME_U L"\\\\.\\WaveIn"
+
+#define DD_WAVE_OUT_DEVICE_NAME "\\Device\\WaveOut"
+#define DD_WAVE_OUT_DEVICE_NAME_U L"\\Device\\WaveOut"
+#define DD_WAVE_OUT_DOS_DEVICE_NAME "\\DosDevices\\WaveOut"
+#define DD_WAVE_OUT_DOS_DEVICE_NAME_U L"\\DosDevices\\WaveOut"
+#define DD_WAVE_OUT_WIN32_DEVICE_NAME "\\\\.\\WaveOut"
+#define DD_WAVE_OUT_WIN32_DEVICE_NAME_U L"\\\\.\\WaveOut"
+
+#define DD_MIDI_IN_DEVICE_NAME "\\Device\\MidiIn"
+#define DD_MIDI_IN_DEVICE_NAME_U L"\\Device\\MidiIn"
+#define DD_MIDI_IN_DOS_DEVICE_NAME "\\DosDevices\\MidiIn"
+#define DD_MIDI_IN_DOS_DEVICE_NAME_U L"\\DosDevices\\MidiIn"
+#define DD_MIDI_IN_WIN32_DEVICE_NAME "\\\\.\\MidiIn"
+#define DD_MIDI_IN_WIN32_DEVICE_NAME_U L"\\\\.\\MidiIn"
+
+#define DD_MIDI_OUT_DEVICE_NAME "\\Device\\MidiOut"
+#define DD_MIDI_OUT_DEVICE_NAME_U L"\\Device\\MidiOut"
+#define DD_MIDI_OUT_DOS_DEVICE_NAME "\\DosDevices\\MidiOut"
+#define DD_MIDI_OUT_DOS_DEVICE_NAME_U L"\\DosDevices\\MidiOut"
+#define DD_MIDI_OUT_WIN32_DEVICE_NAME "\\\\.\\MidiOut"
+#define DD_MIDI_OUT_WIN32_DEVICE_NAME_U L"\\\\.\\MidiOut"
+
+#define DD_MIX_DEVICE_NAME "\\Device\\MMMix"
+#define DD_MIX_DEVICE_NAME_U L"\\Device\\MMMix"
+#define DD_MIX_DOS_DEVICE_NAME "\\DosDevices\\MMMix"
+#define DD_MIX_DOS_DEVICE_NAME_U L"\\DosDevices\\MMMix"
+#define DD_MIX_WIN32_DEVICE_NAME "\\\\.\\MMMix"
+#define DD_MIX_WIN32_DEVICE_NAME_U L"\\\\.\\MMMix"
+
+#define DD_AUX_DEVICE_NAME "\\Device\\MMAux"
+#define DD_AUX_DEVICE_NAME_U L"\\Device\\MMAux"
+#define DD_AUX_DOS_DEVICE_NAME "\\DosDevices\\MMAux"
+#define DD_AUX_DOS_DEVICE_NAME_U L"\\DosDevices\\MMAux"
+#define DD_AUX_WIN32_DEVICE_NAME "\\\\.\\MMAux"
+#define DD_AUX_WIN32_DEVICE_NAME_U L"\\\\.\\MMAux"
+
+/*
+ Registry keys
+*/
+
+#define REG_SERVICES_KEY_NAME_U
L"System\\CurrentControlSet\\Services"
+#define REG_PARAMETERS_KEY_NAME_U L"Parameters"
+#define REG_DEVICE_KEY_NAME_U L"Device"
+#define REG_DEVICES_KEY_NAME_U L"Devices"
+
/*
Base control codes
Added: 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 (added)
+++ branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,299 @@
+/*
+ ReactOS Sound System
+ MME Support Helper
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+
+ Notes:
+ MME Buddy was the best name I could come up with...
+*/
+
+#ifndef ROS_AUDIO_MMEBUDDY_H
+#define ROS_AUDIO_MMEBUDDY_H
+
+struct _SOUND_DEVICE;
+struct _SOUND_DEVICE_INSTANCE;
+
+
+/*
+ Rather than pass caps structures around as a PVOID, this can be
+ used instead.
+*/
+
+typedef union _UNIVERSAL_CAPS
+{
+ WAVEOUTCAPS WaveOut;
+ WAVEINCAPS WaveIn;
+ MIDIOUTCAPS MidiOut;
+ MIDIINCAPS MidiIn;
+} UNIVERSAL_CAPS, *PUNIVERSAL_CAPS;
+
+
+/*
+ Thread helper operations
+*/
+
+typedef MMRESULT (*SOUND_THREAD_OPERATION)(
+ IN struct _SOUND_DEVICE_INSTANCE* Instance,
+ IN PVOID Data);
+
+typedef struct _THREAD_OPERATIONS
+{
+ struct _THREAD_OPERATIONS* Next;
+ DWORD Id;
+ SOUND_THREAD_OPERATION Operation;
+} THREAD_OPERATIONS, *PTHREAD_OPERATIONS;
+
+typedef struct _SOUND_THREAD
+{
+ HANDLE Handle;
+ BOOLEAN Running;
+ PTHREAD_OPERATIONS FirstOperation;
+ HANDLE KillEvent;
+ HANDLE RequestEvent;
+ HANDLE RequestCompletionEvent;
+} SOUND_THREAD, *PSOUND_THREAD;
+
+
+/*
+ Audio device function table
+*/
+
+typedef MMRESULT (*MMOPEN_FUNC)(
+ IN UCHAR DeviceType,
+ IN LPWSTR DevicePath,
+ OUT PHANDLE Handle);
+
+typedef MMRESULT (*MMCLOSE_FUNC)(
+ IN HANDLE Handle);
+
+typedef MMRESULT (*MMGETCAPS_FUNC)(
+ IN struct _SOUND_DEVICE* SoundDevice,
+ OUT PUNIVERSAL_CAPS Capabilities);
+
+typedef struct _MMFUNCTION_TABLE
+{
+ MMOPEN_FUNC Open;
+ MMCLOSE_FUNC Close;
+ MMGETCAPS_FUNC GetCapabilities;
+} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
+
+
+/*
+ Represents an audio device
+*/
+
+typedef struct _SOUND_DEVICE
+{
+ struct _SOUND_DEVICE* Next;
+ struct _SOUND_DEVICE_INSTANCE* FirstInstance;
+ UCHAR DeviceType;
+ LPWSTR DevicePath;
+ HANDLE Handle;
+ MMFUNCTION_TABLE Functions;
+} SOUND_DEVICE, *PSOUND_DEVICE;
+
+
+/*
+ Represents an individual instance of an audio device
+*/
+
+typedef struct _SOUND_DEVICE_INSTANCE
+{
+ struct _SOUND_DEVICE_INSTANCE* Next;
+ PSOUND_DEVICE Device;
+ PSOUND_THREAD Thread;
+} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
+
+
+/*
+ entry.c
+*/
+
+LONG
+DefaultDriverProc(
+ DWORD driver_id,
+ HANDLE driver_handle,
+ UINT message,
+ LONG parameter1,
+ LONG parameter2);
+
+
+/*
+ devices.c
+*/
+
+ULONG
+GetSoundDeviceCount(
+ UCHAR DeviceType);
+
+MMRESULT
+GetSoundDevice(
+ IN UCHAR DeviceType,
+ IN ULONG DeviceIndex,
+ OUT PSOUND_DEVICE* Device);
+
+MMRESULT
+GetSoundDevicePath(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT LPWSTR* DevicePath);
+
+VOID
+DestroyAllSoundDevices();
+
+BOOLEAN
+DestroySoundDevices(
+ UCHAR DeviceType);
+
+BOOLEAN
+CreateSoundDevice(
+ UCHAR DeviceType,
+ PWSTR DevicePath);
+
+BOOLEAN
+DestroySoundDevice(
+ UCHAR DeviceType,
+ ULONG Index);
+
+
+/*
+ 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(
+ LPWSTR ServiceName,
+ UCHAR DeviceType,
+ SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+
+MMRESULT
+DetectNt4SoundDevices(
+ UCHAR DeviceType,
+ PWSTR BaseDevicePath,
+ SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc);
+
+
+/*
+ kernel.c
+*/
+
+MMRESULT
+OpenKernelSoundDeviceByName(
+ PWSTR DeviceName,
+ DWORD AccessRights,
+ PHANDLE Handle);
+
+MMRESULT
+OpenKernelSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD AccessRights);
+
+MMRESULT
+PerformSoundDeviceIo(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID InBuffer,
+ DWORD InBufferSize,
+ LPVOID OutBuffer,
+ DWORD OutBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped);
+
+MMRESULT
+ReadSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID OutBuffer,
+ DWORD OutBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped);
+
+MMRESULT
+WriteSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID InBuffer,
+ DWORD InBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped);
+
+
+/*
+ utility.c
+*/
+
+ULONG
+GetDigitCount(
+ ULONG Number);
+
+MMRESULT
+Win32ErrorToMmResult(UINT error_code);
+
+
+/*
+ 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
+GetSoundDeviceCapabilities(
+ IN PSOUND_DEVICE Device,
+ OUT PUNIVERSAL_CAPS Capabilities);
+
+MMRESULT
+DefaultGetSoundDeviceCapabilities(
+ IN PSOUND_DEVICE Device,
+ OUT PUNIVERSAL_CAPS Capabilities);
+
+
+/*
+ thread.c
+*/
+
+MMRESULT
+StartSoundThread(
+ IN PSOUND_DEVICE_INSTANCE Instance);
+
+MMRESULT
+StopSoundThread(
+ IN PSOUND_DEVICE_INSTANCE Instance);
+
+
+#endif
Propchange: branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/silverblade-audio/lib/drivers/sound/legacy/devname.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/legacy/devname.c [iso-8859-1] (original)
+++ branches/silverblade-audio/lib/drivers/sound/legacy/devname.c [iso-8859-1] Fri Jul 4
21:43:17 2008
@@ -167,7 +167,7 @@
OUT PCWSTR* DeviceNameBody,
OUT PCWSTR* DosDeviceNameBody)
{
- if ( DeviceType > MAX_DEVICE_TYPE )
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
{
DPRINT("Invalid device type");
return STATUS_INVALID_PARAMETER;
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,325 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Device list manager
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+
+/*
+ TODO: Free up devicepath on exit
+*/
+
+#include <windows.h>
+#include <ntddsnd.h>
+#include <debug.h>
+
+#include <mmebuddy.h>
+
+/* Device Lists */
+ULONG SoundDeviceTotals[SOUND_DEVICE_TYPES];
+PSOUND_DEVICE SoundDeviceLists[SOUND_DEVICE_TYPES];
+
+
+ULONG
+GetSoundDeviceCount(
+ UCHAR DeviceType)
+{
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ {
+ return 0;
+ }
+
+ return SoundDeviceTotals[DeviceType];
+}
+
+
+MMRESULT
+GetSoundDevice(
+ IN UCHAR DeviceType,
+ IN ULONG DeviceIndex,
+ OUT PSOUND_DEVICE* Device)
+{
+ ULONG Count = 0;
+ PSOUND_DEVICE CurrentDevice = NULL;
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_INVALPARAM;
+
+ if ( DeviceIndex >= SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Device )
+ return MMSYSERR_INVALPARAM;
+
+ /*
+ We know by now that a device at the index should exist
+ so just loop around until we reach that index.
+ */
+
+ CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE];
+
+ for ( Count = 0; Count <= DeviceIndex; ++ Count )
+ {
+ *Device = CurrentDevice;
+ CurrentDevice = CurrentDevice->Next;
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+
+MMRESULT
+GetSoundDevicePath(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT LPWSTR* DevicePath)
+{
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! DevicePath )
+ return MMSYSERR_INVALPARAM;
+
+ MessageBox(0, SoundDevice->DevicePath, L"Foo", MB_TASKMODAL | MB_OK);
+ *DevicePath = SoundDevice->DevicePath;
+
+ return MMSYSERR_NOERROR;
+}
+
+
+VOID
+DestroyAllSoundDevices()
+{
+ ULONG i;
+
+ DPRINT("Emptying all device lists\n");
+
+ for ( i = 0; i < SOUND_DEVICE_TYPES; ++ i )
+ {
+ DestroySoundDevices(i);
+ }
+}
+
+
+BOOLEAN
+DestroySoundDevices(
+ UCHAR DeviceType)
+{
+ PSOUND_DEVICE CurrentDevice;
+ PSOUND_DEVICE NextDevice;
+
+ DPRINT("Emptying device list for device type %d\n", DeviceType);
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ {
+ DPRINT("Invalid device type - %d\n", DeviceType);
+ return FALSE;
+ }
+
+ /* Clean out the device list */
+ CurrentDevice = SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE];
+
+ while ( CurrentDevice )
+ {
+ /* Save the next device pointer so we can reference it later */
+ NextDevice = CurrentDevice->Next;
+
+ HeapFree(GetProcessHeap(), 0, CurrentDevice);
+ CurrentDevice = NextDevice;
+ }
+
+ /* Reset the list content and item count */
+ SoundDeviceLists[DeviceType - MIN_SOUND_DEVICE_TYPE] = NULL;
+ SoundDeviceTotals[DeviceType - MIN_SOUND_DEVICE_TYPE] = 0;
+
+ return TRUE;
+}
+
+
+VOID
+InitSoundDeviceFunctionTable(
+ IN PSOUND_DEVICE Device)
+{
+ Device->Functions.GetCapabilities = DefaultGetSoundDeviceCapabilities;
+}
+
+
+BOOLEAN
+CreateSoundDevice(
+ UCHAR DeviceType,
+ LPWSTR DevicePath)
+{
+ PSOUND_DEVICE NewDevice;
+ ULONG DevicePathSize = 0;
+ UCHAR TypeIndex;
+
+ DPRINT("Adding a sound device to list %d\n", DeviceType);
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ {
+ return FALSE;
+ }
+
+ TypeIndex = DeviceType - MIN_SOUND_DEVICE_TYPE;
+
+ NewDevice = (PSOUND_DEVICE)
+ HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SOUND_DEVICE));
+
+ if ( ! NewDevice )
+ {
+ return FALSE;
+ }
+
+ DevicePathSize = (wcslen(DevicePath) + 1) * sizeof(WCHAR);
+
+ NewDevice->Next = NULL;
+ NewDevice->FirstInstance = NULL;
+ NewDevice->DeviceType = DeviceType;
+ NewDevice->Handle = INVALID_HANDLE_VALUE;
+
+ NewDevice->DevicePath = (LPWSTR)
+ HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DevicePathSize);
+
+ if ( ! NewDevice->DevicePath )
+ {
+ HeapFree(GetProcessHeap(), 0, NewDevice);
+ return FALSE;
+ }
+
+ CopyMemory(NewDevice->DevicePath, DevicePath, DevicePathSize);
+
+ /* Set up function table */
+ InitSoundDeviceFunctionTable(NewDevice);
+
+ /* Start or add to list */
+ if ( ! SoundDeviceLists[TypeIndex] )
+ {
+ DPRINT("Starting device list\n");
+ SoundDeviceLists[TypeIndex] = NewDevice;
+ }
+ else
+ {
+ PSOUND_DEVICE CurrentDevice = SoundDeviceLists[TypeIndex];
+
+ DPRINT("Adding to device list\n");
+
+ while ( CurrentDevice != NULL )
+ {
+ if ( ! CurrentDevice->Next )
+ {
+ CurrentDevice->Next = NewDevice;
+ break;
+ }
+
+ CurrentDevice = CurrentDevice->Next;
+ }
+ }
+
+ ++ SoundDeviceTotals[TypeIndex];
+ DPRINT("Now %d devices of type %d\n", SoundDeviceTotals[TypeIndex],
DeviceType);
+
+ return TRUE;
+}
+
+
+BOOLEAN
+DestroySoundDevice(
+ UCHAR DeviceType,
+ ULONG Index)
+{
+ ULONG Counter = 0;
+ ULONG TypeIndex;
+ PSOUND_DEVICE CurrentDevice = NULL;
+ PSOUND_DEVICE PreviousDevice = NULL;
+
+ DPRINT("Removing a sound device from list %d\n", DeviceType);
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ {
+ return FALSE;
+ }
+
+ TypeIndex = DeviceType - MIN_SOUND_DEVICE_TYPE;
+
+ CurrentDevice = SoundDeviceLists[TypeIndex];
+ PreviousDevice = NULL;
+
+ while ( CurrentDevice )
+ {
+ if ( Counter == Index )
+ {
+ /* Clean up any instances */
+ if ( CurrentDevice->FirstInstance != NULL )
+ {
+ DestroyAllInstancesOfSoundDevice(CurrentDevice);
+ }
+
+ /* Close handle (if open) */
+ if ( CurrentDevice->Handle != INVALID_HANDLE_VALUE )
+ {
+ CloseHandle(CurrentDevice->Handle);
+ CurrentDevice->Handle = INVALID_HANDLE_VALUE;
+ }
+
+ if ( ! PreviousDevice )
+ {
+ /* Head of list */
+ SoundDeviceLists[TypeIndex] = CurrentDevice->Next;
+ }
+ else
+ {
+ /* Not the head of list */
+ PreviousDevice->Next = CurrentDevice->Next;
+ }
+
+ /* Free the memory associated with the device info */
+ HeapFree(GetProcessHeap(), 0, CurrentDevice);
+ CurrentDevice = NULL;
+
+ DPRINT("Removal succeeded\n");
+
+ return TRUE;
+ }
+
+ PreviousDevice = CurrentDevice;
+ ++ Counter;
+ }
+
+ DPRINT("Not found\n");
+ /* Not found */
+ return FALSE;
+}
+
+
+
+/* Should this go somewhere else? */
+
+MMRESULT
+GetSoundDeviceCapabilities(
+ PSOUND_DEVICE SoundDevice,
+ PUNIVERSAL_CAPS Capabilities)
+{
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Capabilities )
+ return MMSYSERR_INVALPARAM;
+
+ return SoundDevice->Functions.GetCapabilities(SoundDevice, Capabilities);
+}
+
+MMRESULT
+IsSoundDeviceFormatSupported(
+ IN PSOUND_DEVICE SoundDevice /* what else? */)
+{
+ /* TODO */
+ return MMSYSERR_NOTSUPPORTED;
+}
+
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,145 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Device instance manager
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <ntddsnd.h>
+#include <debug.h>
+
+#include <mmebuddy.h>
+
+/*
+ Instances
+*/
+
+MMRESULT
+CreateSoundDeviceInstance(
+ IN PSOUND_DEVICE SoundDevice,
+ OUT PSOUND_DEVICE_INSTANCE* Instance)
+{
+ PSOUND_DEVICE_INSTANCE NewInstance = NULL;
+ PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Instance )
+ return MMSYSERR_INVALPARAM;
+
+ 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;
+
+ /* Search for an appropriate place in the list to put this instance */
+ CurrentInstance = SoundDevice->FirstInstance;
+
+ if ( ! CurrentInstance )
+ {
+ /* This is going to be the first instance */
+ SoundDevice->FirstInstance = CurrentInstance;
+ }
+ else
+ {
+ /* There is already one or more instances */
+ while ( CurrentInstance )
+ {
+ if ( ! CurrentInstance->Next )
+ {
+ /* Add to the end and get outta here */
+ CurrentInstance->Next = NewInstance;
+ 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 */
+ SoundDevice->FirstInstance = NULL;
+ }
+ else
+ {
+ /* Deleting 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 )
+ {
+ CurrentInstance = CurrentInstance->Next;
+ ASSERT(CurrentInstance);
+ }
+
+ /* This is actually the one before the one we want to remove */
+ CurrentInstance->Next = Instance->Next;
+ }
+
+ /* Kill it! */
+ HeapFree(GetProcessHeap(), 0, Instance);
+
+ return MMSYSERR_NOTSUPPORTED;
+}
+
+MMRESULT
+DestroyAllInstancesOfSoundDevice(
+ IN PSOUND_DEVICE SoundDevice)
+{
+ PSOUND_DEVICE_INSTANCE CurrentInstance = NULL;
+ PSOUND_DEVICE_INSTANCE NextInstance = NULL;
+ MMRESULT Result;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ CurrentInstance = SoundDevice->FirstInstance;
+
+ while ( CurrentInstance )
+ {
+ NextInstance = CurrentInstance->Next;
+
+ Result = DestroySoundDeviceInstance(CurrentInstance);
+ ASSERT(Result == MMSYSERR_NOERROR);
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/instances.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c [iso-8859-1] Fri Jul 4
21:43:17 2008
@@ -1,0 +1,181 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Kernel device I/O
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <ntddsnd.h>
+#include <debug.h>
+
+#include <mmebuddy.h>
+
+
+MMRESULT
+OpenKernelSoundDeviceByName(
+ PWSTR DeviceName,
+ DWORD AccessRights,
+ PHANDLE Handle)
+{
+ DWORD OpenFlags = 0;
+
+ if ( ! Handle )
+ {
+ return MMSYSERR_INVALPARAM;
+ }
+
+ if ( ! DeviceName )
+ {
+ return MMSYSERR_INVALPARAM;
+ }
+
+ if ( AccessRights != GENERIC_READ )
+ {
+ OpenFlags = FILE_FLAG_OVERLAPPED;
+ }
+
+ DPRINT("Attempting to open '%ws'\n", DeviceName);
+ MessageBox(0, DeviceName, L"Attempting to open", MB_OK | MB_TASKMODAL);
+
+ *Handle = CreateFile(DeviceName,
+ AccessRights,
+ FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ OpenFlags,
+ NULL);
+
+ if ( *Handle == INVALID_HANDLE_VALUE )
+ {
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+OpenKernelSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD AccessRights)
+{
+ MMRESULT Result;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ Result = OpenKernelSoundDeviceByName(SoundDevice->DevicePath,
+ AccessRights,
+ &SoundDevice->Handle);
+
+ return Result;
+}
+
+MMRESULT
+PerformSoundDeviceIo(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID InBuffer,
+ DWORD InBufferSize,
+ LPVOID OutBuffer,
+ DWORD OutBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped)
+{
+ BOOLEAN TemporaryOpen = FALSE;
+ BOOLEAN IoResult = FALSE;
+ DWORD AccessRights = GENERIC_READ;
+ MMRESULT Result;
+
+ if ( ! SoundDevice )
+ return MMSYSERR_INVALPARAM;
+
+ /* Determine if we actually need to write stuff */
+ if ( InBuffer != NULL )
+ AccessRights |= GENERIC_WRITE;
+
+ /* Open the device temporarily,if it's not open */
+ TemporaryOpen = (SoundDevice->Handle == INVALID_HANDLE_VALUE);
+
+ if ( TemporaryOpen )
+ {
+ MessageBox(0, L"Opening sound device", L"Info", MB_OK |
MB_TASKMODAL);
+
+ Result = OpenKernelSoundDevice(SoundDevice, AccessRights);
+
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+ }
+
+ MessageBox(0, L"Doing IO", L"Info", MB_OK | MB_TASKMODAL);
+ IoResult = DeviceIoControl(
+ SoundDevice->Handle,
+ IoControlCode,
+ InBuffer,
+ InBufferSize,
+ OutBuffer,
+ OutBufferSize,
+ BytesReturned,
+ Overlapped);
+
+ if ( ! IoResult )
+ {
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ /* If we opened the device, we must close it here */
+ if ( TemporaryOpen )
+ {
+ MessageBox(0, L"Closing sound device", L"Info", MB_OK |
MB_TASKMODAL);
+ CloseHandle(SoundDevice->Handle);
+ SoundDevice->Handle = INVALID_HANDLE_VALUE;
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+ReadSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID OutBuffer,
+ DWORD OutBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped)
+{
+ return PerformSoundDeviceIo(SoundDevice,
+ IoControlCode,
+ NULL,
+ 0,
+ OutBuffer,
+ OutBufferSize,
+ BytesReturned,
+ Overlapped);
+}
+
+MMRESULT
+WriteSoundDevice(
+ PSOUND_DEVICE SoundDevice,
+ DWORD IoControlCode,
+ LPVOID InBuffer,
+ DWORD InBufferSize,
+ LPDWORD BytesReturned,
+ LPOVERLAPPED Overlapped)
+{
+ return PerformSoundDeviceIo(SoundDevice,
+ IoControlCode,
+ InBuffer,
+ InBufferSize,
+ NULL,
+ 0,
+ BytesReturned,
+ Overlapped);
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/kernel.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/aux.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/aux.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/aux.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,31 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ Auxiliary device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+
+APIENTRY DWORD
+auxMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ DPRINT("auxMessageStub called\n");
+ /* TODO */
+ return MMSYSERR_NOTSUPPORTED;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/aux.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/entry.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/entry.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/entry.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,77 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ Default DriverProc implementation
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmddk.h>
+#include <ntddsnd.h>
+#include <debug.h>
+
+LONG
+DefaultDriverProc(
+ DWORD driver_id,
+ HANDLE driver_handle,
+ UINT message,
+ LONG parameter1,
+ LONG parameter2)
+{
+ switch ( message )
+ {
+ case DRV_LOAD :
+ DPRINT("DRV_LOAD\n");
+ return 1L;
+
+ case DRV_FREE :
+ DPRINT("DRV_FREE\n");
+ return 1L;
+
+ case DRV_OPEN :
+ DPRINT("DRV_OPEN\n");
+ return 1L;
+
+ case DRV_CLOSE :
+ DPRINT("DRV_CLOSE\n");
+ return 1L;
+
+ case DRV_ENABLE :
+ DPRINT("DRV_ENABLE\n");
+ return 1L;
+
+ case DRV_DISABLE :
+ DPRINT("DRV_DISABLE\n");
+ return 1L;
+
+ /*
+ We don't provide configuration capabilities. This used to be
+ for things like I/O port, IRQ, DMA settings, etc.
+ */
+
+ case DRV_QUERYCONFIGURE :
+ DPRINT("DRV_QUERYCONFIGURE\n");
+ return 0L;
+
+ case DRV_CONFIGURE :
+ DPRINT("DRV_CONFIGURE\n");
+ return 0L;
+
+ case DRV_INSTALL :
+ DPRINT("DRV_INSTALL\n");
+ return DRVCNF_RESTART;
+ };
+
+ return DefDriverProc(driver_id,
+ driver_handle,
+ message,
+ parameter1,
+ parameter2);
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/entry.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mid.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mid.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mid.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,49 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ MIDI Input device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+
+APIENTRY DWORD
+midMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ DPRINT("midMessageStub called\n");
+
+ switch ( message )
+ {
+ case MIDM_GETNUMDEVS :
+ return 0;
+
+ case MIDM_GETDEVCAPS :
+ case MIDM_OPEN :
+ return MMSYSERR_BADDEVICEID;
+
+ case MIDM_CLOSE :
+ case MIDM_ADDBUFFER :
+ case MIDM_START :
+ case MIDM_STOP :
+ case MIDM_RESET :
+ return MMSYSERR_INVALHANDLE;
+
+ default :
+ return MMSYSERR_NOTSUPPORTED;
+ }
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mid.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mod.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mod.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mod.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,48 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ MIDI Output device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+
+APIENTRY DWORD
+modMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ DPRINT("modMessageStub called\n");
+
+ switch ( message )
+ {
+ case MODM_GETNUMDEVS :
+ return 0;
+
+ case MODM_GETDEVCAPS :
+ case MODM_OPEN :
+ return MMSYSERR_BADDEVICEID;
+
+ case MODM_CLOSE :
+ case MODM_DATA :
+ case MODM_LONGDATA :
+ case MODM_RESET :
+ return MMSYSERR_INVALHANDLE;
+
+ default :
+ return MMSYSERR_NOTSUPPORTED;
+ }
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mod.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mxd.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mxd.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mxd.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,31 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ Mixer device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+
+APIENTRY DWORD
+mxdMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ DPRINT("mxdMessageStub called\n");
+ /* TODO */
+ return MMSYSERR_NOTSUPPORTED;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/mxd.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wid.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wid.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wid.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,50 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ Wave input device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+#include <ntddsnd.h>
+
+#include <mmebuddy.h>
+
+APIENTRY DWORD
+widMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ DPRINT("widMessageStub called\n");
+
+ switch ( message )
+ {
+ case WIDM_GETNUMDEVS :
+ return GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE);
+
+ case WIDM_GETDEVCAPS :
+ case WIDM_OPEN :
+ return MMSYSERR_BADDEVICEID;
+
+ case WIDM_CLOSE :
+ case WIDM_START :
+ case WIDM_RESET :
+ return MMSYSERR_INVALHANDLE;
+
+ default :
+ return MMSYSERR_NOTSUPPORTED;
+ }
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wid.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wod.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wod.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wod.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,81 @@
+/*
+ ReactOS Sound System
+ MME Interface
+
+ Purpose:
+ Wave output device message handler
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <mmddk.h>
+#include <debug.h>
+
+#include <ntddsnd.h>
+#include <mmebuddy.h>
+
+APIENTRY DWORD
+wodMessage(
+ DWORD device_id,
+ DWORD message,
+ DWORD private_handle,
+ DWORD parameter1,
+ DWORD parameter2)
+{
+ MMRESULT Result = MMSYSERR_NOERROR;
+ PSOUND_DEVICE Device = NULL;
+ DPRINT("wodMessageStub called\n");
+
+ switch ( message )
+ {
+ case WODM_GETNUMDEVS :
+ return GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
+
+ case WODM_GETDEVCAPS :
+ {
+ UNIVERSAL_CAPS Capabilities;
+
+ Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, device_id, &Device);
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ Result = GetSoundDeviceCapabilities(Device, &Capabilities);
+ if ( Result != MMSYSERR_NOERROR )
+ return Result;
+
+ CopyMemory((LPWAVEOUTCAPS)parameter1, &Capabilities.WaveOut,
parameter2);
+
+ return Result;
+ }
+
+ case WODM_OPEN :
+ /*
+ OpenSoundDevice();
+ */
+ return MMSYSERR_BADDEVICEID;
+
+ case WODM_CLOSE :
+ /* CloseSoundDevice() */
+
+ case WODM_WRITE :
+ case WODM_PAUSE :
+ case WODM_RESTART :
+ case WODM_RESET :
+ case WODM_BREAKLOOP :
+ return MMSYSERR_INVALHANDLE;
+
+ /* Let WINMM take care of these */
+ case WODM_PREPARE :
+ case WODM_UNPREPARE :
+ return MMSYSERR_NOTSUPPORTED;
+
+ default :
+ return MMSYSERR_NOTSUPPORTED;
+ }
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mme/wod.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild [iso-8859-1] Fri
Jul 4 21:43:17 2008
@@ -1,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
+<module name="mmebuddy" type="staticlibrary"
allowwarnings="false" unicode="yes">
+ <include base="ReactOS">include/reactos/libs/sound</include>
+ <file>devices.c</file>
+ <file>instances.c</file>
+ <file>kernel.c</file>
+ <file>nt4.c</file>
+ <file>utility.c</file>
+ <file>thread.c</file>
+ <file>testing.c</file>
+ <directory name="mme">
+ <file>entry.c</file>
+ <file>wod.c</file>
+ <file>wid.c</file>
+ <file>mod.c</file>
+ <file>mid.c</file>
+ <file>mxd.c</file>
+ <file>aux.c</file>
+ </directory>
+ <directory name="wave">
+ <file>wavethread.c</file>
+ </directory>
+ <directory name="midi">
+ </directory>
+</module>
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/mmebuddy.rbuild
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c [iso-8859-1] Fri Jul 4
21:43:17 2008
@@ -1,0 +1,429 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Legacy (NT4) sound device support
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+/*
+ A better way of detecting sound devices...
+ Search the appropriate registry key!
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <ntddsnd.h>
+#include <debug.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;
+
+ if ( ! ServiceName )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! KeyHandle )
+ return MMSYSERR_INVALPARAM;
+
+ /* 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) + 1;
+
+ KeyLength *= sizeof(WCHAR);
+
+ /* Allocate memory for the string */
+ ParametersKeyName = (PWCHAR) HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ 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);
+
+ MessageBox(0, ParametersKeyName, L"Parameters key is...", MB_OK |
MB_TASKMODAL);
+
+ /* Perform the open */
+ if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ ParametersKeyName,
+ 0,
+ KEY_READ,
+ KeyHandle) != ERROR_SUCCESS )
+ {
+ /* Couldn't open the key */
+ HeapFree(GetProcessHeap(), 0, ParametersKeyName);
+ return MMSYSERR_ERROR;
+ }
+
+ HeapFree(GetProcessHeap(), 0, 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 PathSize;
+ PWCHAR RegPath;
+
+ if ( ! ServiceName )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! KeyHandle )
+ return MMSYSERR_INVALPARAM;
+
+ /*
+ Work out the space required to hold the path:
+
+ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
+ sndblst\
+ Parameters\
+ Device123\
+ */
+ PathSize = 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) + 1;
+
+ PathSize *= sizeof(WCHAR);
+
+ /* Allocate storage for the string */
+ RegPath = (PWCHAR) HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ PathSize);
+
+ 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);
+
+ MessageBox(0, RegPath, L"Opening registry path", MB_OK | MB_TASKMODAL);
+
+ /* Perform the open */
+ if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ RegPath,
+ 0,
+ KEY_READ,
+ KeyHandle) != ERROR_SUCCESS )
+ {
+ /* Couldn't open the key */
+ HeapFree(GetProcessHeap(), 0, RegPath);
+ return MMSYSERR_ERROR;
+ }
+
+ HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, 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(
+ LPWSTR ServiceName,
+ UCHAR DeviceType,
+ SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+{
+ HKEY Key;
+ DWORD KeyIndex = 0;
+
+ /* Validate parameters */
+ if ( ! ServiceName )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ return MMSYSERR_INVALPARAM;
+
+ 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 )
+ {
+ RegCloseKey(DevicesKey);
+ RegCloseKey(Key);
+
+ return MMSYSERR_ERROR;
+ }
+
+ /* Account for terminating NULL */
+ ++ MaxNameLength;
+
+ DevicePath = (PWSTR) HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ (MaxNameLength +
+ strlen("\\\\.\\")) *
+ sizeof(WCHAR));
+
+ /* 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 */
+ ValueNameLength = MaxNameLength;
+
+ 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) ) )
+ {
+ SoundDeviceDetectedProc(
+ DeviceType,
+ DevicePath,
+ INVALID_HANDLE_VALUE);
+ }
+
+ /* Reset variables for the next iteration */
+ ValueNameLength = MaxNameLength;
+ ZeroMemory(ValueName, MaxNameLength);
+ ValueDataLength = sizeof(DWORD);
+ ValueData = 0;
+ ValueType = REG_NONE;
+
+ ++ ValueIndex;
+ }
+
+ HeapFree(GetProcessHeap(), 0, 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(
+ UCHAR DeviceType,
+ PWSTR BaseDeviceName,
+ SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
+{
+ ULONG DeviceNameLength = 0;
+ ULONG DeviceNameSize = 0;
+ PWSTR DeviceName = NULL;
+ ULONG Index = 0, Count = 0;
+ HANDLE DeviceHandle;
+ BOOLEAN DoSearch = TRUE;
+
+ DPRINT("Detecting NT4 style sound devices of type %d\n", DeviceType);
+
+ if ( ! VALID_SOUND_DEVICE_TYPE(DeviceType) )
+ {
+ return MMSYSERR_INVALPARAM;
+ }
+
+ DeviceNameLength = wcslen(BaseDeviceName);
+ /* Consider the length of the number */
+ DeviceNameLength += GetDigitCount(Index);
+ /* ...and the terminating NULL */
+ DeviceNameLength += 1;
+ /* Finally, this is a wide string, so... */
+ DeviceNameSize = DeviceNameLength * sizeof(WCHAR);
+
+ DeviceName = (PWSTR)
+ HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, DeviceNameSize);
+
+ if ( ! DeviceName )
+ {
+ return MMSYSERR_NOMEM;
+ }
+
+ while ( DoSearch )
+ {
+ /* Nothing like a nice clean device name */
+ ZeroMemory(DeviceName, DeviceNameSize);
+ wsprintf(DeviceName, L"%ls%d", BaseDeviceName, Index);
+
+ if ( OpenKernelSoundDeviceByName(DeviceName,
+ GENERIC_READ,
+ &DeviceHandle) == MMSYSERR_NOERROR )
+ {
+ DPRINT("Found device %d\n", Index);
+
+ /* Notify the callback function */
+ if ( SoundDeviceDetectedProc(DeviceType, DeviceName, DeviceHandle) )
+ {
+ ++ Count;
+ }
+
+ CloseHandle(DeviceHandle);
+
+ ++ Index;
+ }
+ else
+ {
+ DoSearch = FALSE;
+ }
+ }
+
+ HeapFree(GetProcessHeap(), 0, DeviceName);
+
+ return MMSYSERR_NOERROR;
+}
+
+
+#include <ntddk.h> /* How do I avoid this? */
+
+MMRESULT
+DefaultGetSoundDeviceCapabilities(
+ IN PSOUND_DEVICE Device,
+ OUT PUNIVERSAL_CAPS Capabilities)
+{
+ PVOID RawCapsPtr = NULL;
+ ULONG CapsSize = 0;
+ DWORD Ioctl;
+ MMRESULT Result;
+ DWORD BytesReturned;
+
+ ZeroMemory(Capabilities, sizeof(UNIVERSAL_CAPS));
+
+ if ( ! Device )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Capabilities )
+ return MMSYSERR_INVALPARAM;
+
+ /* Select appropriate IOCTL and capabilities structure */
+ switch ( Device->DeviceType )
+ {
+ case WAVE_OUT_DEVICE_TYPE :
+ Ioctl = IOCTL_WAVE_GET_CAPABILITIES;
+ RawCapsPtr = (PVOID) &Capabilities->WaveOut;
+ CapsSize = sizeof(WAVEOUTCAPS);
+ break;
+
+ case WAVE_IN_DEVICE_TYPE :
+ Ioctl = IOCTL_WAVE_GET_CAPABILITIES;
+ RawCapsPtr = (PVOID) &Capabilities->WaveIn;
+ CapsSize = sizeof(WAVEINCAPS);
+ break;
+
+ case MIDI_OUT_DEVICE_TYPE :
+ Ioctl = IOCTL_MIDI_GET_CAPABILITIES;
+ RawCapsPtr = (PVOID) &Capabilities->MidiOut;
+ CapsSize = sizeof(MIDIOUTCAPS);
+ break;
+
+ case MIDI_IN_DEVICE_TYPE :
+ Ioctl = IOCTL_MIDI_GET_CAPABILITIES;
+ RawCapsPtr = (PVOID) &Capabilities->MidiIn;
+ CapsSize = sizeof(MIDIINCAPS);
+ break;
+
+ case MIXER_DEVICE_TYPE :
+ /* TODO */
+ /*Ioctl = IOCTL_MIX_GET_CAPABILITIES;*/
+ return MMSYSERR_NOTSUPPORTED;
+
+ case AUX_DEVICE_TYPE :
+ /* TODO */
+ Ioctl = IOCTL_AUX_GET_CAPABILITIES;
+ return MMSYSERR_NOTSUPPORTED;
+
+ default :
+ return MMSYSERR_NOTSUPPORTED;
+ }
+
+ /* Call the driver */
+ Result = ReadSoundDevice(
+ Device,
+ Ioctl,
+ (LPVOID) RawCapsPtr,
+ CapsSize,
+ &BytesReturned,
+ NULL);
+
+ return Result;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/nt4.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,229 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Hax
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <ntddsnd.h>
+#include <debug.h>
+
+#include <mmebuddy.h>
+
+
+/*
+ **** TESTING CODE ONLY ****
+*/
+
+#define IDS_WAVEOUT_PNAME 0x68
+
+
+
+BOOLEAN TestCallback(
+ UCHAR DeviceType,
+ PWSTR DevicePath,
+ HANDLE Handle)
+{
+ MessageBox(0, DevicePath, L"CALLBACK", MB_OK | MB_TASKMODAL);
+
+ CreateSoundDevice(DeviceType, DevicePath);
+
+ return TRUE;
+}
+
+
+APIENTRY VOID
+Test()
+{
+ ULONG WaveInCount, WaveOutCount;
+ ULONG MidiInCount, MidiOutCount;
+ ULONG MixerCount, AuxCount;
+ WCHAR Message[1024];
+
+ DetectNt4SoundDevices(WAVE_IN_DEVICE_TYPE,
+ L"\\\\.\\SBWaveIn",
+ TestCallback);
+
+ DetectNt4SoundDevices(WAVE_OUT_DEVICE_TYPE,
+ L"\\\\.\\SBWaveOut",
+ TestCallback);
+
+ DetectNt4SoundDevices(MIDI_IN_DEVICE_TYPE,
+ L"\\\\.\\MidiIn",
+ TestCallback);
+
+ DetectNt4SoundDevices(MIDI_OUT_DEVICE_TYPE,
+ L"\\\\.\\MidiOut",
+ TestCallback);
+
+ DetectNt4SoundDevices(MIXER_DEVICE_TYPE,
+ L"\\\\.\\SBMixer",
+ TestCallback);
+
+ DetectNt4SoundDevices(AUX_DEVICE_TYPE,
+ L"\\\\.\\SBAux",
+ TestCallback);
+
+ WaveInCount = GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE);
+ WaveOutCount = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
+ MidiInCount = GetSoundDeviceCount(MIDI_IN_DEVICE_TYPE);
+ MidiOutCount = GetSoundDeviceCount(MIDI_OUT_DEVICE_TYPE);
+ MixerCount = GetSoundDeviceCount(MIXER_DEVICE_TYPE);
+ AuxCount = GetSoundDeviceCount(AUX_DEVICE_TYPE);
+
+ wsprintf(Message, L"Found devices:\n- %d wave inputs\n- %d wave outputs\n- %d
midi inputs\n- %d midi outputs\n- %d mixers\n- %d aux devices",
+ WaveInCount, WaveOutCount,
+ MidiInCount, MidiOutCount,
+ MixerCount, AuxCount);
+
+ MessageBox(0, Message, L"Result", MB_OK | MB_TASKMODAL);
+}
+
+APIENTRY VOID
+TestGetCaps()
+{
+ UNIVERSAL_CAPS Caps;
+ WCHAR DevInfo[1024];
+ PSOUND_DEVICE Device;
+ MMRESULT Result;
+
+ CreateSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
+ Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail 1", L"Fail", MB_OK | MB_TASKMODAL);
+ return;
+ }
+
+ Result = GetSoundDeviceCapabilities(Device, &Caps);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail 2", L"Fail", MB_OK | MB_TASKMODAL);
+ return;
+ }
+
+ wsprintf(DevInfo, L"Device name: %hS\nManufacturer ID: %d\nProduct ID:
%d\nDriver version: %x\nChannels: %d", Caps.WaveOut.szPname, Caps.WaveOut.wMid,
Caps.WaveOut.wPid, Caps.WaveOut.vDriverVersion, Caps.WaveOut.wChannels);
+
+ MessageBox(0, DevInfo, L"Result", MB_OK | MB_TASKMODAL);
+
+#if 0
+ HANDLE Handle;
+ MMRESULT Result;
+ WAVEOUTCAPS Caps;
+ DWORD BytesReturned = 0;
+ WCHAR DevInfo[1024];
+
+ Result = OpenKernelSoundDevice(
+ L"\\\\.\\SBWaveOut0",
+ GENERIC_READ,
+ &Handle);
+
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail open", L"Fail open", MB_OK |
MB_TASKMODAL);
+ return;
+ }
+
+ ZeroMemory(&Caps, sizeof(WAVEOUTCAPS));
+
+ if ( !
+ DeviceIoControl(Handle,
+ IOCTL_WAVE_GET_CAPABILITIES,
+ NULL,
+ 0,
+ (LPVOID) &Caps,
+ sizeof(WAVEOUTCAPS),
+ &BytesReturned,
+ NULL) )
+ {
+ MessageBox(0, L"Fail", L"Fail", MB_OK | MB_TASKMODAL);
+ }
+ else
+ {
+ wsprintf(DevInfo, L"%02x %02x %02x %02x %02x %02x", Caps.szPname[0],
Caps.szPname[1], Caps.szPname[2], Caps.szPname[3], Caps.szPname[4], Caps.szPname[5]);
+/*
+ wsprintf(DevInfo, 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, DevInfo, L"Result", MB_OK | MB_TASKMODAL);
+ }
+
+ CloseHandle(Handle);
+#endif
+}
+
+
+
+APIENTRY VOID
+TestDevEnum()
+{
+ EnumerateNt4ServiceSoundDevices(
+ L"sndblst",
+ WAVE_OUT_DEVICE_TYPE,
+ TestCallback);
+}
+
+
+WINAPI VOID
+TestThreading()
+{
+ MMRESULT Result;
+ PSOUND_DEVICE Device;
+ PSOUND_DEVICE_INSTANCE Instance;
+
+ CreateSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
+ Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail 1", L"Fail 1", MB_OK | MB_TASKMODAL);
+ return;
+ }
+
+ Result = CreateSoundDeviceInstance(Device, &Instance);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail 2", L"Fail 2", MB_OK | MB_TASKMODAL);
+ return;
+ }
+
+ Result = StartSoundThread(Instance);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ MessageBox(0, L"Fail 2", L"Fail 2", MB_OK | MB_TASKMODAL);
+ return;
+ }
+
+ MessageBox(0, L"Click to kill thread", L"Bai", MB_OK |
MB_TASKMODAL);
+
+ StopSoundThread(Instance);
+/*
+ P
+
+MMRESULT
+CreateSoundThread(
+ IN PSOUND_DEVICE_INSTANCE Instance,
+ OUT PSOUND_THREAD* Thread);
+*/
+}
+
+
+int APIENTRY wWinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPWSTR lpCmdLine,
+ int nCmdShow)
+{
+ TestThreading();
+ MessageBox(0, L"Le end", L"Bai", MB_OK | MB_TASKMODAL);
+ return 0;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c [iso-8859-1] Fri Jul 4
21:43:17 2008
@@ -1,0 +1,230 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Sound device processing thread
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+/*
+ This is used internally by the internal routines
+ (my, how recursive of you...)
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+
+#include <mmebuddy.h>
+
+DWORD WINAPI
+SoundThreadProc(
+ IN LPVOID lpParameter)
+{
+ PSOUND_DEVICE_INSTANCE Instance;
+ PSOUND_THREAD Thread;
+ HANDLE Events[2];
+
+ Instance = (PSOUND_DEVICE_INSTANCE) lpParameter;
+ Thread = Instance->Thread;
+
+ Events[0] = Thread->KillEvent;
+ Events[1] = Thread->RequestEvent;
+
+ Thread->Running = TRUE;
+
+ MessageBox(0, L"Hi from thread!", L"Hi!", MB_OK | MB_TASKMODAL);
+
+ while ( Thread->Running )
+ {
+ DWORD Signalled = 0;
+
+ Signalled = WaitForMultipleObjects(2, Events, FALSE, INFINITE);
+
+ if ( Signalled == WAIT_OBJECT_0 )
+ {
+ Thread->Running = FALSE;
+ }
+ else if ( Signalled == WAIT_OBJECT_0 + 1 )
+ {
+ /* ... */
+ }
+ }
+
+ MessageBox(0, L"Bye from thread!", L"Bye!", MB_OK |
MB_TASKMODAL);
+
+ ExitThread(0);
+ return 0;
+}
+
+MMRESULT
+CreateThreadEvents(
+ IN PSOUND_THREAD Thread)
+{
+ /* Create the request event */
+ Thread->RequestEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+
+ if ( ! Thread->RequestEvent )
+ {
+ return MMSYSERR_NOMEM;
+ }
+
+ /* Create the request completion event */
+ Thread->RequestCompletionEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+
+ if ( ! Thread->RequestCompletionEvent )
+ {
+ CloseHandle(Thread->RequestEvent);
+ return MMSYSERR_NOMEM;
+ }
+
+ /* Create the kill event */
+ Thread->KillEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+
+ if ( ! Thread->KillEvent )
+ {
+ CloseHandle(Thread->RequestCompletionEvent);
+ CloseHandle(Thread->RequestEvent);
+ return MMSYSERR_NOMEM;
+ }
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+DestroyThreadEvents(
+ IN PSOUND_THREAD Thread)
+{
+ CloseHandle(Thread->RequestEvent);
+ CloseHandle(Thread->RequestCompletionEvent);
+ CloseHandle(Thread->KillEvent);
+
+ return MMSYSERR_NOERROR;
+}
+
+
+MMRESULT
+StartSoundThread(
+ IN PSOUND_DEVICE_INSTANCE Instance)
+{
+ PSOUND_THREAD SoundThread = NULL;
+
+ /* Validate parameters */
+ if ( ! Instance )
+ return MMSYSERR_INVALPARAM;
+
+ /* Only allowed one thread per instance */
+ if ( Instance->Thread )
+ return MMSYSERR_ERROR;
+
+ /* Allocate memory for the thread info */
+ SoundThread = (PSOUND_THREAD) HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(SOUND_THREAD));
+
+ if ( ! SoundThread )
+ return MMSYSERR_NOMEM;
+
+ /* Initialise */
+ SoundThread->Running = FALSE;
+ SoundThread->Handle = INVALID_HANDLE_VALUE;
+ SoundThread->FirstOperation = NULL;
+
+ /* Create the events */
+ if ( CreateThreadEvents(SoundThread) != MMSYSERR_NOERROR )
+ {
+ HeapFree(GetProcessHeap(), 0, SoundThread);
+ return MMSYSERR_NOMEM;
+ }
+
+ if ( ! SoundThread->RequestEvent )
+ {
+ CloseHandle(SoundThread->RequestEvent);
+ HeapFree(GetProcessHeap(), 0, SoundThread);
+ return MMSYSERR_NOMEM;
+ }
+
+ /* Do the creation thang */
+ SoundThread->Handle = CreateThread(NULL,
+ 0,
+ &SoundThreadProc,
+ (LPVOID) Instance,
+ CREATE_SUSPENDED,
+ NULL);
+
+ if (SoundThread->Handle == INVALID_HANDLE_VALUE )
+ {
+ HeapFree(GetProcessHeap(), 0, SoundThread);
+ return Win32ErrorToMmResult(GetLastError());
+ }
+
+ /* Assign the thread to the instance */
+ Instance->Thread = SoundThread;
+
+ /* Go! */
+ ResumeThread(SoundThread->Handle);
+
+ return MMSYSERR_NOERROR;
+}
+
+MMRESULT
+StopSoundThread(
+ IN PSOUND_DEVICE_INSTANCE Instance)
+{
+ if ( ! Instance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Instance->Thread )
+ return MMSYSERR_ERROR;
+
+ /* Make the thread quit */
+ Instance->Thread->Running = FALSE;
+
+ /* Wait for the thread to respond to our gentle nudge */
+ SetEvent(Instance->Thread->KillEvent);
+ WaitForSingleObject(Instance->Thread, INFINITE);
+ CloseHandle(Instance->Thread); /* correct way? */
+
+ /* TODO: A bunch of other stuff - WAIT for thread to die */
+ /* Also clean up the events */
+
+ DestroyThreadEvents(Instance->Thread);
+ HeapFree(GetProcessHeap(), 0, Instance->Thread);
+
+ return MMSYSERR_NOERROR;
+}
+
+
+/*
+ Thread must be started before calling this!
+*/
+
+MMRESULT
+AddSoundThreadOperation(
+ PSOUND_DEVICE_INSTANCE Instance,
+ DWORD OperationId,
+ SOUND_THREAD_OPERATION OperationFunc)
+{
+ /*SOUND_THREAD_OPERATION OriginalFirstOp;*/
+
+ if ( ! Instance )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! OperationFunc )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! Instance->Thread )
+ return MMSYSERR_ERROR;
+
+/*
+ OriginalFirstOp = Instance->Thread->FirstOperation;
+ Instance->Thread->FirstOperation->Next =
+*/
+
+ return MMSYSERR_NOTSUPPORTED;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/thread.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c [iso-8859-1] Fri Jul
4 21:43:17 2008
@@ -1,0 +1,63 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Utility functions
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+
+ULONG
+GetDigitCount(
+ ULONG Number)
+{
+ ULONG Value = Number;
+ ULONG Digits = 1;
+
+ while ( Value > 9 )
+ {
+ Value /= 10;
+ ++ Digits;
+ }
+
+ return Digits;
+}
+
+MMRESULT
+Win32ErrorToMmResult(UINT error_code)
+{
+ switch ( error_code )
+ {
+ case NO_ERROR :
+ case ERROR_IO_PENDING :
+ return MMSYSERR_NOERROR;
+
+ case ERROR_BUSY :
+ return MMSYSERR_ALLOCATED;
+
+ case ERROR_NOT_SUPPORTED :
+ case ERROR_INVALID_FUNCTION :
+ return MMSYSERR_NOTSUPPORTED;
+
+ case ERROR_NOT_ENOUGH_MEMORY :
+ return MMSYSERR_NOMEM;
+
+ case ERROR_ACCESS_DENIED :
+ return MMSYSERR_BADDEVICEID;
+
+ case ERROR_INSUFFICIENT_BUFFER :
+ return MMSYSERR_INVALPARAM;
+ };
+
+ /* If all else fails, it's just a plain old error */
+
+ return MMSYSERR_ERROR;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/utility.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c (added)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.c [iso-8859-1]
Fri Jul 4 21:43:17 2008
@@ -1,0 +1,38 @@
+/*
+ ReactOS Sound System
+ MME Driver Helper
+
+ Purpose:
+ Wave thread operations
+
+ Author:
+ Andrew Greenwood (silverblade(a)reactos.org)
+
+ History:
+ 4 July 2008 - Created
+*/
+
+#include <windows.h>
+#include <mmsystem.h>
+
+#include <mmebuddy.h>
+
+MMRESULT
+StartWaveThread(
+ IN PSOUND_DEVICE_INSTANCE Instance)
+{
+ MMRESULT Result;
+
+ if ( ! Instance )
+ return MMSYSERR_INVALPARAM;
+
+ /* Kick off the thread */
+ Result = StartSoundThread(Instance);
+ if ( Result != MMSYSERR_NOERROR )
+ {
+ return Result;
+ }
+
+ /* AddSoundThreadOperation(Instance, 69, SayHello); */
+ return MMSYSERR_NOTSUPPORTED;
+}
Propchange: branches/silverblade-audio/lib/drivers/sound/mmebuddy/wave/wavethread.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 Jul 4
21:43:17 2008
@@ -13,4 +13,7 @@
<directory name="uartmidi">
<xi:include href="uartmidi/uartmidi.rbuild" />
</directory>
+ <directory name="mmebuddy">
+ <xi:include href="mmebuddy/mmebuddy.rbuild" />
+ </directory>
</group>