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 QueryWdmWaveDeviceFormatSupport(
19 IN PSOUND_DEVICE Device
,
20 IN PWAVEFORMATEX WaveFormat
,
21 IN DWORD WaveFormatSize
)
24 return MMSYSERR_NOERROR
;
28 PopulateWdmDeviceList(
29 MMDEVICE_TYPE DeviceType
)
32 DWORD DeviceCount
= 0;
33 PSOUND_DEVICE SoundDevice
= NULL
;
34 MMFUNCTION_TABLE FuncTable
;
37 VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType
) );
39 Result
= WdmAudGetNumWdmDevsByMMixer(DeviceType
, &DeviceCount
);
41 if ( ! MMSUCCESS(Result
) )
43 SND_ERR(L
"Error %d while obtaining number of devices\n", Result
);
44 return TranslateInternalMmResult(Result
);
47 SND_TRACE(L
"%d devices of type %d found\n", DeviceCount
, DeviceType
);
50 for ( i
= 0; i
< DeviceCount
; ++ i
)
52 Result
= ListSoundDevice(DeviceType
, UlongToPtr(i
), &SoundDevice
);
54 if ( ! MMSUCCESS(Result
) )
56 SND_ERR(L
"Failed to list sound device - error %d\n", Result
);
57 return TranslateInternalMmResult(Result
);
60 /* Set up our function table */
61 ZeroMemory(&FuncTable
, sizeof(MMFUNCTION_TABLE
));
62 FuncTable
.GetCapabilities
= WdmAudGetCapabilitiesByMMixer
;
63 FuncTable
.QueryWaveFormatSupport
= QueryWdmWaveDeviceFormatSupport
; //FIXME
64 FuncTable
.Open
= WdmAudOpenSoundDeviceByMMixer
;
65 FuncTable
.Close
= WdmAudCloseSoundDeviceByMMixer
;
66 FuncTable
.GetDeviceInterfaceString
= WdmAudGetDeviceInterfaceStringByMMixer
;
68 if (DeviceType
== MIXER_DEVICE_TYPE
)
70 FuncTable
.SetWaveFormat
= WdmAudSetMixerDeviceFormatByMMixer
;
71 FuncTable
.QueryMixerInfo
= WdmAudQueryMixerInfoByMMixer
;
73 else if (DeviceType
== WAVE_IN_DEVICE_TYPE
|| DeviceType
== WAVE_OUT_DEVICE_TYPE
)
75 FuncTable
.SetWaveFormat
= WdmAudSetWaveDeviceFormatByMMixer
;
76 FuncTable
.SetState
= WdmAudSetWaveStateByMMixer
;
77 FuncTable
.ResetStream
= WdmAudResetStreamByMMixer
;
78 FuncTable
.GetPos
= WdmAudGetWavePositionByMMixer
;
80 #ifndef USERMODE_MIXER
81 FuncTable
.CommitWaveBuffer
= WdmAudCommitWaveBufferByMMixer
;
83 FuncTable
.CommitWaveBuffer
= WriteFileEx_Remixer
;
86 else if (DeviceType
== MIDI_IN_DEVICE_TYPE
|| DeviceType
== MIDI_OUT_DEVICE_TYPE
)
88 FuncTable
.SetWaveFormat
= WdmAudSetWaveDeviceFormatByMMixer
;
89 FuncTable
.SetState
= WdmAudSetWaveStateByMMixer
;
90 FuncTable
.GetPos
= WdmAudGetWavePositionByMMixer
;
93 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
96 return MMSYSERR_NOERROR
;
116 SND_TRACE(L
"DRV_LOAD\n");
118 Result
= InitEntrypointMutexes();
120 if ( ! MMSUCCESS(Result
) )
123 Result
= WdmAudOpenSoundDeviceByMMixer(NULL
, &Handle
);
125 if ( Result
!= MMSYSERR_NOERROR
)
127 SND_ERR(L
"Failed to open \\\\.\\wdmaud\n");
128 //UnlistAllSoundDevices();
133 /* Populate the device lists */
134 SND_TRACE(L
"Populating device lists\n");
135 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
136 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
137 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
138 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
139 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
140 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
142 SND_TRACE(L
"Initialisation complete\n");
149 SND_TRACE(L
"DRV_FREE\n");
151 WdmAudCleanupByMMixer();
153 /* TODO: Clean up the path names! */
154 UnlistAllSoundDevices();
156 CleanupEntrypointMutexes();
158 SND_TRACE(L
"Unfreed memory blocks: %d\n",
159 GetMemoryAllocationCount());
167 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
174 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
178 case DRV_QUERYCONFIGURE
:
180 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
187 SND_TRACE(L
"Unhandled message %d\n", Message
);
188 return DefDriverProc(DriverId
,
204 case DLL_PROCESS_ATTACH
:
205 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
207 case DLL_PROCESS_DETACH
:
208 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
210 case DLL_THREAD_ATTACH
:
211 //SND_TRACE(L"WDMAUD.DRV - Thread attached\n");
213 case DLL_THREAD_DETACH
:
214 //SND_TRACE(L"WDMAUD.DRV - Thread detached\n");