ReactOS  0.4.11-dev-946-g431643b
audiosrv.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <malloc.h>
#include <dbt.h>
#include <audiosrv/audiosrv.h>
Include dependency graph for audiosrv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define AUDIOSRV_PRIVATE_H
 
#define DestroyDeviceDescriptor(descriptor)   free(descriptor)
 

Functions

VOIDCreateDeviceDescriptor (WCHAR *path, BOOL is_enabled)
 
BOOL AppendAudioDeviceToList (PnP_AudioDevice *device)
 
BOOL CreateAudioDeviceList (DWORD max_size)
 
VOID DestroyAudioDeviceList (VOID)
 
BOOL ProcessExistingDevices (VOID)
 
DWORD ProcessDeviceArrival (DEV_BROADCAST_DEVICEINTERFACE *device)
 
BOOL RegisterForDeviceNotifications (VOID)
 
VOID UnregisterDeviceNotifications (VOID)
 
DWORD HandleDeviceEvent (DWORD dwEventType, LPVOID lpEventData)
 
BOOL StartSystemAudioServices (VOID)
 
void logmsg (char *string,...)
 

Variables

SERVICE_STATUS_HANDLE service_status_handle
 

Macro Definition Documentation

◆ AUDIOSRV_PRIVATE_H

#define AUDIOSRV_PRIVATE_H

Definition at line 21 of file audiosrv.h.

◆ DestroyDeviceDescriptor

#define DestroyDeviceDescriptor (   descriptor)    free(descriptor)

Definition at line 31 of file audiosrv.h.

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

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

◆ HandleDeviceEvent()

DWORD HandleDeviceEvent ( DWORD  dwEventType,
LPVOID  lpEventData 
)

Definition at line 176 of file pnp.c.

Referenced by ServiceControlHandler().

179 {
180  switch ( dwEventType )
181  {
182  case DBT_DEVICEARRIVAL :
183  {
184  DEV_BROADCAST_DEVICEINTERFACE* incoming_device =
185  (DEV_BROADCAST_DEVICEINTERFACE*) lpEventData;
186 
187  return ProcessDeviceArrival(incoming_device);
188  }
189 
190  default :
191  {
192  break;
193  }
194  }
195 
196  return NO_ERROR;
197 }
#define NO_ERROR
Definition: dderror.h:5
DWORD ProcessDeviceArrival(DEV_BROADCAST_DEVICEINTERFACE *device)
Definition: pnp.c:111
#define DBT_DEVICEARRIVAL
Definition: dbt.h:12

◆ logmsg()

void logmsg ( char string,
  ... 
)

Definition at line 7 of file debug.c.

Referenced by AppendAudioDeviceToList(), CreateAudioDeviceList(), CreateDeviceDescriptor(), DestroyAudioDeviceList(), ProcessExistingDevices(), RegisterForDeviceNotifications(), ServiceControlHandler(), ServiceMain(), StartAudioService(), StartSystemAudioServices(), WaitForService(), and wmain().

8 {
10 
11  FILE* debug_file = fopen("c:\\audiosrv-debug.txt", "a");
12 
13  if (debug_file)
14  {
15  va_start(args, string);
16  vfprintf(debug_file, string, args);
17  va_end(args);
18  fclose(debug_file);
19  }
20  else
21  {
22  char buf[256];
23  va_start(args, string);
24  vsprintf(buf, string, args);
25  OutputDebugStringA(buf);
26  va_end(args);
27  }
28 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define args
Definition: format.c:66
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18

◆ ProcessDeviceArrival()

DWORD ProcessDeviceArrival ( DEV_BROADCAST_DEVICEINTERFACE device)

Definition at line 111 of file pnp.c.

Referenced by HandleDeviceEvent().

112 {
113  PnP_AudioDevice* list_node;
114  list_node = CreateDeviceDescriptor(device->dbcc_name, TRUE);
115  AppendAudioDeviceToList(list_node);
116  DestroyDeviceDescriptor(list_node);
117 
118  return NO_ERROR;
119 }
#define TRUE
Definition: types.h:120
BOOL AppendAudioDeviceToList(PnP_AudioDevice *device)
#define NO_ERROR
Definition: dderror.h:5
#define DestroyDeviceDescriptor(descriptor)
Definition: audiosrv.h:31
VOID * CreateDeviceDescriptor(WCHAR *path, BOOL is_enabled)

◆ ProcessExistingDevices()

BOOL ProcessExistingDevices ( VOID  )

Referenced by ServiceMain().

◆ RegisterForDeviceNotifications()

BOOL RegisterForDeviceNotifications ( VOID  )

Referenced by ServiceMain().

◆ StartSystemAudioServices()

BOOL StartSystemAudioServices ( VOID  )

Referenced by ServiceMain().

◆ UnregisterDeviceNotifications()

VOID UnregisterDeviceNotifications ( VOID  )

Variable Documentation

◆ service_status_handle

SERVICE_STATUS_HANDLE service_status_handle

Definition at line 11 of file main.c.

Referenced by RegisterForDeviceNotifications(), ServiceControlHandler(), and ServiceMain().