ReactOS  0.4.14-dev-342-gdc047f9
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 #ifndef USE_MMIXER_LIB
22 #define FUNC_NAME(x) x##ByLegacy
23 #else
24 #define FUNC_NAME(x) x##ByMMixer
25 #endif
26 
30  IN PWAVEFORMATEX WaveFormat,
31  IN DWORD WaveFormatSize)
32 {
33  /* Whatever... */
34  return MMSYSERR_NOERROR;
35 }
36 
40 {
42  DWORD DeviceCount = 0;
43  PSOUND_DEVICE SoundDevice = NULL;
44  MMFUNCTION_TABLE FuncTable;
45  DWORD i;
46 
48 
49  Result = FUNC_NAME(WdmAudGetNumWdmDevs)(DeviceType, &DeviceCount);
50 
51  if ( ! MMSUCCESS(Result) )
52  {
53  SND_ERR(L"Error %d while obtaining number of devices\n", Result);
55  }
56 
57  SND_TRACE(L"%d devices of type %d found\n", DeviceCount, DeviceType);
58 
59 
60  for ( i = 0; i < DeviceCount; ++ i )
61  {
62  Result = ListSoundDevice(DeviceType, UlongToPtr(i), &SoundDevice);
63 
64  if ( ! MMSUCCESS(Result) )
65  {
66  SND_ERR(L"Failed to list sound device - error %d\n", Result);
68  }
69 
70  /* Set up our function table */
71  ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
72  FuncTable.GetCapabilities = FUNC_NAME(WdmAudGetCapabilities);
74  FuncTable.Open = FUNC_NAME(WdmAudOpenSoundDevice);
75  FuncTable.Close = FUNC_NAME(WdmAudCloseSoundDevice);
76  FuncTable.GetDeviceInterfaceString = FUNC_NAME(WdmAudGetDeviceInterfaceString);
77 
79  {
80  FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
81  FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo);
82  }
84  {
85  FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat);
86  FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
88  FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
89 
90 #ifndef USERMODE_MIXER
91  FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer);
92 #else
94 #endif
95  }
97  {
98  FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat);
99  FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState);
100  FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition);
101  }
102 
103  SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
104  }
105 
106  return MMSYSERR_NOERROR;
107 }
108 
109 
110 
111 LONG
112 APIENTRY
114  DWORD DriverId,
115  HANDLE DriverHandle,
116  UINT Message,
117  LONG Parameter1,
118  LONG Parameter2)
119 {
120  switch ( Message )
121  {
122  case DRV_LOAD :
123  {
124  HANDLE Handle;
126  SND_TRACE(L"DRV_LOAD\n");
127 
129 
130  if ( ! MMSUCCESS(Result) )
131  return 0L;
132 
133  Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle);
134 
135  if ( Result != MMSYSERR_NOERROR )
136  {
137  SND_ERR(L"Failed to open \\\\.\\wdmaud\n");
138  //UnlistAllSoundDevices();
139 
140  return 0L;
141  }
142 
143  /* Populate the device lists */
144  SND_TRACE(L"Populating device lists\n");
151 
152  SND_TRACE(L"Initialisation complete\n");
153 
154  return 1L;
155  }
156 
157  case DRV_FREE :
158  {
159  SND_TRACE(L"DRV_FREE\n");
160 
162 
163  /* TODO: Clean up the path names! */
165 
167 
168  SND_TRACE(L"Unfreed memory blocks: %d\n",
170 
171  return 1L;
172  }
173 
174  case DRV_ENABLE :
175  case DRV_DISABLE :
176  {
177  SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
178  return 1L;
179  }
180 
181  case DRV_OPEN :
182  case DRV_CLOSE :
183  {
184  SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
185  return 1L;
186  }
187 
188  case DRV_QUERYCONFIGURE :
189  {
190  SND_TRACE(L"DRV_QUERYCONFIGURE\n");
191  return 0L;
192  }
193  case DRV_CONFIGURE :
194  return DRVCNF_OK;
195 
196  default :
197  SND_TRACE(L"Unhandled message %d\n", Message);
198  return DefDriverProc(DriverId,
199  DriverHandle,
200  Message,
201  Parameter1,
202  Parameter2);
203  }
204 }
205 
206 
208  HINSTANCE hinstDLL,
209  DWORD fdwReason,
211 {
212  switch ( fdwReason )
213  {
214  case DLL_PROCESS_ATTACH :
215  SND_TRACE(L"WDMAUD.DRV - Process attached\n");
216  break;
217  case DLL_PROCESS_DETACH :
218  SND_TRACE(L"WDMAUD.DRV - Process detached\n");
219  break;
220  case DLL_THREAD_ATTACH :
221  SND_TRACE(L"WDMAUD.DRV - Thread attached\n");
222  break;
223  case DLL_THREAD_DETACH :
224  SND_TRACE(L"WDMAUD.DRV - Thread detached\n");
225  break;
226  }
227 
228  return TRUE;
229 }
#define DRV_DISABLE
Definition: mmsystem.h:123
#define IN
Definition: typedefs.h:38
MMRESULT ListSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
Definition: devicelist.c:131
MMGETPOS_FUNC GetPos
Definition: mmebuddy.h:215
#define TRUE
Definition: types.h:120
LONG APIENTRY DriverProc(DWORD DriverId, HANDLE DriverHandle, UINT Message, LONG Parameter1, LONG Parameter2)
Definition: wdmaud.c:113
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define DLL_THREAD_ATTACH
Definition: compat.h:121
DeviceType
Definition: mmdrv.h:41
NTSTATUS NTAPI WdmAudCleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: entry.c:286
MMRESETSTREAM_FUNC ResetStream
Definition: mmebuddy.h:218
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define ZeroMemory
Definition: winbase.h:1642
UINT MMRESULT
Definition: mmsystem.h:962
#define DRV_CLOSE
Definition: mmsystem.h:122
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
VOID CleanupEntrypointMutexes(VOID)
MMCLOSE_FUNC Close
Definition: mmebuddy.h:206
#define DRVCNF_OK
Definition: mmsystem.h:134
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define DLL_THREAD_DETACH
Definition: compat.h:122
static IN DWORD IN LPVOID lpvReserved
MMRESULT PopulateWdmDeviceList(MMDEVICE_TYPE DeviceType)
Definition: wdmaud.c:38
WAVE_COMMIT_FUNC CommitWaveBuffer
Definition: mmebuddy.h:213
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
#define DRV_OPEN
Definition: mmsystem.h:121
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
NTSTATUS NTAPI WdmAudResetStream(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo)
Definition: control.c:270
MMRESULT QueryWdmWaveDeviceFormatSupport(IN PSOUND_DEVICE Device, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: wdmaud.c:28
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
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport
Definition: mmebuddy.h:208
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
ULONG DeviceCount
Definition: mpu401.c:26
MMGETCAPS_FUNC GetCapabilities
Definition: mmebuddy.h:198
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define DRV_LOAD(x)
#define UlongToPtr(u)
Definition: config.h:106
#define DLL_PROCESS_DETACH
Definition: compat.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define SND_ERR(...)
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
MMSETSTATE_FUNC SetState
Definition: mmebuddy.h:216
#define DRV_FREE
Definition: mmsystem.h:124
#define FUNC_NAME(x)
Definition: wdmaud.c:22
CHAR Message[80]
Definition: alive.c:5
UINT GetMemoryAllocationCount(VOID)
static const WCHAR L[]
Definition: oid.c:1250
VOID UnlistAllSoundDevices(VOID)
#define DRV_ENABLE
Definition: mmsystem.h:120
MMMIXERQUERY_FUNC QueryMixerInfo
Definition: mmebuddy.h:211
MMQUERYDEVICEINTERFACESTRING_FUNC GetDeviceInterfaceString
Definition: mmebuddy.h:217
MMOPEN_FUNC Open
Definition: mmebuddy.h:205
MMRESULT InitEntrypointMutexes(VOID)
unsigned int UINT
Definition: ndis.h:50
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
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
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: wdmaud.c:207
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:554
MMWAVESETFORMAT_FUNC SetWaveFormat
Definition: mmebuddy.h:209
#define SND_TRACE(...)
#define APIENTRY
Definition: api.h:79