Author: silverblade
Date: Sat Jul 5 19:42:38 2008
New Revision: 34317
URL:
http://svn.reactos.org/svn/reactos?rev=34317&view=rev
Log:
Added macros to ntddsnd.h to make device type checking easier (can now check
if a device is a wave device without comparing against wave in and wave out
individually). Renamed CreateSoundDevice to AddSoundDevice (doesn't actually
*create* devices!) and implemented wave format setting via IOCTL_WAVE_SET_FORMAT.
Modified:
branches/silverblade-audio/include/ddk/ntddsnd.h
branches/silverblade-audio/include/reactos/libs/sound/mmebuddy.h
branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c
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] Sat Jul 5 19:42:38
2008
@@ -7,6 +7,8 @@
History:
24 May 2008 - Created
+ 2 July 2008 - Added device names as seen from user-mode
+ 5 July 2008 - Added macros for checking device type
This file contains definitions and structures for Windows NT4 style
multimedia drivers. The NT4 DDK has these split across multiple header
@@ -48,6 +50,18 @@
#define VALID_SOUND_DEVICE_TYPE(x) \
( ( x >= MIN_SOUND_DEVICE_TYPE ) && ( x <= MAX_SOUND_DEVICE_TYPE ) )
+#define IS_WAVE_DEVICE_TYPE(x) \
+ ( ( x == WAVE_IN_DEVICE_TYPE ) || ( x == WAVE_OUT_DEVICE_TYPE ) )
+
+#define IS_MIDI_DEVICE_TYPE(x) \
+ ( ( x == MIDI_IN_DEVICE_TYPE ) || ( x == MIDI_OUT_DEVICE_TYPE ) )
+
+#define IS_AUX_DEVICE_TYPE(x) \
+ ( x == AUX_DEVICE_TYPE )
+
+#define IS_MIXER_DEVICE_TYPE(x) \
+ ( x == MIXER_DEVICE_TYPE )
+
/*
Base device names
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] Sat Jul
5 19:42:38 2008
@@ -115,7 +115,7 @@
IN struct _SOUND_DEVICE* SoundDevice,
OUT PUNIVERSAL_CAPS Capabilities);
-typedef MMRESULT (*MMQUERYWAVEFORMAT_FUNC)(
+typedef MMRESULT (*MMWAVEFORMAT_FUNC)(
IN struct _SOUND_DEVICE* SoundDevice,
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
@@ -125,7 +125,9 @@
MMOPEN_FUNC Open;
MMCLOSE_FUNC Close;
MMGETCAPS_FUNC GetCapabilities;
- MMQUERYWAVEFORMAT_FUNC QueryWaveFormat;
+
+ MMWAVEFORMAT_FUNC QueryWaveFormat;
+ MMWAVEFORMAT_FUNC SetWaveFormat;
} MMFUNCTION_TABLE, *PMMFUNCTION_TABLE;
@@ -196,12 +198,12 @@
UCHAR DeviceType);
BOOLEAN
-CreateSoundDevice(
+AddSoundDevice(
UCHAR DeviceType,
PWSTR DevicePath);
BOOLEAN
-DestroySoundDevice(
+RemoveSoundDevice(
UCHAR DeviceType,
ULONG Index);
@@ -340,6 +342,18 @@
IN PWAVEFORMATEX WaveFormat,
IN DWORD WaveFormatSize);
+MMRESULT
+SetWaveDeviceFormat(
+ IN PSOUND_DEVICE Device,
+ IN PWAVEFORMATEX WaveFormat,
+ IN DWORD WaveFormatSize);
+
+MMRESULT
+DefaultSetWaveDeviceFormat(
+ IN PSOUND_DEVICE Device,
+ IN PWAVEFORMATEX WaveFormat,
+ IN DWORD WaveFormatSize);
+
/*
thread.c
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/devices.c [iso-8859-1] Sat Jul
5 19:42:38 2008
@@ -150,11 +150,12 @@
{
Device->Functions.GetCapabilities = DefaultGetSoundDeviceCapabilities;
Device->Functions.QueryWaveFormat = DefaultQueryWaveDeviceFormatSupport;
+ Device->Functions.SetWaveFormat = DefaultSetWaveDeviceFormat;
}
BOOLEAN
-CreateSoundDevice(
+AddSoundDevice(
UCHAR DeviceType,
LPWSTR DevicePath)
{
@@ -237,7 +238,7 @@
BOOLEAN
-DestroySoundDevice(
+RemoveSoundDevice(
UCHAR DeviceType,
ULONG Index)
{
@@ -430,8 +431,7 @@
return MMSYSERR_INVALPARAM;
/* Make sure we have a wave device */
- if ( ( Device->DeviceType != WAVE_OUT_DEVICE_TYPE ) &&
- ( Device->DeviceType != WAVE_IN_DEVICE_TYPE ) )
+ if ( IS_WAVE_DEVICE_TYPE(Device->DeviceType) )
{
return MMSYSERR_INVALPARAM;
}
@@ -446,3 +446,51 @@
return Result;
}
+MMRESULT
+SetWaveDeviceFormat(
+ IN PSOUND_DEVICE Device,
+ IN PWAVEFORMATEX WaveFormat,
+ IN DWORD WaveFormatSize)
+{
+ if ( ! Device )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! WaveFormat )
+ return MMSYSERR_INVALPARAM;
+
+ /* TODO: Should we check the size? */
+
+ return Device->Functions.SetWaveFormat(Device, WaveFormat, WaveFormatSize);
+}
+
+MMRESULT
+DefaultSetWaveDeviceFormat(
+ IN PSOUND_DEVICE Device,
+ IN PWAVEFORMATEX WaveFormat,
+ IN DWORD WaveFormatSize)
+{
+ MMRESULT Result;
+ DWORD BytesReturned = 0;
+
+ if ( ! Device )
+ return MMSYSERR_INVALPARAM;
+
+ if ( ! WaveFormat )
+ return MMSYSERR_INVALPARAM;
+
+ /* Make sure we have a wave device */
+ if ( IS_WAVE_DEVICE_TYPE(Device->DeviceType) )
+ {
+ return MMSYSERR_INVALPARAM;
+ }
+
+ Result = WriteSoundDevice(Device,
+ IOCTL_WAVE_SET_FORMAT,
+ (LPVOID) WaveFormat,
+ WaveFormatSize,
+ &BytesReturned,
+ NULL);
+
+ return Result;
+}
+
Modified: branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c
URL:
http://svn.reactos.org/svn/reactos/branches/silverblade-audio/lib/drivers/s…
==============================================================================
--- branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1]
(original)
+++ branches/silverblade-audio/lib/drivers/sound/mmebuddy/testing.c [iso-8859-1] Sat Jul
5 19:42:38 2008
@@ -35,7 +35,7 @@
{
MessageBox(0, DevicePath, L"CALLBACK", MB_OK | MB_TASKMODAL);
- CreateSoundDevice(DeviceType, DevicePath);
+ AddSoundDevice(DeviceType, DevicePath);
return TRUE;
}
@@ -96,7 +96,7 @@
PSOUND_DEVICE Device;
MMRESULT Result;
- CreateSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
+ AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device);
if ( Result != MMSYSERR_NOERROR )
@@ -126,7 +126,7 @@
MMRESULT Result;
WAVEFORMATEX fmt;
- CreateSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
+ AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device);
if ( Result != MMSYSERR_NOERROR )
@@ -188,7 +188,7 @@
PSOUND_DEVICE Device;
PSOUND_DEVICE_INSTANCE Instance;
- CreateSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
+ AddSoundDevice(WAVE_OUT_DEVICE_TYPE, L"\\\\.\\SBWaveOut0");
Result = GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &Device);
if ( Result != MMSYSERR_NOERROR )
{
@@ -216,14 +216,6 @@
MessageBox(0, L"Click to kill thread", L"Bai", MB_OK |
MB_TASKMODAL);
StopWaveThread(Instance);
-/*
- P
-
-MMRESULT
-CreateSoundThread(
- IN PSOUND_DEVICE_INSTANCE Instance,
- OUT PSOUND_THREAD* Thread);
-*/
}