ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

sndblst.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/sndblst/sndblst.c
00005  *
00006  * PURPOSE:     Sound Blaster MME User-Mode Driver
00007  *
00008  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
00009  *
00010  * NOTES:       Currently very experimental and being used as a guinea-pig for
00011  *              changes to the MME-Buddy libraries.
00012  *              TODO: Adhere to maximum device name length!
00013 */
00014 
00015 #include <windows.h>
00016 #include <ntddsnd.h>
00017 #include <sndtypes.h>
00018 #include <mmddk.h>
00019 #include <mmebuddy.h>
00020 #include <mment4.h>
00021 //#include <debug.h>
00022 
00023 /* TODO: Give individual device names if someone has > 1 card */
00024 PWSTR SBWaveOutDeviceName = L"ROS Sound Blaster Wave Out";
00025 PWSTR SBWaveInDeviceName  = L"ROS Sound Blaster Wave In";
00026 PWSTR SBMidiOutDeviceName = L"ROS Sound Blaster Midi Out";
00027 PWSTR SBMidiInDeviceName  = L"ROS Sound Blaster Midi In";
00028 PWSTR SBAuxDeviceName     = L"ROS Sound Blaster Aux";
00029 PWSTR SBMixerDeviceName   = L"ROS Sound Blaster Mixer";
00030 /* TODO: Mixer etc */
00031 
00032 MMRESULT
00033 GetSoundBlasterDeviceCapabilities(
00034     IN  PSOUND_DEVICE SoundDevice,
00035     IN  DWORD DeviceId,
00036     OUT PVOID Capabilities,
00037     IN  DWORD CapabilitiesSize)
00038 {
00039     MMRESULT Result;
00040     MMDEVICE_TYPE DeviceType;
00041 
00042     SND_ASSERT( SoundDevice );
00043     SND_ASSERT( Capabilities );
00044 
00045     SND_TRACE(L"Sndblst - GetSoundBlasterDeviceCapabilities\n");
00046 
00047     Result = GetSoundDeviceType(SoundDevice, &DeviceType);
00048     SND_ASSERT( Result == MMSYSERR_NOERROR );
00049 
00050     /* Use the default method of obtaining device capabilities */
00051     Result = GetNt4SoundDeviceCapabilities(SoundDevice,
00052                                            Capabilities,
00053                                            CapabilitiesSize);
00054 
00055     if ( ! MMSUCCESS(Result) )
00056         return Result;
00057 
00058     /* Inject the appropriate device name */
00059     switch ( DeviceType )
00060     {
00061         case WAVE_OUT_DEVICE_TYPE :
00062         {
00063             LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities;
00064             CopyWideString(WaveOutCaps->szPname, SBWaveOutDeviceName);
00065             break;
00066         }
00067         case WAVE_IN_DEVICE_TYPE :
00068         {
00069             LPWAVEINCAPS WaveInCaps = (LPWAVEINCAPS) Capabilities;
00070             CopyWideString(WaveInCaps->szPname, SBWaveInDeviceName);
00071             break;
00072         }
00073         case MIDI_OUT_DEVICE_TYPE :
00074         {
00075             LPMIDIOUTCAPS MidiOutCaps = (LPMIDIOUTCAPS) Capabilities;
00076             CopyWideString(MidiOutCaps->szPname, SBMidiOutDeviceName);
00077             break;
00078         }
00079         case MIDI_IN_DEVICE_TYPE :
00080         {
00081             LPMIDIINCAPS MidiInCaps = (LPMIDIINCAPS) Capabilities;
00082             CopyWideString(MidiInCaps->szPname, SBMidiInDeviceName);
00083             break;
00084         }
00085         case AUX_DEVICE_TYPE :
00086         {
00087             LPAUXCAPS AuxCaps = (LPAUXCAPS) Capabilities;
00088             CopyWideString(AuxCaps->szPname, SBAuxDeviceName);
00089             break;
00090         }
00091         case MIXER_DEVICE_TYPE :
00092         {
00093             LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities;
00094             CopyWideString(MixerCaps->szPname, SBMixerDeviceName);
00095             break;
00096         }
00097     }
00098 
00099     return MMSYSERR_NOERROR;
00100 }
00101 
00102 BOOLEAN FoundDevice(
00103     UCHAR DeviceType,
00104     PWSTR DevicePath)
00105 {
00106     MMRESULT Result;
00107     PSOUND_DEVICE SoundDevice = NULL;
00108     MMFUNCTION_TABLE FuncTable;
00109     PWSTR PathCopy;
00110 
00111     SND_TRACE(L"(Callback) Found device: %wS\n", DevicePath);
00112 
00113     PathCopy = AllocateWideString(wcslen(DevicePath));
00114 
00115     if ( ! PathCopy )
00116         return FALSE;
00117 
00118     CopyWideString(PathCopy, DevicePath);
00119 
00120     Result = ListSoundDevice(DeviceType, (PVOID) PathCopy, &SoundDevice);
00121 
00122     if ( ! MMSUCCESS(Result) )
00123         return FALSE;
00124 
00125     /* Set up our function table */
00126     ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
00127     FuncTable.GetCapabilities = GetSoundBlasterDeviceCapabilities;
00128     FuncTable.QueryWaveFormatSupport = QueryNt4WaveDeviceFormatSupport;
00129     FuncTable.SetWaveFormat = SetNt4WaveDeviceFormat;
00130     FuncTable.Open = OpenNt4SoundDevice;
00131     FuncTable.Close = CloseNt4SoundDevice;
00132     FuncTable.CommitWaveBuffer = WriteFileEx_Committer;
00133     //FuncTable.SubmitWaveHeaderToDevice = SubmitWaveHeaderToDevice;
00134 
00135     SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
00136 
00137     return TRUE;
00138 }
00139 
00140 LONG APIENTRY
00141 DriverProc(
00142     DWORD DriverId,
00143     HANDLE DriverHandle,
00144     UINT Message,
00145     LONG Parameter1,
00146     LONG Parameter2)
00147 {
00148     MMRESULT Result;
00149 
00150     switch ( Message )
00151     {
00152         case DRV_LOAD :
00153         {
00154             SND_TRACE(L"DRV_LOAD\n");
00155 
00156             Result = InitEntrypointMutexes();
00157 
00158             if ( ! MMSUCCESS(Result) )
00159                 return 0L;
00160 
00161             Result = EnumerateNt4ServiceSoundDevices(L"sndblst",
00162                                                      0,
00163                                                      FoundDevice);
00164 
00165             if ( ! MMSUCCESS(Result) )
00166             {
00167                 CleanupEntrypointMutexes();
00168 
00169                 UnlistAllSoundDevices();
00170 
00171                 return 0L;
00172             }
00173 
00174 /*
00175             PSOUND_DEVICE snd;
00176             GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &snd);
00177             GetSoundDevice(AUX_DEVICE_TYPE, 0, &snd);
00178             GetSoundDevice(AUX_DEVICE_TYPE, 1, &snd);
00179             GetSoundDevice(AUX_DEVICE_TYPE, 2, &snd);
00180 */
00181 
00182             SND_TRACE(L"Initialisation complete\n");
00183 
00184             return 1L;
00185         }
00186 
00187         case DRV_FREE :
00188         {
00189             SND_TRACE(L"DRV_FREE\n");
00190 
00191             /* TODO: Clean up the path names! */
00192             UnlistAllSoundDevices();
00193 
00194             CleanupEntrypointMutexes();
00195 
00196             SND_TRACE(L"Unfreed memory blocks: %d\n",
00197                       GetMemoryAllocationCount());
00198 
00199             return 1L;
00200         }
00201 
00202         case DRV_ENABLE :
00203         case DRV_DISABLE :
00204         {
00205             SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
00206             return 1L;
00207         }
00208 
00209         case DRV_OPEN :
00210         case DRV_CLOSE :
00211         {
00212             SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
00213             return 1L;
00214         }
00215 
00216         case DRV_QUERYCONFIGURE :
00217         {
00218             SND_TRACE(L"DRV_QUERYCONFIGURE");
00219             return 0L;
00220         }
00221         case DRV_CONFIGURE :
00222             return DRVCNF_OK;
00223 
00224         default :
00225             SND_TRACE(L"Unhandled message %d\n", Message);
00226             return DefDriverProc(DriverId,
00227                                  DriverHandle,
00228                                  Message,
00229                                  Parameter1,
00230                                  Parameter2);
00231     }
00232 }
00233 
00234 BOOL WINAPI DllMain(
00235     HINSTANCE hinstDLL,
00236     DWORD fdwReason,
00237     LPVOID lpvReserved)
00238 {
00239     switch ( fdwReason )
00240     {
00241         case DLL_PROCESS_ATTACH :
00242             SND_TRACE(L"DLL_PROCESS_ATTACH\n");
00243             break;
00244         case DLL_PROCESS_DETACH :
00245             SND_TRACE(L"DLL_PROCESS_DETACH\n");
00246             break;
00247         case DLL_THREAD_ATTACH :
00248             SND_TRACE(L"DLL_THREAD_ATTACH\n");
00249             break;
00250         case DLL_THREAD_DETACH :
00251             SND_TRACE(L"DLL_THREAD_DETACH\n");
00252             break;
00253     }
00254 
00255     return TRUE;
00256 }

Generated on Sat May 26 2012 04:25:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.