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
;
115 //SND_TRACE(L"DRV_LOAD\n");
117 Result
= InitEntrypointMutexes();
119 if ( ! MMSUCCESS(Result
) )
122 Result
= WdmAudOpenSoundDeviceByMMixer();
124 if ( Result
!= MMSYSERR_NOERROR
)
126 SND_ERR(L
"Failed to initialize MMixer Library");
127 //UnlistAllSoundDevices();
132 /* Populate the device lists */
133 //SND_TRACE(L"Populating device lists\n");
134 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE
);
135 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE
);
136 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE
);
137 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE
);
138 PopulateWdmDeviceList(AUX_DEVICE_TYPE
);
139 PopulateWdmDeviceList(MIXER_DEVICE_TYPE
);
141 //SND_TRACE(L"Initialisation complete\n");
148 SND_TRACE(L
"DRV_FREE\n");
150 WdmAudCleanupByMMixer();
152 /* TODO: Clean up the path names! */
153 UnlistAllSoundDevices();
155 CleanupEntrypointMutexes();
157 SND_TRACE(L
"Unfreed memory blocks: %d\n",
158 GetMemoryAllocationCount());
166 //SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
173 //SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
177 case DRV_QUERYCONFIGURE
:
179 SND_TRACE(L
"DRV_QUERYCONFIGURE\n");
186 SND_TRACE(L
"Unhandled message %d\n", Message
);
187 return DefDriverProc(DriverId
,
203 case DLL_PROCESS_ATTACH
:
204 SND_TRACE(L
"WDMAUD.DRV - Process attached\n");
206 case DLL_PROCESS_DETACH
:
207 SND_TRACE(L
"WDMAUD.DRV - Process detached\n");
209 case DLL_THREAD_ATTACH
:
210 SND_TRACE(L
"WDMAUD.DRV - Thread attached\n");
212 case DLL_THREAD_DETACH
:
213 SND_TRACE(L
"WDMAUD.DRV - Thread detached\n");