2 * PROJECT: ReactOS Sound System
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/sndblst/sndblst.c
6 * PURPOSE: Sound Blaster MME User-Mode Driver
8 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
10 * NOTES: Currently very experimental and being used as a guinea-pig for
11 * changes to the MME-Buddy libraries.
12 * TODO: Adhere to maximum device name length!
15 #define WIN32_NO_STATUS
17 #define COM_NO_WINDOWS_H
24 //#include <ntddsnd.h>
29 #include <mmebuddy_debug.h>
32 /* TODO: Give individual device names if someone has > 1 card */
33 PWSTR SBWaveOutDeviceName
= L
"ROS Sound Blaster Wave Out";
34 PWSTR SBWaveInDeviceName
= L
"ROS Sound Blaster Wave In";
35 PWSTR SBMidiOutDeviceName
= L
"ROS Sound Blaster Midi Out";
36 PWSTR SBMidiInDeviceName
= L
"ROS Sound Blaster Midi In";
37 PWSTR SBAuxDeviceName
= L
"ROS Sound Blaster Aux";
38 PWSTR SBMixerDeviceName
= L
"ROS Sound Blaster Mixer";
42 GetSoundBlasterDeviceCapabilities(
43 IN PSOUND_DEVICE SoundDevice
,
45 OUT PVOID Capabilities
,
46 IN DWORD CapabilitiesSize
)
49 MMDEVICE_TYPE DeviceType
;
51 SND_ASSERT( SoundDevice
);
52 SND_ASSERT( Capabilities
);
54 SND_TRACE(L
"Sndblst - GetSoundBlasterDeviceCapabilities\n");
56 Result
= GetSoundDeviceType(SoundDevice
, &DeviceType
);
57 SND_ASSERT( Result
== MMSYSERR_NOERROR
);
59 /* Use the default method of obtaining device capabilities */
60 Result
= GetNt4SoundDeviceCapabilities(SoundDevice
,
64 if ( ! MMSUCCESS(Result
) )
67 /* Inject the appropriate device name */
70 case WAVE_OUT_DEVICE_TYPE
:
72 LPWAVEOUTCAPS WaveOutCaps
= (LPWAVEOUTCAPS
) Capabilities
;
73 CopyWideString(WaveOutCaps
->szPname
, SBWaveOutDeviceName
);
76 case WAVE_IN_DEVICE_TYPE
:
78 LPWAVEINCAPS WaveInCaps
= (LPWAVEINCAPS
) Capabilities
;
79 CopyWideString(WaveInCaps
->szPname
, SBWaveInDeviceName
);
82 case MIDI_OUT_DEVICE_TYPE
:
84 LPMIDIOUTCAPS MidiOutCaps
= (LPMIDIOUTCAPS
) Capabilities
;
85 CopyWideString(MidiOutCaps
->szPname
, SBMidiOutDeviceName
);
88 case MIDI_IN_DEVICE_TYPE
:
90 LPMIDIINCAPS MidiInCaps
= (LPMIDIINCAPS
) Capabilities
;
91 CopyWideString(MidiInCaps
->szPname
, SBMidiInDeviceName
);
94 case AUX_DEVICE_TYPE
:
96 LPAUXCAPS AuxCaps
= (LPAUXCAPS
) Capabilities
;
97 CopyWideString(AuxCaps
->szPname
, SBAuxDeviceName
);
100 case MIXER_DEVICE_TYPE
:
102 LPMIXERCAPS MixerCaps
= (LPMIXERCAPS
) Capabilities
;
103 CopyWideString(MixerCaps
->szPname
, SBMixerDeviceName
);
108 return MMSYSERR_NOERROR
;
116 PSOUND_DEVICE SoundDevice
= NULL
;
117 MMFUNCTION_TABLE FuncTable
;
120 SND_TRACE(L
"(Callback) Found device: %wS\n", DevicePath
);
122 PathCopy
= AllocateWideString(wcslen(DevicePath
));
127 CopyWideString(PathCopy
, DevicePath
);
129 Result
= ListSoundDevice(DeviceType
, (PVOID
) PathCopy
, &SoundDevice
);
131 if ( ! MMSUCCESS(Result
) )
134 /* Set up our function table */
135 ZeroMemory(&FuncTable
, sizeof(MMFUNCTION_TABLE
));
136 FuncTable
.GetCapabilities
= GetSoundBlasterDeviceCapabilities
;
137 FuncTable
.QueryWaveFormatSupport
= QueryNt4WaveDeviceFormatSupport
;
138 FuncTable
.SetWaveFormat
= SetNt4WaveDeviceFormat
;
139 FuncTable
.Open
= OpenNt4SoundDevice
;
140 FuncTable
.Close
= CloseNt4SoundDevice
;
141 FuncTable
.CommitWaveBuffer
= WriteFileEx_Committer
;
142 //FuncTable.SubmitWaveHeaderToDevice = SubmitWaveHeaderToDevice;
144 SetSoundDeviceFunctionTable(SoundDevice
, &FuncTable
);
163 SND_TRACE(L
"DRV_LOAD\n");
165 Result
= InitEntrypointMutexes();
167 if ( ! MMSUCCESS(Result
) )
170 Result
= EnumerateNt4ServiceSoundDevices(L
"sndblst",
174 if ( ! MMSUCCESS(Result
) )
176 CleanupEntrypointMutexes();
178 UnlistAllSoundDevices();
185 GetSoundDevice(WAVE_OUT_DEVICE_TYPE, 0, &snd);
186 GetSoundDevice(AUX_DEVICE_TYPE, 0, &snd);
187 GetSoundDevice(AUX_DEVICE_TYPE, 1, &snd);
188 GetSoundDevice(AUX_DEVICE_TYPE, 2, &snd);
191 SND_TRACE(L
"Initialisation complete\n");
198 SND_TRACE(L
"DRV_FREE\n");
200 /* TODO: Clean up the path names! */
201 UnlistAllSoundDevices();
203 CleanupEntrypointMutexes();
205 SND_TRACE(L
"Unfreed memory blocks: %d\n",
206 GetMemoryAllocationCount());
214 SND_TRACE(L
"DRV_ENABLE / DRV_DISABLE\n");
221 SND_TRACE(L
"DRV_OPEN / DRV_CLOSE\n");
225 case DRV_QUERYCONFIGURE
:
227 SND_TRACE(L
"DRV_QUERYCONFIGURE");
234 SND_TRACE(L
"Unhandled message %d\n", Message
);
235 return DefDriverProc(DriverId
,
250 case DLL_PROCESS_ATTACH
:
251 SND_TRACE(L
"DLL_PROCESS_ATTACH\n");
253 case DLL_PROCESS_DETACH
:
254 SND_TRACE(L
"DLL_PROCESS_DETACH\n");
256 case DLL_THREAD_ATTACH
:
257 SND_TRACE(L
"DLL_THREAD_ATTACH\n");
259 case DLL_THREAD_DETACH
:
260 SND_TRACE(L
"DLL_THREAD_DETACH\n");