Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwdmaud.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Sound System 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: dll/win32/wdmaud.drv/wdmaud.c 00005 * 00006 * PURPOSE: WDM Audio Driver (User-mode part) 00007 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) 00008 * 00009 * NOTES: Looking for wodMessage & co? You won't find them here. Try 00010 * the MME Buddy library, which is where these routines are 00011 * actually implemented. 00012 * 00013 */ 00014 00015 #include "wdmaud.h" 00016 00017 00018 #ifndef USE_MMIXER_LIB 00019 #define FUNC_NAME(x) x##ByLegacy 00020 #else 00021 #define FUNC_NAME(x) x##ByMMixer 00022 #endif 00023 00024 MMRESULT 00025 QueryWdmWaveDeviceFormatSupport( 00026 IN PSOUND_DEVICE Device, 00027 IN PWAVEFORMATEX WaveFormat, 00028 IN DWORD WaveFormatSize) 00029 { 00030 /* Whatever... */ 00031 return MMSYSERR_NOERROR; 00032 } 00033 00034 MMRESULT 00035 PopulateWdmDeviceList( 00036 MMDEVICE_TYPE DeviceType) 00037 { 00038 MMRESULT Result; 00039 DWORD DeviceCount = 0; 00040 PSOUND_DEVICE SoundDevice = NULL; 00041 MMFUNCTION_TABLE FuncTable; 00042 DWORD i; 00043 00044 VALIDATE_MMSYS_PARAMETER( IS_VALID_SOUND_DEVICE_TYPE(DeviceType) ); 00045 00046 Result = FUNC_NAME(WdmAudGetNumWdmDevs)(DeviceType, &DeviceCount); 00047 00048 if ( ! MMSUCCESS(Result) ) 00049 { 00050 SND_ERR(L"Error %d while obtaining number of devices\n", Result); 00051 return TranslateInternalMmResult(Result); 00052 } 00053 00054 SND_TRACE(L"%d devices of type %d found\n", DeviceCount, DeviceType); 00055 00056 00057 for ( i = 0; i < DeviceCount; ++ i ) 00058 { 00059 Result = ListSoundDevice(DeviceType, UlongToPtr(i), &SoundDevice); 00060 00061 if ( ! MMSUCCESS(Result) ) 00062 { 00063 SND_ERR(L"Failed to list sound device - error %d\n", Result); 00064 return TranslateInternalMmResult(Result); 00065 } 00066 00067 /* Set up our function table */ 00068 ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE)); 00069 FuncTable.GetCapabilities = FUNC_NAME(WdmAudGetCapabilities); 00070 FuncTable.QueryWaveFormatSupport = QueryWdmWaveDeviceFormatSupport; //FIXME 00071 FuncTable.Open = FUNC_NAME(WdmAudOpenSoundDevice); 00072 FuncTable.Close = FUNC_NAME(WdmAudCloseSoundDevice); 00073 FuncTable.GetDeviceInterfaceString = FUNC_NAME(WdmAudGetDeviceInterfaceString); 00074 00075 if (DeviceType == MIXER_DEVICE_TYPE) 00076 { 00077 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat); 00078 FuncTable.QueryMixerInfo = FUNC_NAME(WdmAudQueryMixerInfo); 00079 } 00080 else if (DeviceType == WAVE_IN_DEVICE_TYPE || DeviceType == WAVE_OUT_DEVICE_TYPE) 00081 { 00082 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetWaveDeviceFormat); 00083 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState); 00084 FuncTable.ResetStream = FUNC_NAME(WdmAudResetStream); 00085 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition); 00086 00087 #ifndef USERMODE_MIXER 00088 FuncTable.CommitWaveBuffer = FUNC_NAME(WdmAudCommitWaveBuffer); 00089 #else 00090 FuncTable.CommitWaveBuffer = WriteFileEx_Remixer; 00091 #endif 00092 } 00093 else if (DeviceType == MIDI_IN_DEVICE_TYPE || DeviceType == MIDI_OUT_DEVICE_TYPE) 00094 { 00095 FuncTable.SetWaveFormat = FUNC_NAME(WdmAudSetMixerDeviceFormat); 00096 FuncTable.SetState = FUNC_NAME(WdmAudSetWaveState); 00097 FuncTable.GetPos = FUNC_NAME(WdmAudGetWavePosition); 00098 } 00099 00100 SetSoundDeviceFunctionTable(SoundDevice, &FuncTable); 00101 } 00102 00103 return MMSYSERR_NOERROR; 00104 } 00105 00106 00107 00108 LONG 00109 APIENTRY 00110 DriverProc( 00111 DWORD DriverId, 00112 HANDLE DriverHandle, 00113 UINT Message, 00114 LONG Parameter1, 00115 LONG Parameter2) 00116 { 00117 switch ( Message ) 00118 { 00119 case DRV_LOAD : 00120 { 00121 HANDLE Handle; 00122 MMRESULT Result; 00123 SND_TRACE(L"DRV_LOAD\n"); 00124 00125 Result = InitEntrypointMutexes(); 00126 00127 if ( ! MMSUCCESS(Result) ) 00128 return 0L; 00129 00130 Result = FUNC_NAME(WdmAudOpenSoundDevice)(NULL, &Handle); 00131 00132 if ( Result != MMSYSERR_NOERROR ) 00133 { 00134 SND_ERR(L"Failed to open \\\\.\\wdmaud\n"); 00135 //UnlistAllSoundDevices(); 00136 00137 return 0L; 00138 } 00139 00140 /* Populate the device lists */ 00141 SND_TRACE(L"Populating device lists\n"); 00142 PopulateWdmDeviceList(WAVE_OUT_DEVICE_TYPE); 00143 PopulateWdmDeviceList(WAVE_IN_DEVICE_TYPE); 00144 PopulateWdmDeviceList(MIDI_OUT_DEVICE_TYPE); 00145 PopulateWdmDeviceList(MIDI_IN_DEVICE_TYPE); 00146 PopulateWdmDeviceList(AUX_DEVICE_TYPE); 00147 PopulateWdmDeviceList(MIXER_DEVICE_TYPE); 00148 00149 SND_TRACE(L"Initialisation complete\n"); 00150 00151 return 1L; 00152 } 00153 00154 case DRV_FREE : 00155 { 00156 SND_TRACE(L"DRV_FREE\n"); 00157 00158 FUNC_NAME(WdmAudCleanup)(); 00159 00160 /* TODO: Clean up the path names! */ 00161 UnlistAllSoundDevices(); 00162 00163 CleanupEntrypointMutexes(); 00164 00165 SND_TRACE(L"Unfreed memory blocks: %d\n", 00166 GetMemoryAllocationCount()); 00167 00168 return 1L; 00169 } 00170 00171 case DRV_ENABLE : 00172 case DRV_DISABLE : 00173 { 00174 SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n"); 00175 return 1L; 00176 } 00177 00178 case DRV_OPEN : 00179 case DRV_CLOSE : 00180 { 00181 SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n"); 00182 return 1L; 00183 } 00184 00185 case DRV_QUERYCONFIGURE : 00186 { 00187 SND_TRACE(L"DRV_QUERYCONFIGURE\n"); 00188 return 0L; 00189 } 00190 case DRV_CONFIGURE : 00191 return DRVCNF_OK; 00192 00193 default : 00194 SND_TRACE(L"Unhandled message %d\n", Message); 00195 return DefDriverProc(DriverId, 00196 DriverHandle, 00197 Message, 00198 Parameter1, 00199 Parameter2); 00200 } 00201 } 00202 00203 00204 BOOL WINAPI DllMain( 00205 HINSTANCE hinstDLL, 00206 DWORD fdwReason, 00207 LPVOID lpvReserved) 00208 { 00209 switch ( fdwReason ) 00210 { 00211 case DLL_PROCESS_ATTACH : 00212 SND_TRACE(L"WDMAUD.DRV - Process attached\n"); 00213 break; 00214 case DLL_PROCESS_DETACH : 00215 SND_TRACE(L"WDMAUD.DRV - Process detached\n"); 00216 break; 00217 case DLL_THREAD_ATTACH : 00218 SND_TRACE(L"WDMAUD.DRV - Thread attached\n"); 00219 break; 00220 case DLL_THREAD_DETACH : 00221 SND_TRACE(L"WDMAUD.DRV - Thread detached\n"); 00222 break; 00223 } 00224 00225 return TRUE; 00226 } Generated on Sun May 27 2012 04:26:52 for ReactOS by
1.7.6.1
|