ReactOS 0.4.16-dev-300-g2aadf2e
pnp_list_manager.c File Reference
#include "audiosrv.h"
#include <debug.h>
Include dependency graph for pnp_list_manager.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOIDCreateDeviceDescriptor (WCHAR *path, BOOL is_enabled)
 
BOOL AppendAudioDeviceToList (PnP_AudioDevice *device)
 
BOOL CreateAudioDeviceList (DWORD max_size)
 
VOID DestroyAudioDeviceList (VOID)
 

Variables

static HANDLE device_list_file = NULL
 
static PnP_AudioHeaderaudio_device_list = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file pnp_list_manager.c.

Function Documentation

◆ AppendAudioDeviceToList()

BOOL AppendAudioDeviceToList ( PnP_AudioDevice device)

Definition at line 57 of file pnp_list_manager.c.

58{
59 int device_info_size;
60
61 /* Figure out the actual structure size */
62 device_info_size = sizeof(PnP_AudioDevice);
63 device_info_size += WideStringSize(device->path);
64
66
67 /* We DON'T want to overshoot the end of the buffer! */
68 if (audio_device_list->size + device_info_size > audio_device_list->max_size)
69 {
70 /*DPRINT("failed, max_size would be exceeded\n");*/
71
73
74 return FALSE;
75 }
76
77 /* Commit the device descriptor to the list */
79 device,
80 device_info_size);
81
82 /* Update the header */
84 audio_device_list->size += device_info_size;
85
87
88 DPRINT("Device added to list\n");
89
90 return TRUE;
91}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID LockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:45
VOID UnlockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:52
static PnP_AudioHeader * audio_device_list
#define WideStringSize(str)
Definition: audiosrv.h:45
#define DPRINT
Definition: sndvol32.h:73
DWORD max_size
Definition: audiosrv.h:36
DWORD device_count
Definition: audiosrv.h:37
Definition: devices.h:37

Referenced by InitializeFakeDevice(), ProcessDeviceArrival(), and ProcessExistingDevices().

◆ CreateAudioDeviceList()

BOOL CreateAudioDeviceList ( DWORD  max_size)

Definition at line 94 of file pnp_list_manager.c.

95{
97 {
98 /*DPRINT("Failed\n");*/
99 return FALSE;
100 }
101
102 /* Preliminary locking - the list memory will likely be a big
103 buffer of gibberish at this point so we don't want anyone
104 turning up before we're ready... */
106
107 DPRINT("Creating file mapping\n");
108 /* Expose our device list to the world */
110 NULL,
112 0,
113 max_size,
115 if (!device_list_file)
116 {
117 DPRINT("Creation of audio device list failed (err %d)\n", GetLastError());
118
121
122 return FALSE;
123 }
124
125 DPRINT("Mapping view of file\n");
126 /* Of course, we'll need to access the list ourselves */
129 0,
130 0,
131 max_size);
133 {
134 DPRINT("MapViewOfFile FAILED (err %d)\n", GetLastError());
135
138
141
142 return FALSE;
143 }
144
145 /* Clear the mem to avoid any random stray data */
147
148 /* Don't want devices to overwrite the list! */
152
154
155 DPRINT("Device list created\n");
156
157 return TRUE;
158}
static INT max_size
Definition: history.c:51
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define MapViewOfFile
Definition: compat.h:745
#define PAGE_READWRITE
Definition: nt_native.h:1304
BOOL InitializeAudioDeviceListLock(VOID)
Definition: pnp_list_lock.c:15
VOID KillAudioDeviceListLock(VOID)
Definition: pnp_list_lock.c:38
static HANDLE device_list_file
#define AUDIO_LIST_NAME
Definition: audiosrv.h:22
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FILE_MAP_WRITE
Definition: winbase.h:155

Referenced by ServiceMain().

◆ CreateDeviceDescriptor()

VOID * CreateDeviceDescriptor ( WCHAR path,
BOOL  is_enabled 
)

Definition at line 18 of file pnp_list_manager.c.

19{
21
23 int size = sizeof(PnP_AudioDevice) + path_length;
24
26 if (! device)
27 {
28 DPRINT("Failed to malloc device descriptor\n");
29 return NULL;
30 }
31
32 device->enabled = is_enabled;
34
35 return device;
36}
static long path_length
Definition: maze.c:116
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919

Referenced by InitializeFakeDevice(), ProcessDeviceArrival(), and ProcessExistingDevices().

◆ DestroyAudioDeviceList()

VOID DestroyAudioDeviceList ( VOID  )

Definition at line 161 of file pnp_list_manager.c.

162{
163 DPRINT("Destroying device list\n");
164
166
167 /*DPRINT("Unmapping view\n");*/
170
171 /*DPRINT("Closing memory mapped file\n");*/
174
176
177 /*DPRINT("Killing devlist lock\n");*/
179}
#define UnmapViewOfFile
Definition: compat.h:746

Referenced by ServiceControlHandler(), and ServiceMain().

Variable Documentation

◆ audio_device_list

PnP_AudioHeader* audio_device_list = NULL
static

◆ device_list_file

HANDLE device_list_file = NULL
static

Definition at line 47 of file pnp_list_manager.c.

Referenced by CreateAudioDeviceList(), and DestroyAudioDeviceList().