ReactOS 0.4.15-dev-8434-g155a7c7
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.GetVolume = FUNC_NAME(WdmAudGetVolume);
82 FuncTable.SetVolume = FUNC_NAME(WdmAudSetVolume);
83 }
84
86 {
87 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
88 FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo);
89 }
91 {
92 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat);
93 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
95 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
96
97#ifndef USERMODE_MIXER
98 FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer);
99#else
101#endif
102 }
104 {
105 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
106 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
107 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
108 }
109
110 SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
111 }
112
113 return MMSYSERR_NOERROR;
114}
115
116
117
118LONG
121 DWORD DriverId,
124 LONG Parameter1,
125 LONG Parameter2)
126{
127 switch ( Message )
128 {
129 case DRV_LOAD :
130 {
133 SND_TRACE(L"DRV_LOAD\n");
134
136
137 if ( ! MMSUCCESS(Result) )
138 return 0L;
139
140 Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle);
141
142 if ( Result != MMSYSERR_NOERROR )
143 {
144 SND_ERR(L"Failed to open \\\\.\\wdmaud\n");
145 //UnlistAllSoundDevices();
146
147 return 0L;
148 }
149
150 /* Populate the device lists */
151 SND_TRACE(L"Populating device lists\n");
158
159 SND_TRACE(L"Initialisation complete\n");
160
161 return 1L;
162 }
163
164 case DRV_FREE :
165 {
166 SND_TRACE(L"DRV_FREE\n");
167
169
170 /* TODO: Clean up the path names! */
172
174
175 SND_TRACE(L"Unfreed memory blocks: %d\n",
177
178 return 1L;
179 }
180
181 case DRV_ENABLE :
182 case DRV_DISABLE :
183 {
184 SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
185 return 1L;
186 }
187
188 case DRV_OPEN :
189 case DRV_CLOSE :
190 {
191 SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
192 return 1L;
193 }
194
195 case DRV_QUERYCONFIGURE :
196 {
197 SND_TRACE(L"DRV_QUERYCONFIGURE\n");
198 return 0L;
199 }
200 case DRV_CONFIGURE :
201 return DRVCNF_OK;
202
203 default :
204 SND_TRACE(L"Unhandled message %d\n", Message);
205 return DefDriverProc(DriverId,
207 Message,
208 Parameter1,
209 Parameter2);
210 }
211}
212
213
215 HINSTANCE hinstDLL,
216 DWORD fdwReason,
218{
219 switch ( fdwReason )
220 {
221 case DLL_PROCESS_ATTACH :
222 SND_TRACE(L"WDMAUD.DRV - Process attached\n");
223 break;
224 case DLL_PROCESS_DETACH :
225 SND_TRACE(L"WDMAUD.DRV - Process detached\n");
226 break;
227 case DLL_THREAD_ATTACH :
228 SND_TRACE(L"WDMAUD.DRV - Thread attached\n");
229 break;
230 case DLL_THREAD_DETACH :
231 SND_TRACE(L"WDMAUD.DRV - Thread detached\n");
232 break;
233 }
234
235 return TRUE;
236}
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
MMGETVOLUME_FUNC GetVolume
Definition: mmebuddy.h:229
MMOPEN_FUNC Open
Definition: mmebuddy.h:214
MMCLOSE_FUNC Close
Definition: mmebuddy.h:215
MMGETPOS_FUNC GetPos
Definition: mmebuddy.h:224
MMRESETSTREAM_FUNC ResetStream
Definition: mmebuddy.h:227
MMGETCAPS_FUNC GetCapabilities
Definition: mmebuddy.h:207
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport
Definition: mmebuddy.h:217
WAVE_COMMIT_FUNC CommitWaveBuffer
Definition: mmebuddy.h:222
MMSETSTATE_FUNC SetState
Definition: mmebuddy.h:225
MMWAVESETFORMAT_FUNC SetWaveFormat
Definition: mmebuddy.h:218
MMMIXERQUERY_FUNC QueryMixerInfo
Definition: mmebuddy.h:220
MMSETVOLUME_FUNC SetVolume
Definition: mmebuddy.h:230
MMQUERYDEVICEINTERFACESTRING_FUNC GetDeviceInterfaceString
Definition: mmebuddy.h:226
#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:214
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:120
#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