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
;
94 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
97 return MMSYSERR_NOERROR
;
117 SND_TRACE(L
"DRV_LOAD\n");
119 Result
= InitEntrypointMutexes();
121 if ( ! MMSUCCESS(Result
) )
124 Result
= FUNC_NAME(WdmAudOpenSoundDevice
)(NULL
, &Handle
);
126 if ( Result
!= MMSYSERR_NOERROR
)
128 SND_ERR(L
"Failed to open \\\\.\\wdmaud\n");
129 //UnlistAllSoundDevices();
134 /* Populate the device lists */
135 SND_TRACE(L
"Populating device lists\n");
136 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
137 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
138 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
139 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
140 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
141 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
143 SND_TRACE(L
"Initialisation complete\n");
150 SND_TRACE(L
"DRV_FREE\n");
152 FUNC_NAME(WdmAudCleanup
)();
154 /* TODO: Clean up the path names! */
155 UnlistAllSoundDevices();
157 CleanupEntrypointMutexes();
159 SND_TRACE(L
"Unfreed memory blocks: %d\n",
160 GetMemoryAllocationCount());
168 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
175 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
179 case DRV_QUERYCONFIGURE
:
181 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
188 SND_TRACE(L
"Unhandled message %d\n", Message
);
189 return DefDriverProc(DriverId
,
205 case DLL_PROCESS_ATTACH
:
206 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
208 case DLL_PROCESS_DETACH
:
209 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
211 case DLL_THREAD_ATTACH
:
212 SND_TRACE(L
"WDMAUD.DRV - Thread attached\n");
214 case DLL_THREAD_DETACH
:
215 SND_TRACE(L
"WDMAUD.DRV - Thread detached\n");