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.
19 #include <mmebuddy_debug.h>
21 #define USE_MMIXER_LIB
22 #ifndef USE_MMIXER_LIB
23 #define FUNC_NAME(x) x##ByLegacy
25 #define FUNC_NAME(x) x##ByMMixer
29 QueryWdmWaveDeviceFormatSupport(
30 IN PSOUND_DEVICE Device
,
31 IN PWAVEFORMATEX WaveFormat
,
32 IN DWORD WaveFormatSize
)
35 return MMSYSERR_NOERROR
;
39 PopulateWdmDeviceList(
40 MMDEVICE_TYPE DeviceType
)
43 DWORD DeviceCount
= 0;
44 PSOUND_DEVICE SoundDevice
= NULL
;
45 MMFUNCTION_TABLE FuncTable
;
48 VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType
) );
50 Result
= FUNC_NAME(WdmAudGetNumWdmDevs
)(DeviceType
, &DeviceCount
);
52 if ( ! MMSUCCESS(Result
) )
54 SND_ERR(L
"Error %d while obtaining number of devices\n", Result
);
55 return TranslateInternalMmResult(Result
);
58 SND_TRACE(L
"%d devices of type %d found\n", DeviceCount
, DeviceType
);
61 for ( i
= 0; i
< DeviceCount
; ++ i
)
63 Result
= ListSoundDevice(DeviceType
, UlongToPtr(i
), &SoundDevice
);
65 if ( ! MMSUCCESS(Result
) )
67 SND_ERR(L
"Failed to list sound device - error %d\n", Result
);
68 return TranslateInternalMmResult(Result
);
71 /* Set up our function table */
72 ZeroMemory(&FuncTable
, sizeof(MMFUNCTION_TABLE
));
73 FuncTable
.GetCapabilities
= FUNC_NAME(WdmAudGetCapabilities
);
74 FuncTable
.QueryWaveFormatSupport
= QueryWdmWaveDeviceFormatSupport
; //FIXME
75 FuncTable
.Open
= FUNC_NAME(WdmAudOpenSoundDevice
);
76 FuncTable
.Close
= FUNC_NAME(WdmAudCloseSoundDevice
);
77 FuncTable
.GetDeviceInterfaceString
= FUNC_NAME(WdmAudGetDeviceInterfaceString
);
79 if (DeviceType
== MIXER_DEVICE_TYPE
)
81 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
82 FuncTable
.QueryMixerInfo
= FUNC_NAME(WdmAudQueryMixerInfo
);
84 else if (DeviceType
== WAVE_IN_DEVICE_TYPE
|| DeviceType
== WAVE_OUT_DEVICE_TYPE
)
86 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetWaveDeviceFormat
);
87 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
88 FuncTable
.ResetStream
= FUNC_NAME(WdmAudResetStream
);
89 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
91 #ifndef USERMODE_MIXER
92 FuncTable
.CommitWaveBuffer
= FUNC_NAME(WdmAudCommitWaveBuffer
);
94 FuncTable
.CommitWaveBuffer
= WriteFileEx_Remixer
;
97 else if (DeviceType
== MIDI_IN_DEVICE_TYPE
|| DeviceType
== MIDI_OUT_DEVICE_TYPE
)
99 FuncTable
.SetWaveFormat
= FUNC_NAME(WdmAudSetMixerDeviceFormat
);
100 FuncTable
.SetState
= FUNC_NAME(WdmAudSetWaveState
);
101 FuncTable
.GetPos
= FUNC_NAME(WdmAudGetWavePosition
);
104 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
107 return MMSYSERR_NOERROR
;
127 SND_TRACE(L
"DRV_LOAD\n");
129 Result
= InitEntrypointMutexes();
131 if ( ! MMSUCCESS(Result
) )
134 Result
= FUNC_NAME(WdmAudOpenSoundDevice
)(NULL
, &Handle
);
136 if ( Result
!= MMSYSERR_NOERROR
)
138 SND_ERR(L
"Failed to open \\\\.\\wdmaud\n");
139 //UnlistAllSoundDevices();
144 /* Populate the device lists */
145 SND_TRACE(L
"Populating device lists\n");
146 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
147 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
148 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
149 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
150 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
151 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
153 SND_TRACE(L
"Initialisation complete\n");
160 SND_TRACE(L
"DRV_FREE\n");
162 FUNC_NAME(WdmAudCleanup
)();
164 /* TODO: Clean up the path names! */
165 UnlistAllSoundDevices();
167 CleanupEntrypointMutexes();
169 SND_TRACE(L
"Unfreed memory blocks: %d\n",
170 GetMemoryAllocationCount());
178 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
185 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
189 case DRV_QUERYCONFIGURE
:
191 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
198 SND_TRACE(L
"Unhandled message %d\n", Message
);
199 return DefDriverProc(DriverId
,
215 case DLL_PROCESS_ATTACH
:
216 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
218 case DLL_PROCESS_DETACH
:
219 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
221 case DLL_THREAD_ATTACH
:
222 SND_TRACE(L
"WDMAUD.DRV - Thread attached\n");
224 case DLL_THREAD_DETACH
:
225 SND_TRACE(L
"WDMAUD.DRV - Thread detached\n");