ReactOS 0.4.15-dev-8116-gf69e256
services.c File Reference
#include "audiosrv.h"
#include <debug.h>
Include dependency graph for services.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL WaitForService (SC_HANDLE hService, ULONG RetryCount)
 
BOOL StartAudioService (SC_HANDLE hSCManager, LPWSTR ServiceName, ULONG RetryCount)
 
BOOL StartSystemAudioServices (VOID)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file services.c.

Function Documentation

◆ StartAudioService()

BOOL StartAudioService ( SC_HANDLE  hSCManager,
LPWSTR  ServiceName,
ULONG  RetryCount 
)

Definition at line 43 of file services.c.

47{
48 SC_HANDLE hService;
49 BOOL ret;
50
52 if (!hService)
53 {
54 DPRINT("Failed to open service %S %x\n", ServiceName, GetLastError());
55 return FALSE;
56 }
57
58 if (!StartService(hService, 0, NULL))
59 {
60 DPRINT("Failed to start service %S %x\n", ServiceName, GetLastError());
61 CloseServiceHandle(hService);
62 return FALSE;
63 }
64
65 ret = WaitForService(hService, RetryCount);
66
67 CloseServiceHandle(hService);
68 return ret;
69}
BOOL WaitForService(SC_HANDLE hService, ULONG RetryCount)
Definition: services.c:14
static WCHAR ServiceName[]
Definition: browser.c:19
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
SC_HANDLE hSCManager
Definition: sc.c:12
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define DPRINT
Definition: sndvol32.h:73
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SERVICE_ALL_ACCESS
Definition: winsvc.h:62
#define StartService
Definition: winsvc.h:585
#define OpenService
Definition: winsvc.h:576

Referenced by StartSystemAudioServices().

◆ StartSystemAudioServices()

BOOL StartSystemAudioServices ( VOID  )

Definition at line 72 of file services.c.

73{
74 SC_HANDLE hSCManager;
75
76 DPRINT("Starting system audio services\n");
77
79 if (!hSCManager)
80 {
81 DPRINT("Failed to open service manager %x\n", GetLastError());
82 return FALSE;
83 }
84
85 DPRINT("Starting sysaudio service\n");
86 StartAudioService(hSCManager, L"sysaudio", 20);
87 DPRINT("Starting wdmaud service\n");
88 StartAudioService(hSCManager, L"wdmaud", 20);
89
91 return TRUE;
92}
BOOL StartAudioService(SC_HANDLE hSCManager, LPWSTR ServiceName, ULONG RetryCount)
Definition: services.c:43
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
#define OpenSCManager
Definition: winsvc.h:575
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14

Referenced by ServiceMain().

◆ WaitForService()

BOOL WaitForService ( SC_HANDLE  hService,
ULONG  RetryCount 
)

Definition at line 14 of file services.c.

17{
18 ULONG Index = 0;
21
22 do
23 {
25 {
26 DPRINT("QueryServiceStatusEx failed %x\n", GetLastError());
27 break;
28 }
29
30 if (Info.dwCurrentState == SERVICE_RUNNING)
31 return TRUE;
32
33 Sleep(1000);
34
35 } while (Index++ < RetryCount);
36
37 DPRINT("Timeout while waiting for service to become ready %p\n", hService);
38
39 return FALSE;
40}
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2887
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFCOLLECTION _In_ ULONG Index
@ SC_STATUS_PROCESS_INFO
Definition: winsvc.h:119
#define SERVICE_RUNNING
Definition: winsvc.h:24

Referenced by StartAudioService().