ReactOS 0.4.15-dev-8102-g108db8f
wdmaud.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Sound System
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/wdmaud.drv/wdmaud.c
5 *
6 * PURPOSE: WDM Audio Driver (User-mode part)
7 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
8 *
9 * NOTES: Looking for wodMessage & co? You won't find them here. Try
10 * the MME Buddy library, which is where these routines are
11 * actually implemented.
12 *
13 */
14
15#include "wdmaud.h"
16
17#define NDEBUG
18#include <debug.h>
19#include <mmebuddy_debug.h>
20
21#define USE_MMIXER_LIB
22#ifndef USE_MMIXER_LIB
23#define FUNC_NAME(x) x##ByLegacy
24#else
25#define FUNC_NAME(x) x##ByMMixer
26#endif
27
31 IN PWAVEFORMATEX WaveFormat,
32 IN DWORD WaveFormatSize)
33{
34 /* Whatever... */
35 return MMSYSERR_NOERROR;
36}
37
41{
44 PSOUND_DEVICE SoundDevice = NULL;
45 MMFUNCTION_TABLE FuncTable;
46 DWORD i;
47
49
50 Result = FUNC_NAME(WdmAudGetNumWdmDevs)(DeviceType, &DeviceCount);
51
52 if ( ! MMSUCCESS(Result) )
53 {
54 SND_ERR(L"Error %d while obtaining number of devices\n", Result);
56 }
57
58 SND_TRACE(L"%d devices of type %d found\n", DeviceCount, DeviceType);
59
60
61 for ( i = 0; i < DeviceCount; ++ i )
62 {
63 Result = ListSoundDevice(DeviceType, UlongToPtr(i), &SoundDevice);
64
65 if ( ! MMSUCCESS(Result) )
66 {
67 SND_ERR(L"Failed to list sound device - error %d\n", Result);
69 }
70
71 /* Set up our function table */
72 ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
73 FuncTable.GetCapabilities = FUNC_NAME(WdmAudGetCapabilities);
75 FuncTable.Open = FUNC_NAME(WdmAudOpenSoundDevice);
76 FuncTable.Close = FUNC_NAME(WdmAudCloseSoundDevice);
77 FuncTable.GetDeviceInterfaceString = FUNC_NAME(WdmAudGetDeviceInterfaceString);
78
80 {
81 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
82 FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo);
83 }
85 {
86 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat);
87 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
89 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
90
91#ifndef USERMODE_MIXER
92 FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer);
93#else
95#endif
96 }
98 {
99 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
100 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
101 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
102 }
103
104 SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
105 }
106
107 return MMSYSERR_NOERROR;
108}
109
110
111
112LONG
115 DWORD DriverId,
118 LONG Parameter1,
119 LONG Parameter2)
120{
121 switch ( Message )
122 {
123 case DRV_LOAD :
124 {
127 SND_TRACE(L"DRV_LOAD\n");
128
130
131 if ( ! MMSUCCESS(Result) )
132 return 0L;
133
134 Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle);
135
136 if ( Result != MMSYSERR_NOERROR )
137 {
138 SND_ERR(L"Failed to open \\\\.\\wdmaud\n");
139 //UnlistAllSoundDevices();
140
141 return 0L;
142 }
143
144 /* Populate the device lists */
145 SND_TRACE(L"Populating device lists\n");
152
153 SND_TRACE(L"Initialisation complete\n");
154
155 return 1L;
156 }
157
158 case DRV_FREE :
159 {
160 SND_TRACE(L"DRV_FREE\n");
161
163
164 /* TODO: Clean up the path names! */
166
168
169 SND_TRACE(L"Unfreed memory blocks: %d\n",
171
172 return 1L;
173 }
174
175 case DRV_ENABLE :
176 case DRV_DISABLE :
177 {
178 SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
179 return 1L;
180 }
181
182 case DRV_OPEN :
183 case DRV_CLOSE :
184 {
185 SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
186 return 1L;
187 }
188
189 case DRV_QUERYCONFIGURE :
190 {
191 SND_TRACE(L"DRV_QUERYCONFIGURE\n");
192 return 0L;
193 }
194 case DRV_CONFIGURE :
195 return DRVCNF_OK;
196
197 default :
198 SND_TRACE(L"Unhandled message %d\n", Message);
199 return DefDriverProc(DriverId,
201 Message,
202 Parameter1,
203 Parameter2);
204 }
205}
206
207
209 HINSTANCE hinstDLL,
210 DWORD fdwReason,
212{
213 switch ( fdwReason )
214 {
215 case DLL_PROCESS_ATTACH :
216 SND_TRACE(L"WDMAUD.DRV - Process attached\n");
217 break;
218 case DLL_PROCESS_DETACH :
219 SND_TRACE(L"WDMAUD.DRV - Process detached\n");
220 break;
221 case DLL_THREAD_ATTACH :
222 SND_TRACE(L"WDMAUD.DRV - Thread attached\n");
223 break;
224 case DLL_THREAD_DETACH :
225 SND_TRACE(L"WDMAUD.DRV - Thread detached\n");
226 break;
227 }
228
229 return TRUE;
230}
static NDIS_HANDLE DriverHandle
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define APIENTRY
Definition: api.h:79
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define DLL_THREAD_ATTACH
Definition: compat.h:132
MMRESULT WriteFileEx_Remixer(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
Definition: mixer.c:423
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:554
static const WCHAR Message[]
Definition: register.c:74
#define UlongToPtr(u)
Definition: config.h:106
NTSTATUS NTAPI WdmAudResetStream(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:270
NTSTATUS NTAPI WdmAudCleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: entry.c:286
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Handle
Definition: gdb_input.c:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DRV_LOAD(x)
static IN DWORD IN LPVOID lpvReserved
DeviceType
Definition: mmdrv.h:42
MMRESULT ListSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
Definition: devicelist.c:131
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_TRACE(...)
#define SND_ERR(...)
#define DRV_CLOSE
Definition: mmsystem.h:122
UINT MMRESULT
Definition: mmsystem.h:962
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
#define DRV_ENABLE
Definition: mmsystem.h:120
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define DRV_OPEN
Definition: mmsystem.h:121
#define DRVCNF_OK
Definition: mmsystem.h:134
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define DRV_FREE
Definition: mmsystem.h:124
#define DRV_DISABLE
Definition: mmsystem.h:123
ULONG DeviceCount
Definition: mpu401.c:26
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
VOID CleanupEntrypointMutexes()
Definition: reentrancy.c:56
MMRESULT InitEntrypointMutexes()
Definition: reentrancy.c:21
VOID UnlistAllSoundDevices()
Definition: devicelist.c:270
UINT GetMemoryAllocationCount()
Definition: utility.c:58
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ AUX_DEVICE_TYPE
Definition: sndtypes.h:32
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
MMOPEN_FUNC Open
Definition: mmebuddy.h:204
MMCLOSE_FUNC Close
Definition: mmebuddy.h:205
MMGETPOS_FUNC GetPos
Definition: mmebuddy.h:214
MMRESETSTREAM_FUNC ResetStream
Definition: mmebuddy.h:217
MMGETCAPS_FUNC GetCapabilities
Definition: mmebuddy.h:197
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport
Definition: mmebuddy.h:207
WAVE_COMMIT_FUNC CommitWaveBuffer
Definition: mmebuddy.h:212
MMSETSTATE_FUNC SetState
Definition: mmebuddy.h:215
MMWAVESETFORMAT_FUNC SetWaveFormat
Definition: mmebuddy.h:208
MMMIXERQUERY_FUNC QueryMixerInfo
Definition: mmebuddy.h:210
MMQUERYDEVICEINTERFACESTRING_FUNC GetDeviceInterfaceString
Definition: mmebuddy.h:216
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: wdmaud.c:208
MMRESULT QueryWdmWaveDeviceFormatSupport(IN PSOUND_DEVICE Device, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: wdmaud.c:29
MMRESULT PopulateWdmDeviceList(MMDEVICE_TYPE DeviceType)
Definition: wdmaud.c:39
#define FUNC_NAME(x)
Definition: wdmaud.c:25
LONG APIENTRY DriverProc(DWORD DriverId, HANDLE DriverHandle, UINT Message, LONG Parameter1, LONG Parameter2)
Definition: wdmaud.c:114
#define ZeroMemory
Definition: winbase.h:1712
#define WINAPI
Definition: msvc.h:6
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409