mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
[0.4.7][AUDIOSRV] Update to master state 2023-02-18
by porting back: 0.4.15-dev-5710-g9672dc5047
CORE-16912 [AUDIOSRV] Overhaul logging interfaces (#5067) 0.4.15-dev-445-g353b544047
CORE-16814 [AUDIOSRV] Disable Logging to file (#2599) 0.4.13-dev-894-g5f7575909f
CORE-16307 [AUDIOSRV][BOOTDATA][INCLUDE][MMSYS] Rename RosAudioSrv to AudioSrv (#1826) 0.4.13-dev-715-g353e05a4f3
[AUDIOSRV] Fix the coding style. No code changes!
This commit is contained in:
parent
88908edc19
commit
3aea497ef5
12 changed files with 136 additions and 194 deletions
|
@ -5,11 +5,10 @@ list(APPEND SOURCE
|
||||||
pnp_list_lock.c
|
pnp_list_lock.c
|
||||||
pnp.c
|
pnp.c
|
||||||
services.c
|
services.c
|
||||||
debug.c
|
|
||||||
audiosrv.h)
|
audiosrv.h)
|
||||||
|
|
||||||
add_executable(audiosrv ${SOURCE} audiosrv.rc)
|
add_executable(audiosrv ${SOURCE} audiosrv.rc)
|
||||||
set_module_type(audiosrv win32cui UNICODE)
|
set_module_type(audiosrv win32cui UNICODE)
|
||||||
add_importlibs(audiosrv advapi32 user32 setupapi msvcrt kernel32)
|
add_importlibs(audiosrv advapi32 user32 setupapi msvcrt kernel32 ntdll)
|
||||||
add_pch(audiosrv audiosrv.h SOURCE)
|
add_pch(audiosrv audiosrv.h SOURCE)
|
||||||
add_cd_file(TARGET audiosrv DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET audiosrv DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/audiosrv.h
|
|
||||||
* PURPOSE: Audio Service (private header)
|
* PURPOSE: Audio Service (private header)
|
||||||
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
||||||
*/
|
*/
|
||||||
|
@ -62,10 +61,6 @@ HandleDeviceEvent(
|
||||||
BOOL
|
BOOL
|
||||||
StartSystemAudioServices(VOID);
|
StartSystemAudioServices(VOID);
|
||||||
|
|
||||||
/* Debugging */
|
|
||||||
|
|
||||||
void logmsg(char* string, ...);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _AUDIOSRV_PCH_ */
|
#endif /* _AUDIOSRV_PCH_ */
|
||||||
|
|
|
@ -19,18 +19,18 @@ subsequently passes to wdmaud.drv
|
||||||
It is not necessary to duplicate the exact structure of this mapped
|
It is not necessary to duplicate the exact structure of this mapped
|
||||||
file, since it appears to only be used internally by Windows components.
|
file, since it appears to only be used internally by Windows components.
|
||||||
|
|
||||||
The ROS Audio Service (RosAudioSrv) is intended to be able to run
|
The ROS Audio Service (AudioSrv) is intended to be able to run
|
||||||
alongside the Windows Audio Service on XP/Vista, so it should be
|
alongside the Windows Audio Service on XP/Vista, so it should be
|
||||||
possible to test in a "known working environment" ;)
|
possible to test in a "known working environment" ;)
|
||||||
|
|
||||||
It will create a mutex, to:
|
It will create a mutex, to:
|
||||||
1) Allow synchronization when accessing the device list
|
1) Allow synchronization when accessing the device list
|
||||||
2) Provide a simple method of identifying if RosAudioSrv is running
|
2) Provide a simple method of identifying if AudioSrv is running
|
||||||
|
|
||||||
(It might be worth using an event to notify WinMM when things are
|
(It might be worth using an event to notify WinMM when things are
|
||||||
happening?)
|
happening?)
|
||||||
|
|
||||||
The intention is to make RosAudioSrv receive PnP notifications for
|
The intention is to make AudioSrv receive PnP notifications for
|
||||||
relevant audio devices, and also let AudioSrv in Windows do this. Then
|
relevant audio devices, and also let AudioSrv in Windows do this. Then
|
||||||
it should be possible to create a small application that imitates
|
it should be possible to create a small application that imitates
|
||||||
WinMM's actions :)
|
WinMM's actions :)
|
||||||
|
@ -54,12 +54,12 @@ Testing the Service
|
||||||
===================
|
===================
|
||||||
|
|
||||||
The service can be installed on Windows XP (possibly also Vista) like so:
|
The service can be installed on Windows XP (possibly also Vista) like so:
|
||||||
sc create RosAudioSrv <path to audiosrv.exe>
|
sc create AudioSrv <path to audiosrv.exe>
|
||||||
net start RosAudioSrv
|
net start AudioSrv
|
||||||
|
|
||||||
...and can be removed like so:
|
...and can be removed like so:
|
||||||
net stop RosAudioSrv
|
net stop AudioSrv
|
||||||
sc delete RosAudioSrv
|
sc delete AudioSrv
|
||||||
|
|
||||||
You can view a list of the currently available devices (device list is
|
You can view a list of the currently available devices (device list is
|
||||||
identical to the one offered by Windows' own AudioSrv) by running
|
identical to the one offered by Windows' own AudioSrv) by running
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/* Service debugging (simply logs to a file) */
|
|
||||||
|
|
||||||
#include "audiosrv.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void logmsg(char* string, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
FILE* debug_file = fopen("c:\\audiosrv-debug.txt", "a");
|
|
||||||
|
|
||||||
if (debug_file)
|
|
||||||
{
|
|
||||||
va_start(args, string);
|
|
||||||
vfprintf(debug_file, string, args);
|
|
||||||
va_end(args);
|
|
||||||
fclose(debug_file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char buf[256];
|
|
||||||
va_start(args, string);
|
|
||||||
vsprintf(buf, string, args);
|
|
||||||
OutputDebugStringA(buf);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +1,22 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/main.c
|
|
||||||
* PURPOSE: Audio Service
|
* PURPOSE: Audio Service
|
||||||
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audiosrv.h"
|
#include "audiosrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
SERVICE_STATUS_HANDLE service_status_handle;
|
SERVICE_STATUS_HANDLE service_status_handle;
|
||||||
SERVICE_STATUS service_status;
|
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,23 +32,23 @@ ServiceControlHandler(
|
||||||
LPVOID lpEventData,
|
LPVOID lpEventData,
|
||||||
LPVOID lpContext)
|
LPVOID lpContext)
|
||||||
{
|
{
|
||||||
switch ( dwControl )
|
switch (dwControl)
|
||||||
{
|
{
|
||||||
case SERVICE_CONTROL_INTERROGATE :
|
case SERVICE_CONTROL_INTERROGATE :
|
||||||
{
|
{
|
||||||
logmsg("* Interrogation\n");
|
DPRINT("* Interrogation\n");
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SERVICE_CONTROL_STOP :
|
case SERVICE_CONTROL_STOP :
|
||||||
case SERVICE_CONTROL_SHUTDOWN :
|
case SERVICE_CONTROL_SHUTDOWN :
|
||||||
{
|
{
|
||||||
logmsg("* Service Stop/Shutdown request received\n");
|
DPRINT("* Service Stop/Shutdown request received\n");
|
||||||
|
|
||||||
logmsg("Unregistering device notifications\n");
|
DPRINT("Unregistering device notifications\n");
|
||||||
UnregisterDeviceNotifications();
|
UnregisterDeviceNotifications();
|
||||||
|
|
||||||
logmsg("Destroying audio device list\n");
|
DPRINT("Destroying audio device list\n");
|
||||||
DestroyAudioDeviceList();
|
DestroyAudioDeviceList();
|
||||||
|
|
||||||
service_status.dwCurrentState = SERVICE_STOP_PENDING;
|
service_status.dwCurrentState = SERVICE_STOP_PENDING;
|
||||||
|
@ -57,14 +59,14 @@ ServiceControlHandler(
|
||||||
|
|
||||||
SetServiceStatus(service_status_handle, &service_status);
|
SetServiceStatus(service_status_handle, &service_status);
|
||||||
|
|
||||||
logmsg("* Service stopped\n");
|
DPRINT("* Service stopped\n");
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SERVICE_CONTROL_DEVICEEVENT :
|
case SERVICE_CONTROL_DEVICEEVENT :
|
||||||
{
|
{
|
||||||
logmsg("* Device Event\n");
|
DPRINT("* Device Event\n");
|
||||||
return HandleDeviceEvent(dwEventType, lpEventData);
|
return HandleDeviceEvent(dwEventType, lpEventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +80,16 @@ ServiceControlHandler(
|
||||||
VOID CALLBACK
|
VOID CALLBACK
|
||||||
ServiceMain(DWORD argc, LPWSTR argv)
|
ServiceMain(DWORD argc, LPWSTR argv)
|
||||||
{
|
{
|
||||||
logmsg("* Service starting\n");
|
DPRINT("* Service starting\n");
|
||||||
logmsg("Registering service control handler...\n");
|
DPRINT("Registering service control handler\n");
|
||||||
service_status_handle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
|
service_status_handle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
|
||||||
ServiceControlHandler,
|
ServiceControlHandler,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
logmsg("Service status handle %d\n", service_status_handle);
|
DPRINT("Service status handle %d\n", service_status_handle);
|
||||||
if ( ! service_status_handle )
|
if (!service_status_handle)
|
||||||
{
|
{
|
||||||
logmsg("Failed to register service control handler\n");
|
DPRINT("Failed to register service control handler\n");
|
||||||
/* FIXME - we should fail */
|
/* FIXME - we should fail */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,23 +105,23 @@ ServiceMain(DWORD argc, LPWSTR argv)
|
||||||
service_status.dwCurrentState = SERVICE_START_PENDING;
|
service_status.dwCurrentState = SERVICE_START_PENDING;
|
||||||
SetServiceStatus(service_status_handle, &service_status);
|
SetServiceStatus(service_status_handle, &service_status);
|
||||||
|
|
||||||
logmsg("Creating audio device list\n");
|
DPRINT("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");
|
DPRINT("Failed to create audio device list\n");
|
||||||
service_status.dwCurrentState = SERVICE_STOPPED;
|
service_status.dwCurrentState = SERVICE_STOPPED;
|
||||||
service_status.dwWin32ExitCode = -1;
|
service_status.dwWin32ExitCode = -1;
|
||||||
SetServiceStatus(service_status_handle, &service_status);
|
SetServiceStatus(service_status_handle, &service_status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg("Registering for device notifications\n");
|
DPRINT("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");
|
DPRINT("Failed to register for device notifications\n");
|
||||||
/*
|
/*
|
||||||
DestroyAudioDeviceList();
|
DestroyAudioDeviceList();
|
||||||
|
|
||||||
|
@ -132,14 +134,13 @@ ServiceMain(DWORD argc, LPWSTR argv)
|
||||||
/* start system audio services */
|
/* start system audio services */
|
||||||
StartSystemAudioServices();
|
StartSystemAudioServices();
|
||||||
|
|
||||||
|
|
||||||
InitializeFakeDevice();
|
InitializeFakeDevice();
|
||||||
|
|
||||||
logmsg("Processing existing devices\n");
|
DPRINT("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");
|
DPRINT("Could not process existing devices\n");
|
||||||
UnregisterDeviceNotifications();
|
UnregisterDeviceNotifications();
|
||||||
DestroyAudioDeviceList();
|
DestroyAudioDeviceList();
|
||||||
|
|
||||||
|
@ -149,14 +150,14 @@ ServiceMain(DWORD argc, LPWSTR argv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg("* Service started\n");
|
DPRINT("* Service started\n");
|
||||||
/* Tell SCM we are now running, and we may be stopped */
|
/* Tell SCM we are now running, and we may be stopped */
|
||||||
service_status.dwCurrentState = SERVICE_RUNNING;
|
service_status.dwCurrentState = SERVICE_RUNNING;
|
||||||
service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
||||||
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[] =
|
||||||
{
|
{
|
||||||
|
@ -164,9 +165,9 @@ int wmain()
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
logmsg("Audio Service main()\n");
|
DPRINT("Audio Service main()\n");
|
||||||
if (!StartServiceCtrlDispatcherW(service_table))
|
if (!StartServiceCtrlDispatcherW(service_table))
|
||||||
logmsg("StartServiceCtrlDispatcher failed\n");
|
DPRINT("StartServiceCtrlDispatcher failed\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/pnp.c
|
|
||||||
* PURPOSE: Audio Service Plug and Play
|
* PURPOSE: Audio Service Plug and Play
|
||||||
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +14,9 @@
|
||||||
#include <ks.h>
|
#include <ks.h>
|
||||||
#include <ksmedia.h>
|
#include <ksmedia.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
static HDEVNOTIFY device_notification_handle = NULL;
|
static HDEVNOTIFY device_notification_handle = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,7 +25,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;
|
||||||
|
@ -42,8 +44,6 @@ ProcessExistingDevices()
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* printf("%s:\n", ClassString); */
|
|
||||||
|
|
||||||
interface_data.cbSize = sizeof(interface_data);
|
interface_data.cbSize = sizeof(interface_data);
|
||||||
interface_data.Reserved = 0;
|
interface_data.Reserved = 0;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ ProcessExistingDevices()
|
||||||
|
|
||||||
if ( ! detail_data )
|
if ( ! detail_data )
|
||||||
{
|
{
|
||||||
logmsg("ProcessExistingDevices() failed to allocate detail_data\n");
|
DPRINT("failed to allocate detail_data\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,10 +141,9 @@ 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());
|
DPRINT("failed with error %d\n", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( device_notification_handle != NULL );
|
return ( device_notification_handle != NULL );
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/pnp_list_lock.c
|
|
||||||
* PURPOSE: Audio Service Plug and Play list locking mechanism
|
* PURPOSE: Audio Service Plug and Play list locking mechanism
|
||||||
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +12,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 +31,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/pnp_list_manager.c
|
|
||||||
* PURPOSE: Audio Service List Manager
|
* PURPOSE: Audio Service List Manager
|
||||||
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
* COPYRIGHT: Copyright 2007 Andrew Greenwood
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audiosrv.h"
|
#include "audiosrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Device descriptor
|
Device descriptor
|
||||||
*/
|
*/
|
||||||
|
@ -20,13 +22,10 @@ CreateDeviceDescriptor(WCHAR* path, BOOL is_enabled)
|
||||||
int path_length = WideStringSize(path);
|
int path_length = WideStringSize(path);
|
||||||
int size = sizeof(PnP_AudioDevice) + path_length;
|
int size = sizeof(PnP_AudioDevice) + path_length;
|
||||||
|
|
||||||
/* 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");
|
DPRINT("Failed to malloc device descriptor\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,15 +64,10 @@ AppendAudioDeviceToList(PnP_AudioDevice* device)
|
||||||
|
|
||||||
LockAudioDeviceList();
|
LockAudioDeviceList();
|
||||||
|
|
||||||
/*
|
|
||||||
printf("list size is %d\n", audio_device_list->size);
|
|
||||||
printf("device info size is %d bytes\n", device_info_size);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* 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");*/
|
/*DPRINT("failed, max_size would be exceeded\n");*/
|
||||||
|
|
||||||
UnlockAudioDeviceList();
|
UnlockAudioDeviceList();
|
||||||
|
|
||||||
|
@ -91,7 +85,7 @@ AppendAudioDeviceToList(PnP_AudioDevice* device)
|
||||||
|
|
||||||
UnlockAudioDeviceList();
|
UnlockAudioDeviceList();
|
||||||
|
|
||||||
logmsg("Device added to list\n");
|
DPRINT("Device added to list\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -99,11 +93,9 @@ AppendAudioDeviceToList(PnP_AudioDevice* device)
|
||||||
BOOL
|
BOOL
|
||||||
CreateAudioDeviceList(DWORD max_size)
|
CreateAudioDeviceList(DWORD max_size)
|
||||||
{
|
{
|
||||||
/* printf("Initializing memory device list lock\n");*/
|
if (!InitializeAudioDeviceListLock())
|
||||||
|
|
||||||
if ( ! InitializeAudioDeviceListLock() )
|
|
||||||
{
|
{
|
||||||
/*printf("Failed!\n");*/
|
/*DPRINT("Failed\n");*/
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +104,7 @@ CreateAudioDeviceList(DWORD max_size)
|
||||||
turning up before we're ready... */
|
turning up before we're ready... */
|
||||||
LockAudioDeviceList();
|
LockAudioDeviceList();
|
||||||
|
|
||||||
logmsg("Creating file mapping\n");
|
DPRINT("Creating file mapping\n");
|
||||||
/* Expose our device list to the world */
|
/* Expose our device list to the world */
|
||||||
device_list_file = CreateFileMappingW(INVALID_HANDLE_VALUE,
|
device_list_file = CreateFileMappingW(INVALID_HANDLE_VALUE,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -120,10 +112,9 @@ 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());
|
DPRINT("Creation of audio device list failed (err %d)\n", GetLastError());
|
||||||
|
|
||||||
UnlockAudioDeviceList();
|
UnlockAudioDeviceList();
|
||||||
KillAudioDeviceListLock();
|
KillAudioDeviceListLock();
|
||||||
|
@ -131,17 +122,16 @@ CreateAudioDeviceList(DWORD max_size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg("Mapping view of file\n");
|
DPRINT("Mapping view of file\n");
|
||||||
/* Of course, we'll need to access the list ourselves */
|
/* Of course, we'll need to access the list ourselves */
|
||||||
audio_device_list = MapViewOfFile(device_list_file,
|
audio_device_list = MapViewOfFile(device_list_file,
|
||||||
FILE_MAP_WRITE,
|
FILE_MAP_WRITE,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
max_size);
|
max_size);
|
||||||
|
if (!audio_device_list)
|
||||||
if ( ! audio_device_list )
|
|
||||||
{
|
{
|
||||||
logmsg("MapViewOfFile FAILED (err %d)\n", GetLastError());
|
DPRINT("MapViewOfFile FAILED (err %d)\n", GetLastError());
|
||||||
|
|
||||||
CloseHandle(device_list_file);
|
CloseHandle(device_list_file);
|
||||||
device_list_file = NULL;
|
device_list_file = NULL;
|
||||||
|
@ -162,28 +152,28 @@ CreateAudioDeviceList(DWORD max_size)
|
||||||
|
|
||||||
UnlockAudioDeviceList();
|
UnlockAudioDeviceList();
|
||||||
|
|
||||||
logmsg("Device list created\n");
|
DPRINT("Device list created\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DestroyAudioDeviceList()
|
DestroyAudioDeviceList(VOID)
|
||||||
{
|
{
|
||||||
logmsg("Destroying device list\n");
|
DPRINT("Destroying device list\n");
|
||||||
|
|
||||||
LockAudioDeviceList();
|
LockAudioDeviceList();
|
||||||
|
|
||||||
/*printf("Unmapping view\n");*/
|
/*DPRINT("Unmapping view\n");*/
|
||||||
UnmapViewOfFile(audio_device_list);
|
UnmapViewOfFile(audio_device_list);
|
||||||
audio_device_list = NULL;
|
audio_device_list = NULL;
|
||||||
|
|
||||||
/*printf("Closing memory mapped file\n");*/
|
/*DPRINT("Closing memory mapped file\n");*/
|
||||||
CloseHandle(device_list_file);
|
CloseHandle(device_list_file);
|
||||||
device_list_file = NULL;
|
device_list_file = NULL;
|
||||||
|
|
||||||
UnlockAudioDeviceList();
|
UnlockAudioDeviceList();
|
||||||
|
|
||||||
/*printf("Killing devlist lock\n");*/
|
/*DPRINT("Killing devlist lock\n");*/
|
||||||
KillAudioDeviceListLock();
|
KillAudioDeviceListLock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS
|
* PROJECT: ReactOS
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: base/services/audiosrv/services.c
|
|
||||||
* PURPOSE: Audio Service Plug and Play
|
* PURPOSE: Audio Service Plug and Play
|
||||||
* COPYRIGHT: Copyright 2009 Johannes Anderwald
|
* COPYRIGHT: Copyright 2009 Johannes Anderwald
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audiosrv.h"
|
#include "audiosrv.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
WaitForService(
|
WaitForService(
|
||||||
SC_HANDLE hService,
|
SC_HANDLE hService,
|
||||||
|
@ -21,7 +23,7 @@ WaitForService(
|
||||||
{
|
{
|
||||||
if (!QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, (LPBYTE)&Info, sizeof(SERVICE_STATUS_PROCESS), &dwSize))
|
if (!QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, (LPBYTE)&Info, sizeof(SERVICE_STATUS_PROCESS), &dwSize))
|
||||||
{
|
{
|
||||||
logmsg("QueryServiceStatusEx failed %x\n", GetLastError());
|
DPRINT("QueryServiceStatusEx failed %x\n", GetLastError());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +32,9 @@ WaitForService(
|
||||||
|
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
|
|
||||||
}while(Index++ < RetryCount);
|
} while (Index++ < RetryCount);
|
||||||
|
|
||||||
logmsg("Timeout while waiting for service to become ready %p\n", hService);
|
DPRINT("Timeout while waiting for service to become ready %p\n", hService);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -47,16 +49,15 @@ 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());
|
DPRINT("Failed to open service %S %x\n", ServiceName, GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StartService(hService, 0, NULL))
|
if (!StartService(hService, 0, NULL))
|
||||||
{
|
{
|
||||||
logmsg("Failed to start service %S %x\n", ServiceName, GetLastError());
|
DPRINT("Failed to start service %S %x\n", ServiceName, GetLastError());
|
||||||
CloseServiceHandle(hService);
|
CloseServiceHandle(hService);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -67,39 +68,25 @@ StartAudioService(
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
StartSystemAudioServices()
|
StartSystemAudioServices(VOID)
|
||||||
{
|
{
|
||||||
SC_HANDLE hSCManager;
|
SC_HANDLE hSCManager;
|
||||||
|
|
||||||
logmsg("Starting system audio services\n");
|
DPRINT("Starting system audio services\n");
|
||||||
|
|
||||||
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
||||||
if (!hSCManager)
|
if (!hSCManager)
|
||||||
{
|
{
|
||||||
logmsg("Failed to open service manager %x\n", GetLastError());
|
DPRINT("Failed to open service manager %x\n", GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
logmsg("Starting sysaudio service\n");
|
DPRINT("Starting sysaudio service\n");
|
||||||
StartAudioService(hSCManager, L"sysaudio", 20);
|
StartAudioService(hSCManager, L"sysaudio", 20);
|
||||||
logmsg("Starting wdmaud service\n");
|
DPRINT("Starting wdmaud service\n");
|
||||||
StartAudioService(hSCManager, L"wdmaud", 20);
|
StartAudioService(hSCManager, L"wdmaud", 20);
|
||||||
|
|
||||||
CloseServiceHandle(hSCManager);
|
CloseServiceHandle(hSCManager);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1477,14 +1477,14 @@ HKLM,"SYSTEM\CurrentControlSet\Services\swenum","Start",0x00010001,0x00000000
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\swenum","Type",0x00010001,0x00000001
|
HKLM,"SYSTEM\CurrentControlSet\Services\swenum","Type",0x00010001,0x00000001
|
||||||
|
|
||||||
; Audio Service
|
; Audio Service
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","DisplayName",0x00000000,%AUDIO_SERVICE%
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","DisplayName",0x00000000,%AUDIO_SERVICE%
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","Description",0x00000000,%AUDIO_SERVICE_DESCRIPTION%
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Description",0x00000000,%AUDIO_SERVICE_DESCRIPTION%
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","ErrorControl",0x00010001,0x00000000
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","ErrorControl",0x00010001,0x00000000
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","Group",0x00000000,"Audio"
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Group",0x00000000,"Audio"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","ImagePath",0x00020000,"%SystemRoot%\system32\audiosrv.exe"
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","ImagePath",0x00020000,"%SystemRoot%\system32\audiosrv.exe"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","ObjectName",0x00000000,"LocalSystem"
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","ObjectName",0x00000000,"LocalSystem"
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","Start",0x00010001,0x00000003
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Start",0x00010001,0x00000003
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\RosAudioSrv","Type",0x00010001,0x00000010
|
HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Type",0x00010001,0x00000010
|
||||||
|
|
||||||
; Background Intelligent Transfer Service (BITS)
|
; Background Intelligent Transfer Service (BITS)
|
||||||
HKLM,"SYSTEM\CurrentControlSet\Services\BITS","DisplayName",0x00000000,%BITS_SERVICE%
|
HKLM,"SYSTEM\CurrentControlSet\Services\BITS","DisplayName",0x00000000,%BITS_SERVICE%
|
||||||
|
|
|
@ -553,10 +553,10 @@ MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
|
||||||
return ERROR_DI_DO_DEFAULT;
|
return ERROR_DI_DO_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
hService = OpenService(hSCManager, L"RosAudioSrv", SERVICE_ALL_ACCESS);
|
hService = OpenService(hSCManager, L"AudioSrv", SERVICE_ALL_ACCESS);
|
||||||
if (hService)
|
if (hService)
|
||||||
{
|
{
|
||||||
/* Make RosAudioSrv start automatically */
|
/* Make AudioSrv start automatically */
|
||||||
ChangeServiceConfig(hService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
ChangeServiceConfig(hService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
StartService(hService, 0, NULL);
|
StartService(hService, 0, NULL);
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
#ifndef AUDIOSRV_H
|
#ifndef AUDIOSRV_H
|
||||||
#define AUDIOSRV_H
|
#define AUDIOSRV_H
|
||||||
|
|
||||||
/* This is currently set to avoid conflicting service names in Windows! */
|
/* The service name */
|
||||||
#define SERVICE_NAME L"RosAudioSrv"
|
#define SERVICE_NAME L"AudioSrv"
|
||||||
|
|
||||||
/* A named mutex is used for synchronizing access to the device list.
|
/* A named mutex is used for synchronizing access to the device list.
|
||||||
If this mutex doesn't exist, it means the audio service isn't running. */
|
If this mutex doesn't exist, it means the audio service isn't running. */
|
||||||
|
|
Loading…
Reference in a new issue