[AUDIOSVC] Fix the coding style. No code changes!

This commit is contained in:
Eric Kohl 2019-07-27 16:54:15 +02:00
parent 6ee7cba77b
commit 353e05a4f3
5 changed files with 31 additions and 51 deletions

View file

@ -14,7 +14,7 @@ SERVICE_STATUS service_status;
/* This is for testing only! */ /* This is for testing only! */
VOID VOID
InitializeFakeDevice() InitializeFakeDevice(VOID)
{ {
PnP_AudioDevice* list_node; PnP_AudioDevice* list_node;
@ -30,7 +30,7 @@ ServiceControlHandler(
LPVOID lpEventData, LPVOID lpEventData,
LPVOID lpContext) LPVOID lpContext)
{ {
switch ( dwControl ) switch (dwControl)
{ {
case SERVICE_CONTROL_INTERROGATE : case SERVICE_CONTROL_INTERROGATE :
{ {
@ -85,7 +85,7 @@ ServiceMain(DWORD argc, LPWSTR argv)
NULL); NULL);
logmsg("Service status handle %d\n", service_status_handle); logmsg("Service status handle %d\n", service_status_handle);
if ( ! service_status_handle ) if (!service_status_handle)
{ {
logmsg("Failed to register service control handler\n"); logmsg("Failed to register service control handler\n");
/* FIXME - we should fail */ /* FIXME - we should fail */
@ -105,7 +105,7 @@ ServiceMain(DWORD argc, LPWSTR argv)
logmsg("Creating audio device list\n"); logmsg("Creating audio device list\n");
/* This creates the audio device list and mutex */ /* This creates the audio device list and mutex */
if ( ! CreateAudioDeviceList(AUDIO_LIST_MAX_SIZE) ) if (!CreateAudioDeviceList(AUDIO_LIST_MAX_SIZE))
{ {
logmsg("Failed to create audio device list\n"); logmsg("Failed to create audio device list\n");
service_status.dwCurrentState = SERVICE_STOPPED; service_status.dwCurrentState = SERVICE_STOPPED;
@ -116,7 +116,7 @@ ServiceMain(DWORD argc, LPWSTR argv)
logmsg("Registering for device notifications\n"); logmsg("Registering for device notifications\n");
/* We want to know when devices are added/removed */ /* We want to know when devices are added/removed */
if ( ! RegisterForDeviceNotifications() ) if (!RegisterForDeviceNotifications())
{ {
/* FIXME: This is not fatal at present as ROS does not support this */ /* FIXME: This is not fatal at present as ROS does not support this */
logmsg("Failed to register for device notifications\n"); logmsg("Failed to register for device notifications\n");
@ -132,12 +132,11 @@ ServiceMain(DWORD argc, LPWSTR argv)
/* start system audio services */ /* start system audio services */
StartSystemAudioServices(); StartSystemAudioServices();
InitializeFakeDevice(); InitializeFakeDevice();
logmsg("Processing existing devices\n"); logmsg("Processing existing devices\n");
/* Now find any devices that already exist on the system */ /* Now find any devices that already exist on the system */
if ( ! ProcessExistingDevices() ) if (!ProcessExistingDevices())
{ {
logmsg("Could not process existing devices\n"); logmsg("Could not process existing devices\n");
UnregisterDeviceNotifications(); UnregisterDeviceNotifications();
@ -156,7 +155,7 @@ ServiceMain(DWORD argc, LPWSTR argv)
SetServiceStatus(service_status_handle, &service_status); SetServiceStatus(service_status_handle, &service_status);
} }
int wmain() int wmain(VOID)
{ {
SERVICE_TABLE_ENTRYW service_table[] = SERVICE_TABLE_ENTRYW service_table[] =
{ {

View file

@ -23,7 +23,7 @@ static HDEVNOTIFY device_notification_handle = NULL;
*/ */
BOOL BOOL
ProcessExistingDevices() ProcessExistingDevices(VOID)
{ {
SP_DEVICE_INTERFACE_DATA interface_data; SP_DEVICE_INTERFACE_DATA interface_data;
SP_DEVINFO_DATA device_data; SP_DEVINFO_DATA device_data;
@ -124,7 +124,7 @@ ProcessDeviceArrival(DEV_BROADCAST_DEVICEINTERFACE* device)
*/ */
BOOL BOOL
RegisterForDeviceNotifications() RegisterForDeviceNotifications(VOID)
{ {
DEV_BROADCAST_DEVICEINTERFACE notification_filter; DEV_BROADCAST_DEVICEINTERFACE notification_filter;
@ -141,8 +141,7 @@ RegisterForDeviceNotifications()
DEVICE_NOTIFY_SERVICE_HANDLE DEVICE_NOTIFY_SERVICE_HANDLE
/* | /* |
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES*/); DEVICE_NOTIFY_ALL_INTERFACE_CLASSES*/);
if (!device_notification_handle)
if ( ! device_notification_handle )
{ {
logmsg("RegisterDeviceNotification() failed with error %d\n", GetLastError()); logmsg("RegisterDeviceNotification() failed with error %d\n", GetLastError());
} }
@ -156,11 +155,12 @@ RegisterForDeviceNotifications()
called. called.
*/ */
VOID UnregisterDeviceNotifications() VOID
UnregisterDeviceNotifications(VOID)
{ {
/* TODO -- NOT IMPLEMENTED! */ /* TODO -- NOT IMPLEMENTED! */
if ( device_notification_handle ) if (device_notification_handle)
{ {
/* TODO */ /* TODO */
device_notification_handle = NULL; device_notification_handle = NULL;
@ -177,12 +177,12 @@ HandleDeviceEvent(
DWORD dwEventType, DWORD dwEventType,
LPVOID lpEventData) LPVOID lpEventData)
{ {
switch ( dwEventType ) switch (dwEventType)
{ {
case DBT_DEVICEARRIVAL : case DBT_DEVICEARRIVAL:
{ {
DEV_BROADCAST_DEVICEINTERFACE* incoming_device = DEV_BROADCAST_DEVICEINTERFACE* incoming_device =
(DEV_BROADCAST_DEVICEINTERFACE*) lpEventData; (DEV_BROADCAST_DEVICEINTERFACE*)lpEventData;
return ProcessDeviceArrival(incoming_device); return ProcessDeviceArrival(incoming_device);
} }

View file

@ -13,7 +13,7 @@
static HANDLE audio_device_list_lock = NULL; static HANDLE audio_device_list_lock = NULL;
BOOL BOOL
InitializeAudioDeviceListLock() InitializeAudioDeviceListLock(VOID)
{ {
/* The security stuff is to make sure the mutex can be grabbed by /* The security stuff is to make sure the mutex can be grabbed by
other processes - is this the best idea though ??? */ other processes - is this the best idea though ??? */
@ -32,27 +32,26 @@ InitializeAudioDeviceListLock()
FALSE, FALSE,
AUDIO_LIST_LOCK_NAME); AUDIO_LIST_LOCK_NAME);
return ( audio_device_list_lock != NULL ); return (audio_device_list_lock != NULL);
} }
VOID VOID
KillAudioDeviceListLock() KillAudioDeviceListLock(VOID)
{ {
CloseHandle(audio_device_list_lock); CloseHandle(audio_device_list_lock);
audio_device_list_lock = NULL; audio_device_list_lock = NULL;
} }
VOID VOID
LockAudioDeviceList() LockAudioDeviceList(VOID)
{ {
assert( audio_device_list_lock != NULL ); assert(audio_device_list_lock != NULL);
WaitForSingleObject(audio_device_list_lock, INFINITE); WaitForSingleObject(audio_device_list_lock, INFINITE);
} }
VOID VOID
UnlockAudioDeviceList() UnlockAudioDeviceList(VOID)
{ {
assert( audio_device_list_lock != NULL ); assert(audio_device_list_lock != NULL);
ReleaseMutex(audio_device_list_lock); ReleaseMutex(audio_device_list_lock);
} }

View file

@ -23,8 +23,7 @@ CreateDeviceDescriptor(WCHAR* path, BOOL is_enabled)
/* printf("path_length %d, total %d\n", path_length, size);*/ /* printf("path_length %d, total %d\n", path_length, size);*/
device = malloc(size); device = malloc(size);
if (! device)
if ( ! device )
{ {
logmsg("Failed to create a device descriptor (malloc fail)\n"); logmsg("Failed to create a device descriptor (malloc fail)\n");
return NULL; return NULL;
@ -71,7 +70,7 @@ AppendAudioDeviceToList(PnP_AudioDevice* device)
*/ */
/* We DON'T want to overshoot the end of the buffer! */ /* We DON'T want to overshoot the end of the buffer! */
if ( audio_device_list->size + device_info_size > audio_device_list->max_size ) if (audio_device_list->size + device_info_size > audio_device_list->max_size)
{ {
/*printf("max_size would be exceeded! Failing...\n");*/ /*printf("max_size would be exceeded! Failing...\n");*/
@ -101,7 +100,7 @@ CreateAudioDeviceList(DWORD max_size)
{ {
/* printf("Initializing memory device list lock\n");*/ /* printf("Initializing memory device list lock\n");*/
if ( ! InitializeAudioDeviceListLock() ) if (!InitializeAudioDeviceListLock())
{ {
/*printf("Failed!\n");*/ /*printf("Failed!\n");*/
return FALSE; return FALSE;
@ -120,8 +119,7 @@ CreateAudioDeviceList(DWORD max_size)
0, 0,
max_size, max_size,
AUDIO_LIST_NAME); AUDIO_LIST_NAME);
if (!device_list_file)
if ( ! device_list_file )
{ {
logmsg("Creation of audio device list failed (err %d)\n", GetLastError()); logmsg("Creation of audio device list failed (err %d)\n", GetLastError());
@ -138,8 +136,7 @@ CreateAudioDeviceList(DWORD max_size)
0, 0,
0, 0,
max_size); max_size);
if (!audio_device_list)
if ( ! audio_device_list )
{ {
logmsg("MapViewOfFile FAILED (err %d)\n", GetLastError()); logmsg("MapViewOfFile FAILED (err %d)\n", GetLastError());
@ -168,7 +165,7 @@ CreateAudioDeviceList(DWORD max_size)
} }
VOID VOID
DestroyAudioDeviceList() DestroyAudioDeviceList(VOID)
{ {
logmsg("Destroying device list\n"); logmsg("Destroying device list\n");

View file

@ -30,7 +30,7 @@ WaitForService(
Sleep(1000); Sleep(1000);
}while(Index++ < RetryCount); } while (Index++ < RetryCount);
logmsg("Timeout while waiting for service to become ready %p\n", hService); logmsg("Timeout while waiting for service to become ready %p\n", hService);
@ -47,7 +47,6 @@ StartAudioService(
BOOL ret; BOOL ret;
hService = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS); hService = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS);
if (!hService) if (!hService)
{ {
logmsg("Failed to open service %S %x\n", ServiceName, GetLastError()); logmsg("Failed to open service %S %x\n", ServiceName, GetLastError());
@ -67,11 +66,8 @@ StartAudioService(
return ret; return ret;
} }
BOOL BOOL
StartSystemAudioServices() StartSystemAudioServices(VOID)
{ {
SC_HANDLE hSCManager; SC_HANDLE hSCManager;
@ -92,14 +88,3 @@ StartSystemAudioServices()
CloseServiceHandle(hSCManager); CloseServiceHandle(hSCManager);
return TRUE; return TRUE;
} }