Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencontrol.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: lib/drivers/sound/mment4/control.c 00005 * 00006 * PURPOSE: Device control for NT4 audio devices 00007 * 00008 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) 00009 */ 00010 00011 #define NDEBUG 00012 #include "precomp.h" 00013 00014 /* 00015 Convenience routine for getting the path of a device and opening it. 00016 */ 00017 MMRESULT 00018 OpenNt4KernelSoundDevice( 00019 IN PSOUND_DEVICE SoundDevice, 00020 IN BOOLEAN ReadOnly, 00021 OUT PHANDLE Handle) 00022 { 00023 PWSTR Path; 00024 MMRESULT Result; 00025 00026 VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); 00027 VALIDATE_MMSYS_PARAMETER( Handle ); 00028 00029 Result = GetSoundDeviceIdentifier(SoundDevice, (PVOID*) &Path); 00030 if ( ! MMSUCCESS(Result) ) 00031 { 00032 SND_ERR(L"Unable to get sound device path"); 00033 return TranslateInternalMmResult(Result); 00034 } 00035 00036 SND_ASSERT( Path ); 00037 00038 return OpenKernelSoundDeviceByName(Path, ReadOnly, Handle); 00039 } 00040 00041 /* 00042 Device open/close. These are basically wrappers for the MME-Buddy 00043 open and close routines, which provide a Windows device handle. 00044 These may seem simple but as you can return pretty much anything 00045 as the handle, we could just as easily return a structure etc. 00046 */ 00047 MMRESULT 00048 OpenNt4SoundDevice( 00049 IN PSOUND_DEVICE SoundDevice, 00050 OUT PVOID* Handle) 00051 { 00052 SND_TRACE(L"Opening NT4 style sound device\n"); 00053 00054 VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); 00055 VALIDATE_MMSYS_PARAMETER( Handle ); 00056 00057 return OpenNt4KernelSoundDevice(SoundDevice, FALSE, Handle); 00058 } 00059 00060 MMRESULT 00061 CloseNt4SoundDevice( 00062 IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, 00063 IN PVOID Handle) 00064 { 00065 SND_TRACE(L"Closing NT4 style sound device\n"); 00066 00067 VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) ); 00068 return CloseKernelSoundDevice((HANDLE) Handle); 00069 } 00070 00071 /* 00072 Provides an implementation for the "get capabilities" request, 00073 using the standard IOCTLs used by NT4 sound drivers. 00074 */ 00075 MMRESULT 00076 GetNt4SoundDeviceCapabilities( 00077 IN PSOUND_DEVICE SoundDevice, 00078 OUT PVOID Capabilities, 00079 IN DWORD CapabilitiesSize) 00080 { 00081 MMRESULT Result; 00082 MMDEVICE_TYPE DeviceType; 00083 DWORD IoCtl; 00084 HANDLE DeviceHandle; 00085 00086 /* If these are bad there's an internal error with MME-Buddy! */ 00087 SND_ASSERT( SoundDevice ); 00088 SND_ASSERT( Capabilities ); 00089 SND_ASSERT( CapabilitiesSize > 0 ); 00090 00091 SND_TRACE(L"NT4 get-capabilities routine called\n"); 00092 00093 /* Get the device type */ 00094 Result = GetSoundDeviceType(SoundDevice, &DeviceType); 00095 SND_ASSERT( Result == MMSYSERR_NOERROR ); 00096 00097 if ( ! MMSUCCESS(Result) ) 00098 return TranslateInternalMmResult(Result); 00099 00100 /* Choose the appropriate IOCTL */ 00101 if ( IS_WAVE_DEVICE_TYPE(DeviceType) ) 00102 { 00103 IoCtl = IOCTL_WAVE_GET_CAPABILITIES; 00104 } 00105 else if ( IS_MIDI_DEVICE_TYPE(DeviceType) ) 00106 { 00107 IoCtl = IOCTL_MIDI_GET_CAPABILITIES; 00108 } 00109 else 00110 { 00111 /* FIXME - need to support AUX and mixer devices */ 00112 SND_ASSERT( FALSE ); 00113 IoCtl = 0; 00114 } 00115 00116 /* Get the capabilities information from the driver */ 00117 Result = OpenNt4KernelSoundDevice(SoundDevice, TRUE, &DeviceHandle); 00118 00119 if ( ! MMSUCCESS(Result) ) 00120 { 00121 SND_ERR(L"Failed to open device"); 00122 return TranslateInternalMmResult(Result); 00123 } 00124 00125 Result = SyncOverlappedDeviceIoControl(DeviceHandle, 00126 IoCtl, 00127 Capabilities, 00128 CapabilitiesSize, 00129 NULL, 00130 0, 00131 NULL); 00132 00133 CloseKernelSoundDevice(DeviceHandle); 00134 00135 if ( ! MMSUCCESS(Result) ) 00136 { 00137 SND_ERR(L"Retrieval of capabilities information failed\n"); 00138 Result = TranslateInternalMmResult(Result); 00139 } 00140 00141 return Result; 00142 } 00143 00144 /* 00145 Querying/setting the format of a wave device. Querying format support 00146 requires us to first open the device, whereas setting format is done 00147 on an already opened device. 00148 */ 00149 MMRESULT 00150 QueryNt4WaveDeviceFormatSupport( 00151 IN PSOUND_DEVICE SoundDevice, 00152 IN LPWAVEFORMATEX Format, 00153 IN DWORD FormatSize) 00154 { 00155 MMRESULT Result; 00156 HANDLE Handle; 00157 00158 SND_TRACE(L"NT4 wave format support querying routine called\n"); 00159 00160 VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) ); 00161 VALIDATE_MMSYS_PARAMETER( Format ); 00162 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) ); 00163 00164 /* Get the device path */ 00165 Result = OpenNt4KernelSoundDevice(SoundDevice, 00166 FALSE, 00167 &Handle); 00168 00169 if ( ! MMSUCCESS(Result) ) 00170 { 00171 SND_ERR(L"Unable to open kernel sound device\n"); 00172 return TranslateInternalMmResult(Result); 00173 } 00174 00175 Result = SyncOverlappedDeviceIoControl(Handle, 00176 IOCTL_WAVE_QUERY_FORMAT, 00177 (LPVOID) Format, 00178 FormatSize, 00179 NULL, 00180 0, 00181 NULL); 00182 00183 if ( ! MMSUCCESS(Result) ) 00184 { 00185 SND_ERR(L"Sync overlapped I/O failed - MMSYS_ERROR %d\n", Result); 00186 Result = TranslateInternalMmResult(Result); 00187 } 00188 00189 CloseKernelSoundDevice(Handle); 00190 00191 return MMSYSERR_NOERROR; 00192 } 00193 00194 MMRESULT 00195 SetNt4WaveDeviceFormat( 00196 IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, 00197 IN DWORD DeviceId, 00198 IN LPWAVEFORMATEX Format, 00199 IN DWORD FormatSize) 00200 { 00201 MMRESULT Result; 00202 HANDLE Handle; 00203 00204 VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceInstance(SoundDeviceInstance) ); 00205 VALIDATE_MMSYS_PARAMETER( Format ); 00206 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) ); 00207 00208 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle); 00209 00210 if ( ! MMSUCCESS(Result) ) 00211 return TranslateInternalMmResult(Result); 00212 00213 SND_TRACE(L"Setting wave device format on handle %x\n", Handle); 00214 00215 Result = SyncOverlappedDeviceIoControl(Handle, 00216 IOCTL_WAVE_SET_FORMAT, 00217 (LPVOID) Format, 00218 FormatSize, 00219 NULL, 00220 0, 00221 NULL); 00222 00223 if ( ! MMSUCCESS(Result) ) 00224 return TranslateInternalMmResult(Result); 00225 00226 return MMSYSERR_NOERROR; 00227 } 00228 00229 #if 0 00230 MMRESULT 00231 SubmitNt4WaveHeader( 00232 IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, 00233 IN PWAVEHDR WaveHeader) 00234 { 00235 VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance ); 00236 VALIDATE_MMSYS_PARAMETER( WaveHeader ); 00237 00238 SND_TRACE(L"Submitting wave header %p (in sound thread)\n", WaveHeader); 00239 00240 /* TODO: This should only submit the header to the device, nothing more! */ 00241 } 00242 #endif Generated on Sat May 26 2012 04:15:35 for ReactOS by
1.7.6.1
|