ReactOS  0.4.12-dev-36-g472787f
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 ()
 

Variables

static HANDLE device_list_file = NULL
 
static PnP_AudioHeaderaudio_device_list = NULL
 

Function Documentation

◆ AppendAudioDeviceToList()

BOOL AppendAudioDeviceToList ( PnP_AudioDevice device)

Definition at line 58 of file pnp_list_manager.c.

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

59 {
60  int device_info_size;
61 
62  /* Figure out the actual structure size */
63  device_info_size = sizeof(PnP_AudioDevice);
64  device_info_size += WideStringSize(device->path);
65 
67 
68 /*
69  printf("list size is %d\n", audio_device_list->size);
70  printf("device info size is %d bytes\n", device_info_size);
71 */
72 
73  /* We DON'T want to overshoot the end of the buffer! */
74  if ( audio_device_list->size + device_info_size > audio_device_list->max_size )
75  {
76  /*printf("max_size would be exceeded! Failing...\n");*/
77 
79 
80  return FALSE;
81  }
82 
83  /* Commit the device descriptor to the list */
85  device,
86  device_info_size);
87 
88  /* Update the header */
90  audio_device_list->size += device_info_size;
91 
93 
94  logmsg("Device added to list\n");
95 
96  return TRUE;
97 }
VOID UnlockAudioDeviceList()
Definition: pnp_list_lock.c:53
#define TRUE
Definition: types.h:120
VOID LockAudioDeviceList()
Definition: pnp_list_lock.c:46
WCHAR path[]
Definition: audiosrv.h:30
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

◆ CreateAudioDeviceList()

BOOL CreateAudioDeviceList ( DWORD  max_size)

Definition at line 100 of file pnp_list_manager.c.

Referenced by ServiceMain().

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

◆ CreateDeviceDescriptor()

VOID* CreateDeviceDescriptor ( WCHAR path,
BOOL  is_enabled 
)

Definition at line 16 of file pnp_list_manager.c.

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

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 
27  if ( ! device )
28  {
29  logmsg("Failed to create a device descriptor (malloc fail)\n");
30  return NULL;
31  }
32 
33  device->enabled = is_enabled;
34  memcpy(device->path, path, path_length);
35 
36  return device;
37 }
Definition: devices.h:39
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static long path_length
Definition: maze.c:116
WCHAR path[]
Definition: audiosrv.h:30
void logmsg(char *string,...)
Definition: debug.c:7
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: services.c:325
#define malloc
Definition: debug_ros.c:4
#define WideStringSize(str)
Definition: audiosrv.h:45
DWORD enabled
Definition: audiosrv.h:29

◆ DestroyAudioDeviceList()

VOID DestroyAudioDeviceList ( )

Definition at line 171 of file pnp_list_manager.c.

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

Variable Documentation

◆ audio_device_list

PnP_AudioHeader* audio_device_list = NULL
static

Definition at line 49 of file pnp_list_manager.c.

◆ device_list_file

HANDLE device_list_file = NULL
static

Definition at line 48 of file pnp_list_manager.c.