ReactOS 0.4.15-dev-8241-g63935f8
main.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Audio Service
5 * COPYRIGHT: Copyright 2007 Andrew Greenwood
6 */
7
8#include "audiosrv.h"
9
10#define NDEBUG
11#include <debug.h>
12
15
16
17/* This is for testing only! */
18VOID
20{
21 PnP_AudioDevice* list_node;
22
23 list_node = CreateDeviceDescriptor(L"ThisDeviceDoesNotReallyExist", TRUE);
24 AppendAudioDeviceToList(list_node);
25 DestroyDeviceDescriptor(list_node);
26}
27
30 DWORD dwControl,
31 DWORD dwEventType,
32 LPVOID lpEventData,
33 LPVOID lpContext)
34{
35 switch (dwControl)
36 {
38 {
39 DPRINT("* Interrogation\n");
40 return NO_ERROR;
41 }
42
45 {
46 DPRINT("* Service Stop/Shutdown request received\n");
47
48 DPRINT("Unregistering device notifications\n");
50
51 DPRINT("Destroying audio device list\n");
53
56
59
61
62 DPRINT("* Service stopped\n");
63
64 return NO_ERROR;
65 }
66
68 {
69 DPRINT("* Device Event\n");
70 return HandleDeviceEvent(dwEventType, lpEventData);
71 }
72
73 default :
75 };
76
77 /*SetServiceStatus(service_status_handle, &service_status);*/
78}
79
82{
83 DPRINT("* Service starting\n");
84 DPRINT("Registering service control handler\n");
87 NULL);
88
89 DPRINT("Service status handle %d\n", service_status_handle);
91 {
92 DPRINT("Failed to register service control handler\n");
93 /* FIXME - we should fail */
94 }
95
96 /* Set these to defaults */
103
104 /* Tell SCM we're starting */
107
108 DPRINT("Creating audio device list\n");
109 /* This creates the audio device list and mutex */
111 {
112 DPRINT("Failed to create audio device list\n");
116 return;
117 }
118
119 DPRINT("Registering for device notifications\n");
120 /* We want to know when devices are added/removed */
122 {
123 /* FIXME: This is not fatal at present as ROS does not support this */
124 DPRINT("Failed to register for device notifications\n");
125/*
126 DestroyAudioDeviceList();
127
128 service_status.dwCurrentState = SERVICE_STOPPED;
129 service_status.dwWin32ExitCode = -1;
130 SetServiceStatus(service_status_handle, &service_status);
131 return;
132*/
133 }
134 /* start system audio services */
136
138
139 DPRINT("Processing existing devices\n");
140 /* Now find any devices that already exist on the system */
142 {
143 DPRINT("Could not process existing devices\n");
146
150 return;
151 }
152
153 DPRINT("* Service started\n");
154 /* Tell SCM we are now running, and we may be stopped */
158}
159
161{
162 SERVICE_TABLE_ENTRYW service_table[] =
163 {
165 { NULL, NULL }
166 };
167
168 DPRINT("Audio Service main()\n");
169 if (!StartServiceCtrlDispatcherW(service_table))
170 DPRINT("StartServiceCtrlDispatcher failed\n");
171
172 return 0;
173}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
static int argc
Definition: ServiceArgs.c:12
BOOL RegisterForDeviceNotifications(VOID)
Definition: pnp.c:127
BOOL CreateAudioDeviceList(DWORD max_size)
BOOL AppendAudioDeviceToList(PnP_AudioDevice *device)
VOID UnregisterDeviceNotifications(VOID)
Definition: pnp.c:159
VOID DestroyAudioDeviceList(VOID)
BOOL StartSystemAudioServices(VOID)
Definition: services.c:72
#define DestroyDeviceDescriptor(descriptor)
Definition: audiosrv.h:30
DWORD HandleDeviceEvent(DWORD dwEventType, LPVOID lpEventData)
Definition: pnp.c:176
BOOL ProcessExistingDevices(VOID)
Definition: pnp.c:28
VOID * CreateDeviceDescriptor(WCHAR *path, BOOL is_enabled)
SERVICE_STATUS service_status
Definition: main.c:14
DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: main.c:29
VOID InitializeFakeDevice(VOID)
Definition: main.c:19
VOID CALLBACK ServiceMain(DWORD argc, LPWSTR argv)
Definition: main.c:81
SERVICE_STATUS_HANDLE service_status_handle
Definition: main.c:13
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define CALLBACK
Definition: compat.h:35
unsigned long DWORD
Definition: ntddk_ex.h:95
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
int wmain()
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1134
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
#define AUDIO_LIST_MAX_SIZE
Definition: audiosrv.h:25
#define DPRINT
Definition: sndvol32.h:73
DWORD dwServiceType
Definition: winsvc.h:99
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwControlsAccepted
Definition: winsvc.h:101
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwCurrentState
Definition: winsvc.h:100
DWORD dwCheckPoint
Definition: winsvc.h:104
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define WINAPI
Definition: msvc.h:6
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_CONTROL_DEVICEEVENT
Definition: winsvc.h:46
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
void(WINAPI * LPSERVICE_MAIN_FUNCTIONW)(DWORD, LPWSTR *)
Definition: winsvc.h:177
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
#define SERVICE_NAME
Definition: wlansvc.c:18
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962
WCHAR * LPWSTR
Definition: xmlstorage.h:184