2 * PROJECT: ReactOS Sound System
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/wdmaud.drv/wdmaud.c
6 * PURPOSE: WDM Audio Driver (User-mode part)
7 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
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.
20 #ifndef USE_MMIXER_LIB
21 #define FUNC_NAME(x) x##ByLegacy
23 #define FUNC_NAME(x) x##ByMMixer
27 QueryWdmWaveDeviceFormatSupport(
28 IN PSOUND_DEVICE Device
,
29 IN PWAVEFORMATEX WaveFormat
,
30 IN DWORD WaveFormatSize
)
33 return MMSYSERR_NOERROR
;
37 PopulateWdmDeviceList(
38 MMDEVICE_TYPE DeviceType
)
41 DWORD DeviceCount
= 0;
42 PSOUND_DEVICE SoundDevice
= NULL
;
43 MMFUNCTION_TABLE FuncTable
;
46 VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType
) );
48 Result
= FUNC_NAME(WdmAudGetNumWdmDevs
)(DeviceType
, &DeviceCount
);
50 if ( ! MMSUCCESS(Result
) )
52 SND_ERR(L
"Error %d while obtaining number of devices\n", Result
);
53 return TranslateInternalMmResult(Result
);
56 SND_TRACE(L
"%d devices of type %d found\n", DeviceCount
, DeviceType
);
59 for ( i
= 0; i
< DeviceCount
; ++ i
)
61 Result
= ListSoundDevice(DeviceType
, UlongToPtr(i
), &SoundDevice
);
63 if ( ! MMSUCCESS(Result
) )
65 SND_ERR(L
"Failed to list sound device - error %d\n", Result
);
66 return TranslateInternalMmResult(Result
);
69 /* Set up our function table */
70 ZeroMemory(&FuncTable
, sizeof(MMFUNCTION_TABLE
));
71 FuncTable
.GetCapabilities
= FUNC_NAME(WdmAudGetCapabilities
);
72 FuncTable
.QueryWaveFormatSupport
= QueryWdmWaveDeviceFormatSupport
; //FIXME
73 FuncTable
.Open
= FUNC_NAME(WdmAudOpenSoundDevice
);
74 FuncTable
.Close
= FUNC_NAME(WdmAudCloseSoundDevice
);
75 FuncTable
.GetDeviceInterfaceString
= FUNC_NAME(WdmAudGetDeviceInterfaceString
);
77 if (DeviceType
== MIXER_DEVICE_TYPE
)
79 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
80 FuncTable
.QueryMixerInfo
= FUNC_NAME(WdmAudQueryMixerInfo
);
82 else if (DeviceType
== WAVE_IN_DEVICE_TYPE
|| DeviceType
== WAVE_OUT_DEVICE_TYPE
)
84 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetWaveDeviceFormat
);
85 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
86 FuncTable
.ResetStream
= FUNC_NAME(WdmAudResetStream
);
87 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
89 #ifndef USERMODE_MIXER
90 FuncTable
.CommitWaveBuffer
= FUNC_NAME(WdmAudCommitWaveBuffer
);
92 FuncTable
.CommitWaveBuffer
= WriteFileEx_Remixer
;
95 else if (DeviceType
== MIDI_IN_DEVICE_TYPE
|| DeviceType
== MIDI_OUT_DEVICE_TYPE
)
97 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
98 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
99 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
102 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
105 return MMSYSERR_NOERROR
;
125 SND_TRACE(L
"DRV_LOAD\n");
127 Result
= InitEntrypointMutexes();
129 if ( ! MMSUCCESS(Result
) )
132 Result
= FUNC_NAME(WdmAudOpenSoundDevice
)(NULL
, &Handle
);
134 if ( Result
!= MMSYSERR_NOERROR
)
136 SND_ERR(L
"Failed to open \\\\.\\wdmaud\n");
137 //UnlistAllSoundDevices();
142 /* Populate the device lists */
143 SND_TRACE(L
"Populating device lists\n");
144 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
145 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
146 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
147 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
148 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
149 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
151 SND_TRACE(L
"Initialisation complete\n");
158 SND_TRACE(L
"DRV_FREE\n");
160 FUNC_NAME(WdmAudCleanup
)();
162 /* TODO: Clean up the path names! */
163 UnlistAllSoundDevices();
165 CleanupEntrypointMutexes();
167 SND_TRACE(L
"Unfreed memory blocks: %d\n",
168 GetMemoryAllocationCount());
176 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
183 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
187 case DRV_QUERYCONFIGURE
:
189 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
196 SND_TRACE(L
"Unhandled message %d\n", Message
);
197 return DefDriverProc(DriverId
,
213 case DLL_PROCESS_ATTACH
:
214 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
216 case DLL_PROCESS_DETACH
:
217 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
219 case DLL_THREAD_ATTACH
:
220 SND_TRACE(L
"WDMAUD.DRV - Thread attached\n");
222 case DLL_THREAD_DETACH
:
223 SND_TRACE(L
"WDMAUD.DRV - Thread detached\n");