ReactOS 0.4.16-dev-319-g6cf4263
devicelist.c File Reference
#include "precomp.h"
Include dependency graph for devicelist.c:

Go to the source code of this file.

Functions

MMRESULT AllocateSoundDevice (IN MMDEVICE_TYPE DeviceType, OUT PSOUND_DEVICE *SoundDevice)
 
VOID FreeSoundDevice (IN PSOUND_DEVICE SoundDevice)
 
ULONG GetSoundDeviceCount (IN MMDEVICE_TYPE DeviceType)
 
BOOLEAN IsValidSoundDevice (IN PSOUND_DEVICE SoundDevice)
 
MMRESULT ListSoundDevice (IN MMDEVICE_TYPE DeviceType, IN PVOID Identifier OPTIONAL, OUT PSOUND_DEVICE *SoundDevice OPTIONAL)
 
MMRESULT UnlistSoundDevice (IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
 
MMRESULT UnlistSoundDevices (IN MMDEVICE_TYPE DeviceType)
 
VOID UnlistAllSoundDevices ()
 
MMRESULT GetSoundDevice (IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceIndex, OUT PSOUND_DEVICE *SoundDevice)
 
MMRESULT GetSoundDeviceIdentifier (IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
 
MMRESULT GetSoundDeviceType (IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
 

Variables

ULONG SoundDeviceCounts [SOUND_DEVICE_TYPES]
 
PSOUND_DEVICE SoundDeviceListHeads [SOUND_DEVICE_TYPES]
 
PSOUND_DEVICE SoundDeviceListTails [SOUND_DEVICE_TYPES]
 

Function Documentation

◆ AllocateSoundDevice()

MMRESULT AllocateSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
OUT PSOUND_DEVICE SoundDevice 
)

Definition at line 21 of file devicelist.c.

24{
25 PSOUND_DEVICE NewDevice;
26
28 SND_ASSERT( SoundDevice );
29
30 SND_TRACE(L"Allocating a SOUND_DEVICE structure\n");
31
32 NewDevice = AllocateStruct(SOUND_DEVICE);
33
34 if ( ! NewDevice )
35 return MMSYSERR_NOMEM;
36
37 NewDevice->Type = DeviceType;
38
39 /* Return the new structure to the caller and report success */
40 *SoundDevice = NewDevice;
41
42 return MMSYSERR_NOERROR;
43}
DeviceType
Definition: mmdrv.h:42
#define AllocateStruct(thing)
Definition: mmebuddy.h:27
#define IsValidSoundDeviceType
Definition: mmebuddy.h:69
#define SND_TRACE(...)
#define SND_ASSERT(condition)
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define L(x)
Definition: ntvdm.h:50
MMDEVICE_TYPE Type
Definition: mmebuddy.h:273

Referenced by ListSoundDevice().

◆ FreeSoundDevice()

VOID FreeSoundDevice ( IN PSOUND_DEVICE  SoundDevice)

Definition at line 49 of file devicelist.c.

51{
52 SND_ASSERT( SoundDevice );
53
54 SND_TRACE(L"Freeing a SOUND_DEVICE structure\n");
55
56 /* For safety the whole struct gets zeroed */
57 ZeroMemory(SoundDevice, sizeof(SOUND_DEVICE));
58 FreeMemory(SoundDevice);
59}
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
#define ZeroMemory
Definition: winbase.h:1737

Referenced by UnlistSoundDevice().

◆ GetSoundDevice()

MMRESULT GetSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN DWORD  DeviceIndex,
OUT PSOUND_DEVICE SoundDevice 
)

Definition at line 289 of file devicelist.c.

293{
295 DWORD CurrentIndex = 0;
296 PSOUND_DEVICE CurrentDevice;
297
299
300 if ( DeviceIndex >= SoundDeviceCounts[TypeIndex] )
301 {
302 SND_ERR(L"Invalid device ID %d for type %d\n", DeviceIndex, DeviceType);
304 }
305
306 CurrentDevice = SoundDeviceListHeads[TypeIndex];
307
308 /* Following the earlier checks, the index should be valid here. */
309 for ( CurrentIndex = 0; CurrentIndex != DeviceIndex; ++ CurrentIndex )
310 {
311 SND_ASSERT( CurrentDevice );
312 CurrentDevice = CurrentDevice->Next;
313 }
314
315 SND_TRACE(L"Returning sound device %x\n", CurrentDevice);
316
317 *SoundDevice = CurrentDevice;
318
319 return MMSYSERR_NOERROR;
320}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SOUND_DEVICE_TYPE_TO_INDEX(x)
Definition: mmebuddy.h:58
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
#define SND_ERR(...)
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
ULONG SoundDeviceCounts[SOUND_DEVICE_TYPES]
Definition: devicelist.c:13
PSOUND_DEVICE SoundDeviceListHeads[SOUND_DEVICE_TYPES]
Definition: devicelist.c:14
struct _SOUND_DEVICE * Next
Definition: mmebuddy.h:270
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by MmeGetDeviceInterfaceString(), MmeGetLineInfo(), MmeGetSoundDeviceCapabilities(), and MmeOpenDevice().

◆ GetSoundDeviceCount()

ULONG GetSoundDeviceCount ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 67 of file devicelist.c.

69{
71
73 {
74 return 0;
75 }
76
77 SND_TRACE(L"Returning a count of %d devices\n", SoundDeviceCounts[Index]);
79}
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by auxMessage(), midMessage(), modMessage(), mxdMessage(), widMessage(), and wodMessage().

◆ GetSoundDeviceIdentifier()

MMRESULT GetSoundDeviceIdentifier ( IN PSOUND_DEVICE  SoundDevice,
OUT PVOID Identifier 
)

Definition at line 328 of file devicelist.c.

331{
332 VALIDATE_MMSYS_PARAMETER( SoundDevice );
334
335 /* The caller should not modify this! */
336 *Identifier = SoundDevice->Identifier;
337
338 return MMSYSERR_NOERROR;
339}
@ Identifier
Definition: asmpp.cpp:95

Referenced by OpenNt4KernelSoundDevice(), and WdmAudSetWaveDeviceFormatByLegacy().

◆ GetSoundDeviceType()

◆ IsValidSoundDevice()

BOOLEAN IsValidSoundDevice ( IN PSOUND_DEVICE  SoundDevice)

Definition at line 87 of file devicelist.c.

89{
90 UCHAR TypeIndex;
91 PSOUND_DEVICE CurrentDevice;
92
93 if ( ! SoundDevice )
94 return FALSE;
95
96 /* Go through all the device lists */
97 for ( TypeIndex = 0; TypeIndex < SOUND_DEVICE_TYPES; ++ TypeIndex )
98 {
99 CurrentDevice = SoundDeviceListHeads[TypeIndex];
100
101 while ( CurrentDevice )
102 {
103 if ( CurrentDevice == SoundDevice )
104 {
105 /* Found the device */
106 return TRUE;
107 }
108
109 CurrentDevice = CurrentDevice->Next;
110 }
111 }
112
113 /* If we get here, nothing was found */
114 return FALSE;
115}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ SOUND_DEVICE_TYPES
Definition: sndtypes.h:40

Referenced by CreateSoundDeviceInstance(), GetSoundDeviceCapabilities(), GetSoundDeviceFunctionTable(), ListSoundDeviceInstance(), OpenNt4KernelSoundDevice(), OpenNt4SoundDevice(), QueryNt4WaveDeviceFormatSupport(), QueryWaveDeviceFormatSupport(), SetSoundDeviceFunctionTable(), and UnlistSoundDevice().

◆ ListSoundDevice()

MMRESULT ListSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN PVOID Identifier  OPTIONAL,
OUT PSOUND_DEVICE *SoundDevice  OPTIONAL 
)

Definition at line 131 of file devicelist.c.

135{
137 PSOUND_DEVICE NewDevice;
139
141
143
144 if ( ! MMSUCCESS(Result) )
145 {
146 SND_ERR(L"Failed to allocate SOUND_DEVICE structure\n");
147 return Result;
148 }
149
150 if ( ! SoundDeviceListHeads[TypeIndex] )
151 {
152 SND_TRACE(L"Putting first entry into device list %d\n", DeviceType);
153 SoundDeviceListHeads[TypeIndex] = NewDevice;
154 SoundDeviceListTails[TypeIndex] = NewDevice;
155 }
156 else
157 {
158 SND_TRACE(L"Putting another entry into device list %d\n", DeviceType);
159 SoundDeviceListTails[TypeIndex]->Next = NewDevice;
160 SoundDeviceListTails[TypeIndex] = NewDevice;
161 }
162
163 /* Add to the count */
164 ++ SoundDeviceCounts[TypeIndex];
165
166 /* Set up the default function table */
168
169 /* Set up other members of the structure */
170 NewDevice->Identifier = Identifier;
171 NewDevice->HeadInstance = NULL;
172 NewDevice->TailInstance = NULL;
173
174 /* Fill in the caller's PSOUND_DEVICE */
175 if ( SoundDevice )
176 {
177 *SoundDevice = NewDevice;
178 }
179
180 return MMSYSERR_NOERROR;
181}
#define NULL
Definition: types.h:112
MMRESULT SetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, IN PMMFUNCTION_TABLE FunctionTable)
Definition: functiontable.c:21
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
UINT MMRESULT
Definition: mmsystem.h:962
PSOUND_DEVICE SoundDeviceListTails[SOUND_DEVICE_TYPES]
Definition: devicelist.c:15
MMRESULT AllocateSoundDevice(IN MMDEVICE_TYPE DeviceType, OUT PSOUND_DEVICE *SoundDevice)
Definition: devicelist.c:21
PVOID Identifier
Definition: mmebuddy.h:274
struct _SOUND_DEVICE_INSTANCE * HeadInstance
Definition: mmebuddy.h:271
struct _SOUND_DEVICE_INSTANCE * TailInstance
Definition: mmebuddy.h:272
_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

Referenced by FoundDevice(), and PopulateWdmDeviceList().

◆ UnlistAllSoundDevices()

VOID UnlistAllSoundDevices ( )

Definition at line 270 of file devicelist.c.

271{
273
274 SND_TRACE(L"Unlisting all sound devices\n");
275
277 {
281 }
282}
Type
Definition: Type.h:7
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT UnlistSoundDevices(IN MMDEVICE_TYPE DeviceType)
Definition: devicelist.c:245
@ MIN_SOUND_DEVICE_TYPE
Definition: sndtypes.h:36
@ MAX_SOUND_DEVICE_TYPE
Definition: sndtypes.h:37

Referenced by DriverProc().

◆ UnlistSoundDevice()

MMRESULT UnlistSoundDevice ( IN MMDEVICE_TYPE  DeviceType,
IN PSOUND_DEVICE  SoundDevice 
)

Definition at line 188 of file devicelist.c.

191{
192 PSOUND_DEVICE CurrentDevice, PreviousDevice;
193
195
198
199 PreviousDevice = NULL;
200 CurrentDevice = SoundDeviceListHeads[TypeIndex];
201
202 while ( CurrentDevice )
203 {
204 if ( CurrentDevice == SoundDevice )
205 {
206 if ( ! PreviousDevice )
207 {
208 /* This is the head node */
209 SND_TRACE(L"Removing head node from device list %d\n", DeviceType);
210 SoundDeviceListHeads[TypeIndex] =
211 SoundDeviceListHeads[TypeIndex]->Next;
212 }
213 else
214 {
215 SND_TRACE(L"Removing node from device list %d\n", DeviceType);
216 /* There are nodes before this one - cut our device out */
217 PreviousDevice->Next = CurrentDevice->Next;
218 }
219
220 if ( ! CurrentDevice->Next )
221 {
222 /* This is the tail node */
223 SND_TRACE(L"Removing tail node from device list %d\n", DeviceType);
224 SoundDeviceListTails[TypeIndex] = PreviousDevice;
225 }
226 }
227
228 PreviousDevice = CurrentDevice;
229 CurrentDevice = CurrentDevice->Next;
230 }
231
232 /* Subtract from the count */
233 -- SoundDeviceCounts[TypeIndex];
234
235 /* Finally, free up the deleted entry */
236 FreeSoundDevice(SoundDevice);
237
238 return MMSYSERR_NOERROR;
239}
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
VOID FreeSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:49

Referenced by UnlistSoundDevices().

◆ UnlistSoundDevices()

MMRESULT UnlistSoundDevices ( IN MMDEVICE_TYPE  DeviceType)

Definition at line 245 of file devicelist.c.

247{
248 UCHAR TypeIndex;
250
251 SND_TRACE(L"Unlisting all sound devices of type %d\n", DeviceType);
252
254
255 /* Munch away at the head of the list until it's drained */
256 while ( SoundDeviceCounts[TypeIndex] > 0 )
257 {
261 }
262
263 return MMSYSERR_NOERROR;
264}
MMRESULT UnlistSoundDevice(IN MMDEVICE_TYPE DeviceType, IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:188

Referenced by UnlistAllSoundDevices().

Variable Documentation

◆ SoundDeviceCounts

◆ SoundDeviceListHeads

◆ SoundDeviceListTails

PSOUND_DEVICE SoundDeviceListTails[SOUND_DEVICE_TYPES]

Definition at line 15 of file devicelist.c.

Referenced by ListSoundDevice(), and UnlistSoundDevice().