ReactOS  0.4.14-dev-1332-g6db3d88
pnp_list_manager.c File Reference
#include "audiosrv.h"
Include dependency graph for pnp_list_manager.c:

Go to the source code of this file.

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
 

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 /*
68  printf("list size is %d\n", audio_device_list->size);
69  printf("device info size is %d bytes\n", device_info_size);
70 */
71 
72  /* We DON'T want to overshoot the end of the buffer! */
73  if (audio_device_list->size + device_info_size > audio_device_list->max_size)
74  {
75  /*printf("max_size would be exceeded! Failing...\n");*/
76 
78 
79  return FALSE;
80  }
81 
82  /* Commit the device descriptor to the list */
84  device,
85  device_info_size);
86 
87  /* Update the header */
89  audio_device_list->size += device_info_size;
90 
92 
93  logmsg("Device added to list\n");
94 
95  return TRUE;
96 }
VOID UnlockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:53
#define TRUE
Definition: types.h:120
Definition: devices.h:37
DWORD device_count
Definition: audiosrv.h:37
void logmsg(char *string,...)
Definition: debug.c:7
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD max_size
Definition: audiosrv.h:36
static PnP_AudioHeader * audio_device_list
#define WideStringSize(str)
Definition: audiosrv.h:45
VOID LockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:46

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

◆ CreateAudioDeviceList()

BOOL CreateAudioDeviceList ( DWORD  max_size)

Definition at line 99 of file pnp_list_manager.c.

100 {
101 /* printf("Initializing memory device list lock\n");*/
102 
104  {
105  /*printf("Failed!\n");*/
106  return FALSE;
107  }
108 
109  /* Preliminary locking - the list memory will likely be a big
110  buffer of gibberish at this point so we don't want anyone
111  turning up before we're ready... */
113 
114  logmsg("Creating file mapping\n");
115  /* Expose our device list to the world */
117  NULL,
119  0,
120  max_size,
122  if (!device_list_file)
123  {
124  logmsg("Creation of audio device list failed (err %d)\n", GetLastError());
125 
128 
129  return FALSE;
130  }
131 
132  logmsg("Mapping view of file\n");
133  /* Of course, we'll need to access the list ourselves */
136  0,
137  0,
138  max_size);
139  if (!audio_device_list)
140  {
141  logmsg("MapViewOfFile FAILED (err %d)\n", GetLastError());
142 
145 
148 
149  return FALSE;
150  }
151 
152  /* Clear the mem to avoid any random stray data */
154 
155  /* Don't want devices to overwrite the list! */
159 
161 
162  logmsg("Device list created\n");
163 
164  return TRUE;
165 }
VOID UnlockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:53
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define MapViewOfFile
Definition: compat.h:410
#define AUDIO_LIST_NAME
Definition: audiosrv.h:22
BOOL InitializeAudioDeviceListLock(VOID)
Definition: pnp_list_lock.c:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HANDLE device_list_file
static INT max_size
Definition: history.c:51
smooth NULL
Definition: ftsmooth.c:416
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:409
#define FILE_MAP_WRITE
Definition: winbase.h:154
DWORD device_count
Definition: audiosrv.h:37
void logmsg(char *string,...)
Definition: debug.c:7
VOID KillAudioDeviceListLock(VOID)
Definition: pnp_list_lock.c:39
DWORD max_size
Definition: audiosrv.h:36
static PnP_AudioHeader * audio_device_list
#define memset(x, y, z)
Definition: compat.h:39
VOID LockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:46
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by ServiceMain().

◆ CreateDeviceDescriptor()

VOID* CreateDeviceDescriptor ( WCHAR path,
BOOL  is_enabled 
)

Definition at line 16 of file pnp_list_manager.c.

17 {
19 
21  int size = sizeof(PnP_AudioDevice) + path_length;
22 
23 /* printf("path_length %d, total %d\n", path_length, size);*/
24 
25  device = malloc(size);
26  if (! device)
27  {
28  logmsg("Failed to create a device descriptor (malloc fail)\n");
29  return NULL;
30  }
31 
32  device->enabled = is_enabled;
33  memcpy(device->path, path, path_length);
34 
35  return device;
36 }
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static long path_length
Definition: maze.c:116
void logmsg(char *string,...)
Definition: debug.c:7
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define malloc
Definition: debug_ros.c:4
#define WideStringSize(str)
Definition: audiosrv.h:45

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

◆ DestroyAudioDeviceList()

VOID DestroyAudioDeviceList ( VOID  )

Definition at line 168 of file pnp_list_manager.c.

169 {
170  logmsg("Destroying device list\n");
171 
173 
174  /*printf("Unmapping view\n");*/
177 
178  /*printf("Closing memory mapped file\n");*/
181 
183 
184  /*printf("Killing devlist lock\n");*/
186 }
VOID UnlockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:53
#define CloseHandle
Definition: compat.h:406
static HANDLE device_list_file
smooth NULL
Definition: ftsmooth.c:416
void logmsg(char *string,...)
Definition: debug.c:7
VOID KillAudioDeviceListLock(VOID)
Definition: pnp_list_lock.c:39
static PnP_AudioHeader * audio_device_list
#define UnmapViewOfFile
Definition: compat.h:411
VOID LockAudioDeviceList(VOID)
Definition: pnp_list_lock.c:46

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().