ReactOS 0.4.16-dev-297-gc569aee
sndblst.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Sound System
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/sndblst/sndblst.c
5 *
6 * PURPOSE: Sound Blaster MME User-Mode Driver
7 *
8 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
9 *
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!
13*/
14
15#define WIN32_NO_STATUS
16#define _INC_WINDOWS
17#define COM_NO_WINDOWS_H
18
19#include <stdarg.h>
20
21#include <windef.h>
22#include <winuser.h>
23
24//#include <ntddsnd.h>
25#include <sndtypes.h>
26#include <mmddk.h>
27#include <mmebuddy.h>
28#include <mment4.h>
29#include <mmebuddy_debug.h>
30//#include <debug.h>
31
32/* TODO: Give individual device names if someone has > 1 card */
33PWSTR SBWaveOutDeviceName = L"ROS Sound Blaster Wave Out";
34PWSTR SBWaveInDeviceName = L"ROS Sound Blaster Wave In";
35PWSTR SBMidiOutDeviceName = L"ROS Sound Blaster Midi Out";
36PWSTR SBMidiInDeviceName = L"ROS Sound Blaster Midi In";
37PWSTR SBAuxDeviceName = L"ROS Sound Blaster Aux";
38PWSTR SBMixerDeviceName = L"ROS Sound Blaster Mixer";
39/* TODO: Mixer etc */
40
43 IN PSOUND_DEVICE SoundDevice,
44 IN DWORD DeviceId,
46 IN DWORD CapabilitiesSize)
47{
50
51 SND_ASSERT( SoundDevice );
53
54 SND_TRACE(L"Sndblst - GetSoundBlasterDeviceCapabilities\n");
55
56 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
58
59 /* Use the default method of obtaining device capabilities */
62 CapabilitiesSize);
63
64 if ( ! MMSUCCESS(Result) )
65 return Result;
66
67 /* Inject the appropriate device name */
68 switch ( DeviceType )
69 {
71 {
74 break;
75 }
77 {
80 break;
81 }
83 {
86 break;
87 }
89 {
92 break;
93 }
94 case AUX_DEVICE_TYPE :
95 {
98 break;
99 }
100 case MIXER_DEVICE_TYPE :
101 {
104 break;
105 }
106 }
107
108 return MMSYSERR_NOERROR;
109}
110
113 PWSTR DevicePath)
114{
116 PSOUND_DEVICE SoundDevice = NULL;
117 MMFUNCTION_TABLE FuncTable;
118 PWSTR PathCopy;
119
120 SND_TRACE(L"(Callback) Found device: %wS\n", DevicePath);
121
122 PathCopy = AllocateWideString(wcslen(DevicePath));
123
124 if ( ! PathCopy )
125 return FALSE;
126
127 CopyWideString(PathCopy, DevicePath);
128
129 Result = ListSoundDevice(DeviceType, (PVOID) PathCopy, &SoundDevice);
130
131 if ( ! MMSUCCESS(Result) )
132 return FALSE;
133
134 /* Set up our function table */
135 ZeroMemory(&FuncTable, sizeof(MMFUNCTION_TABLE));
139 FuncTable.Open = OpenNt4SoundDevice;
140 FuncTable.Close = CloseNt4SoundDevice;
142 //FuncTable.SubmitWaveHeaderToDevice = SubmitWaveHeaderToDevice;
143
144 SetSoundDeviceFunctionTable(SoundDevice, &FuncTable);
145
146 return TRUE;
147}
148
151 DWORD DriverId,
154 LONG Parameter1,
155 LONG Parameter2)
156{
158
159 switch ( Message )
160 {
161 case DRV_LOAD :
162 {
163 SND_TRACE(L"DRV_LOAD\n");
164
166
167 if ( ! MMSUCCESS(Result) )
168 return 0L;
169
171 0,
173
174 if ( ! MMSUCCESS(Result) )
175 {
177
179
180 return 0L;
181 }
182
183/*
184 PSOUND_DEVICE snd;
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);
189*/
190
191 SND_TRACE(L"Initialisation complete\n");
192
193 return 1L;
194 }
195
196 case DRV_FREE :
197 {
198 SND_TRACE(L"DRV_FREE\n");
199
200 /* TODO: Clean up the path names! */
202
204
205 SND_TRACE(L"Unfreed memory blocks: %d\n",
207
208 return 1L;
209 }
210
211 case DRV_ENABLE :
212 case DRV_DISABLE :
213 {
214 SND_TRACE(L"DRV_ENABLE / DRV_DISABLE\n");
215 return 1L;
216 }
217
218 case DRV_OPEN :
219 case DRV_CLOSE :
220 {
221 SND_TRACE(L"DRV_OPEN / DRV_CLOSE\n");
222 return 1L;
223 }
224
225 case DRV_QUERYCONFIGURE :
226 {
227 SND_TRACE(L"DRV_QUERYCONFIGURE\n");
228 return 0L;
229 }
230 case DRV_CONFIGURE :
231 return DRVCNF_OK;
232
233 default :
234 SND_TRACE(L"Unhandled message %d\n", Message);
235 return DefDriverProc(DriverId,
237 Message,
238 Parameter1,
239 Parameter2);
240 }
241}
242
244 HINSTANCE hinstDLL,
245 DWORD fdwReason,
247{
248 switch ( fdwReason )
249 {
250 case DLL_PROCESS_ATTACH :
251 SND_TRACE(L"DLL_PROCESS_ATTACH\n");
252 break;
253 case DLL_PROCESS_DETACH :
254 SND_TRACE(L"DLL_PROCESS_DETACH\n");
255 break;
256 case DLL_THREAD_ATTACH :
257 SND_TRACE(L"DLL_THREAD_ATTACH\n");
258 break;
259 case DLL_THREAD_DETACH :
260 SND_TRACE(L"DLL_THREAD_DETACH\n");
261 break;
262 }
263
264 return TRUE;
265}
static NDIS_HANDLE DriverHandle
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define DLL_THREAD_ATTACH
Definition: compat.h:132
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: sndblst.c:243
PWSTR SBMidiOutDeviceName
Definition: sndblst.c:35
PWSTR SBMidiInDeviceName
Definition: sndblst.c:36
PWSTR SBWaveOutDeviceName
Definition: sndblst.c:33
PWSTR SBMixerDeviceName
Definition: sndblst.c:38
PWSTR SBWaveInDeviceName
Definition: sndblst.c:34
BOOLEAN FoundDevice(UCHAR DeviceType, PWSTR DevicePath)
Definition: sndblst.c:111
PWSTR SBAuxDeviceName
Definition: sndblst.c:37
LONG APIENTRY DriverProc(DWORD DriverId, HANDLE DriverHandle, UINT Message, LONG Parameter1, LONG Parameter2)
Definition: sndblst.c:150
MMRESULT GetSoundBlasterDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: sndblst.c:42
LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, UINT Msg, LPARAM lParam1, LPARAM lParam2)
Definition: driver.c:554
static const WCHAR Message[]
Definition: register.c:74
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
#define DRV_LOAD(x)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static IN DWORD IN LPVOID lpvReserved
DeviceType
Definition: mmdrv.h:42
MMRESULT ListSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
Definition: devicelist.c:131
MMRESULT WriteFileEx_Committer(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
Definition: streaming.c:264
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
#define AllocateWideString(string_length)
Definition: mmebuddy.h:33
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
#define CopyWideString(dest, source)
Definition: mmebuddy.h:39
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_TRACE(...)
#define SND_ASSERT(condition)
MMRESULT OpenNt4SoundDevice(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Handle)
Definition: control.c:52
MMRESULT GetNt4SoundDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: control.c:80
MMRESULT QueryNt4WaveDeviceFormatSupport(IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: control.c:154
MMRESULT EnumerateNt4ServiceSoundDevices(IN LPWSTR ServiceName, IN MMDEVICE_TYPE DeviceType, IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
Definition: detect.c:26
MMRESULT CloseNt4SoundDevice(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Handle)
Definition: control.c:65
MMRESULT SetNt4WaveDeviceFormat(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: control.c:199
#define DRV_CLOSE
Definition: mmsystem.h:122
MIXERCAPSA * LPMIXERCAPS
Definition: mmsystem.h:2823
UINT MMRESULT
Definition: mmsystem.h:962
#define DRV_QUERYCONFIGURE
Definition: mmsystem.h:126
WAVEINCAPSA * LPWAVEINCAPS
Definition: mmsystem.h:2819
MIDIINCAPSA * LPMIDIINCAPS
Definition: mmsystem.h:2821
AUXCAPSA * LPAUXCAPS
Definition: mmsystem.h:2822
WAVEOUTCAPSA * LPWAVEOUTCAPS
Definition: mmsystem.h:2818
#define DRV_ENABLE
Definition: mmsystem.h:120
#define DRV_CONFIGURE
Definition: mmsystem.h:125
#define DRV_OPEN
Definition: mmsystem.h:121
#define DRVCNF_OK
Definition: mmsystem.h:134
MIDIOUTCAPSA * LPMIDIOUTCAPS
Definition: mmsystem.h:2820
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define DRV_FREE
Definition: mmsystem.h:124
#define DRV_DISABLE
Definition: mmsystem.h:123
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
VOID CleanupEntrypointMutexes()
Definition: reentrancy.c:56
MMRESULT InitEntrypointMutexes()
Definition: reentrancy.c:21
VOID UnlistAllSoundDevices()
Definition: devicelist.c:270
UINT GetMemoryAllocationCount()
Definition: utility.c:58
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ AUX_DEVICE_TYPE
Definition: sndtypes.h:32
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30
MMOPEN_FUNC Open
Definition: mmebuddy.h:214
MMCLOSE_FUNC Close
Definition: mmebuddy.h:215
MMGETCAPS_FUNC GetCapabilities
Definition: mmebuddy.h:207
MMWAVEQUERYFORMATSUPPORT_FUNC QueryWaveFormatSupport
Definition: mmebuddy.h:217
WAVE_COMMIT_FUNC CommitWaveBuffer
Definition: mmebuddy.h:222
MMWAVESETFORMAT_FUNC SetWaveFormat
Definition: mmebuddy.h:218
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1192
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1138
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1114
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1217
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1050
CHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1028
uint16_t * PWSTR
Definition: typedefs.h:56
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
#define ZeroMemory
Definition: winbase.h:1737
#define WINAPI
Definition: msvc.h:6
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char UCHAR
Definition: xmlstorage.h:181