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.
18 #ifndef USE_MMIXER_LIB
19 #define FUNC_NAME(x) x##ByLegacy
21 #define FUNC_NAME(x) x##ByMMixer
25 QueryWdmWaveDeviceFormatSupport(
26 IN PSOUND_DEVICE Device
,
27 IN PWAVEFORMATEX WaveFormat
,
28 IN DWORD WaveFormatSize
)
31 return MMSYSERR_NOERROR
;
35 PopulateWdmDeviceList(
36 MMDEVICE_TYPE DeviceType
)
39 DWORD DeviceCount
= 0;
40 PSOUND_DEVICE SoundDevice
= NULL
;
41 MMFUNCTION_TABLE FuncTable
;
44 VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType
) );
46 Result
= FUNC_NAME(WdmAudGetNumWdmDevs
)(DeviceType
, &DeviceCount
);
48 if ( ! MMSUCCESS(Result
) )
50 SND_ERR(L
"Error %d while obtaining number of devices\n", Result
);
51 return TranslateInternalMmResult(Result
);
54 SND_TRACE(L
"%d devices of type %d found\n", DeviceCount
, DeviceType
);
57 for ( i
= 0; i
< DeviceCount
; ++ i
)
59 Result
= ListSoundDevice(DeviceType
, UlongToPtr(i
), &SoundDevice
);
61 if ( ! MMSUCCESS(Result
) )
63 SND_ERR(L
"Failed to list sound device - error %d\n", Result
);
64 return TranslateInternalMmResult(Result
);
67 /* Set up our function table */
68 ZeroMemory(&FuncTable
, sizeof(MMFUNCTION_TABLE
));
69 FuncTable
.GetCapabilities
= FUNC_NAME(WdmAudGetCapabilities
);
70 FuncTable
.QueryWaveFormatSupport
= QueryWdmWaveDeviceFormatSupport
; //FIXME
71 FuncTable
.Open
= FUNC_NAME(WdmAudOpenSoundDevice
);
72 FuncTable
.Close
= FUNC_NAME(WdmAudCloseSoundDevice
);
73 FuncTable
.GetDeviceInterfaceString
= FUNC_NAME(WdmAudGetDeviceInterfaceString
);
75 if (DeviceType
== MIXER_DEVICE_TYPE
)
77 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
78 FuncTable
.QueryMixerInfo
= FUNC_NAME(WdmAudQueryMixerInfo
);
80 else if (DeviceType
== WAVE_IN_DEVICE_TYPE
|| DeviceType
== WAVE_OUT_DEVICE_TYPE
)
82 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetWaveDeviceFormat
);
83 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
84 FuncTable
.ResetStream
= FUNC_NAME(WdmAudResetStream
);
85 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
87 #ifndef USERMODE_MIXER
88 FuncTable
.CommitWaveBuffer
= FUNC_NAME(WdmAudCommitWaveBuffer
);
90 FuncTable
.CommitWaveBuffer
= WriteFileEx_Remixer
;
93 else if (DeviceType
== MIDI_IN_DEVICE_TYPE
|| DeviceType
== MIDI_OUT_DEVICE_TYPE
)
95 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
96 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
97 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
100 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
103 return MMSYSERR_NOERROR
;
123 SND_TRACE(L
"DRV_LOAD\n");
125 Result
= InitEntrypointMutexes();
127 if ( ! MMSUCCESS(Result
) )
130 Result
= FUNC_NAME(WdmAudOpenSoundDevice
)(NULL
, &Handle
);
132 if ( Result
!= MMSYSERR_NOERROR
)
134 SND_ERR(L
"Failed to open \\\\.\\wdmaud\n");
135 //UnlistAllSoundDevices();
140 /* Populate the device lists */
141 SND_TRACE(L
"Populating device lists\n");
142 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
143 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
144 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
145 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
146 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
147 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
149 SND_TRACE(L
"Initialisation complete\n");
156 SND_TRACE(L
"DRV_FREE\n");
158 FUNC_NAME(WdmAudCleanup
)();
160 /* TODO: Clean up the path names! */
161 UnlistAllSoundDevices();
163 CleanupEntrypointMutexes();
165 SND_TRACE(L
"Unfreed memory blocks: %d\n",
166 GetMemoryAllocationCount());
174 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
181 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
185 case DRV_QUERYCONFIGURE
:
187 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
194 SND_TRACE(L
"Unhandled message %d\n", Message
);
195 return DefDriverProc(DriverId
,
211 case DLL_PROCESS_ATTACH
:
212 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
214 case DLL_PROCESS_DETACH
:
215 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
217 case DLL_THREAD_ATTACH
:
218 SND_TRACE(L
"WDMAUD.DRV - Thread attached\n");
220 case DLL_THREAD_DETACH
:
221 SND_TRACE(L
"WDMAUD.DRV - Thread detached\n");