ReactOS  0.4.12-dev-75-g00dd17e
main.c File Reference
#include "audiosrv.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

VOID InitializeFakeDevice ()
 
DWORD WINAPI ServiceControlHandler (DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
 
VOID CALLBACK ServiceMain (DWORD argc, LPWSTR argv)
 
int wmain ()
 

Variables

SERVICE_STATUS_HANDLE service_status_handle
 
SERVICE_STATUS service_status
 

Function Documentation

◆ InitializeFakeDevice()

VOID InitializeFakeDevice ( )

Definition at line 17 of file main.c.

Referenced by ServiceMain().

18 {
19  PnP_AudioDevice* list_node;
20 
21  list_node = CreateDeviceDescriptor(L"ThisDeviceDoesNotReallyExist", TRUE);
22  AppendAudioDeviceToList(list_node);
23  DestroyDeviceDescriptor(list_node);
24 }
#define TRUE
Definition: types.h:120
BOOL AppendAudioDeviceToList(PnP_AudioDevice *device)
#define DestroyDeviceDescriptor(descriptor)
Definition: audiosrv.h:31
static const WCHAR L[]
Definition: oid.c:1087
VOID * CreateDeviceDescriptor(WCHAR *path, BOOL is_enabled)

◆ ServiceControlHandler()

DWORD WINAPI ServiceControlHandler ( DWORD  dwControl,
DWORD  dwEventType,
LPVOID  lpEventData,
LPVOID  lpContext 
)

Definition at line 27 of file main.c.

Referenced by ServiceMain().

32 {
33  switch ( dwControl )
34  {
36  {
37  logmsg("* Interrogation\n");
38  return NO_ERROR;
39  }
40 
43  {
44  logmsg("* Service Stop/Shutdown request received\n");
45 
46  logmsg("Unregistering device notifications\n");
48 
49  logmsg("Destroying audio device list\n");
51 
54 
57 
59 
60  logmsg("* Service stopped\n");
61 
62  return NO_ERROR;
63  }
64 
66  {
67  logmsg("* Device Event\n");
68  return HandleDeviceEvent(dwEventType, lpEventData);
69  }
70 
71  default :
73  };
74 
75  /*SetServiceStatus(service_status_handle, &service_status);*/
76 }
VOID DestroyAudioDeviceList(VOID)
#define SERVICE_CONTROL_DEVICEEVENT
Definition: winsvc.h:46
DWORD HandleDeviceEvent(DWORD dwEventType, LPVOID lpEventData)
Definition: pnp.c:176
DWORD dwCurrentState
Definition: winsvc.h:100
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
SERVICE_STATUS_HANDLE service_status_handle
Definition: main.c:11
DWORD dwWin32ExitCode
Definition: winsvc.h:102
void logmsg(char *string,...)
Definition: debug.c:7
SERVICE_STATUS service_status
Definition: main.c:12
VOID UnregisterDeviceNotifications(VOID)
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40

◆ ServiceMain()

VOID CALLBACK ServiceMain ( DWORD  argc,
LPWSTR  argv 
)

Definition at line 79 of file main.c.

Referenced by ServiceStarter(), and wmain().

80 {
81  logmsg("* Service starting\n");
82  logmsg("Registering service control handler...\n");
85  NULL);
86 
87  logmsg("Service status handle %d\n", service_status_handle);
88  if ( ! service_status_handle )
89  {
90  logmsg("Failed to register service control handler\n");
91  /* FIXME - we should fail */
92  }
93 
94  /* Set these to defaults */
101 
102  /* Tell SCM we're starting */
105 
106  logmsg("Creating audio device list\n");
107  /* This creates the audio device list and mutex */
109  {
110  logmsg("Failed to create audio device list\n");
114  return;
115  }
116 
117  logmsg("Registering for device notifications\n");
118  /* We want to know when devices are added/removed */
120  {
121  /* FIXME: This is not fatal at present as ROS does not support this */
122  logmsg("Failed to register for device notifications\n");
123 /*
124  DestroyAudioDeviceList();
125 
126  service_status.dwCurrentState = SERVICE_STOPPED;
127  service_status.dwWin32ExitCode = -1;
128  SetServiceStatus(service_status_handle, &service_status);
129  return;
130 */
131  }
132  /* start system audio services */
134 
135 
137 
138  logmsg("Processing existing devices\n");
139  /* Now find any devices that already exist on the system */
140  if ( ! ProcessExistingDevices() )
141  {
142  logmsg("Could not process existing devices\n");
145 
149  return;
150  }
151 
152  logmsg("* Service started\n");
153  /* Tell SCM we are now running, and we may be stopped */
157 }
VOID DestroyAudioDeviceList(VOID)
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define NO_ERROR
Definition: dderror.h:5
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
BOOL StartSystemAudioServices(VOID)
smooth NULL
Definition: ftsmooth.c:416
BOOL CreateAudioDeviceList(DWORD max_size)
SERVICE_STATUS_HANDLE service_status_handle
Definition: main.c:11
BOOL ProcessExistingDevices(VOID)
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:960
DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: main.c:27
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
void logmsg(char *string,...)
Definition: debug.c:7
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:773
BOOL RegisterForDeviceNotifications(VOID)
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_NAME
Definition: wlansvc.c:18
SERVICE_STATUS service_status
Definition: main.c:12
#define AUDIO_LIST_MAX_SIZE
Definition: audiosrv.h:25
VOID UnregisterDeviceNotifications(VOID)
VOID InitializeFakeDevice()
Definition: main.c:17

◆ wmain()

int wmain ( )

Definition at line 159 of file main.c.

160 {
161  SERVICE_TABLE_ENTRYW service_table[] =
162  {
164  { NULL, NULL }
165  };
166 
167  logmsg("Audio Service main()\n");
168  if (!StartServiceCtrlDispatcherW(service_table))
169  logmsg("StartServiceCtrlDispatcher failed\n");
170 
171  return 0;
172 }
void(WINAPI * LPSERVICE_MAIN_FUNCTIONW)(DWORD, LPWSTR *)
Definition: winsvc.h:177
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1094
smooth NULL
Definition: ftsmooth.c:416
VOID CALLBACK ServiceMain(DWORD argc, LPWSTR argv)
Definition: main.c:79
void logmsg(char *string,...)
Definition: debug.c:7
#define SERVICE_NAME
Definition: wlansvc.c:18

Variable Documentation

◆ service_status

SERVICE_STATUS service_status

Definition at line 12 of file main.c.

◆ service_status_handle

SERVICE_STATUS_HANDLE service_status_handle

Definition at line 11 of file main.c.

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