Author: silverblade Date: Wed Sep 19 20:54:25 2007 New Revision: 29108
URL: http://svn.reactos.org/svn/reactos?rev=29108&view=rev Log: Set service to manual start, and implemented a quick debug-logging solution. ReactOS does not currently have RegisterDeviceNotification implemented so if this function fails the audio service will still run but won't receive plug and play event notifications (this is a temporary hack.) Service now starts but won't find any devices (we don't have any yet!)
Added: trunk/reactos/base/services/audiosrv/debug.c (with props) Modified: trunk/reactos/base/services/audiosrv/audiosrv.h trunk/reactos/base/services/audiosrv/audiosrv.rbuild (contents, props changed) trunk/reactos/base/services/audiosrv/audiosrv.rc (props changed) trunk/reactos/base/services/audiosrv/audiosrv.txt (contents, props changed) trunk/reactos/base/services/audiosrv/main.c (contents, props changed) trunk/reactos/base/services/audiosrv/pnp.c (contents, props changed) trunk/reactos/base/services/audiosrv/pnp_list_lock.c (props changed) trunk/reactos/base/services/audiosrv/pnp_list_manager.c (contents, props changed) trunk/reactos/boot/bootdata/hivesys.inf trunk/reactos/boot/bootdata/packages/reactos.dff
Modified: trunk/reactos/base/services/audiosrv/audiosrv.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/audi... ============================================================================== --- trunk/reactos/base/services/audiosrv/audiosrv.h (original) +++ trunk/reactos/base/services/audiosrv/audiosrv.h Wed Sep 19 20:54:25 2007 @@ -61,4 +61,9 @@ DWORD dwEventType, LPVOID lpEventData);
+ +/* Debugging */ + +void logmsg(char* string, ...); + #endif
Modified: trunk/reactos/base/services/audiosrv/audiosrv.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/audi... ============================================================================== --- trunk/reactos/base/services/audiosrv/audiosrv.rbuild (original) +++ trunk/reactos/base/services/audiosrv/audiosrv.rbuild Wed Sep 19 20:54:25 2007 @@ -14,5 +14,6 @@ <file>pnp_list_manager.c</file> <file>pnp_list_lock.c</file> <file>pnp.c</file> + <file>debug.c</file> <file>audiosrv.rc</file> </module>
Propchange: trunk/reactos/base/services/audiosrv/audiosrv.rbuild ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Propchange: trunk/reactos/base/services/audiosrv/audiosrv.rc ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Modified: trunk/reactos/base/services/audiosrv/audiosrv.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/audi... ============================================================================== --- trunk/reactos/base/services/audiosrv/audiosrv.txt (original) +++ trunk/reactos/base/services/audiosrv/audiosrv.txt Wed Sep 19 20:54:25 2007 @@ -9,6 +9,9 @@
AudioSrv on Windows creates a mapped file at: Global\mmGlobalPnpInfo + +The ReactOS audio device list lives at: +Global\AudioDeviceList
This file appears to contain a list of devices that WinMM accesses and subsequently passes to wdmaud.drv @@ -32,7 +35,39 @@ it should be possible to create a small application that imitates WinMM's actions :)
-So far, it doesn't do much... Watch this space! + +Current Status +============== + +AudioSrv registers for device notifications and obtains a list of the +current audio devices in the system (devices registered against the +KSCATEGORY_AUDIO interface). + +ReactOS does not currently have RegisterDeviceNotification implemented, +so for the moment this service considers the failure of this API call +to be non-fatal and will proceed without device event notification. This +behaviour will be amended in a future revision (ie once this API call +is implemented!) + + +Testing the Service +=================== + +The service can be installed on Windows XP (possibly also Vista) like so: +sc create RosAudioSrv <path to audiosrv.exe> +net start RosAudioSrv + +...and can be removed like so: +net stop RosAudioSrv +sc delete RosAudioSrv + +You can view a list of the currently available devices (device list is +identical to the one offered by Windows' own AudioSrv) by running +my READER.EXE test utility, available in the following package: + +http://stuff.silverblade.co.uk/reactos/sharedlist.tar.gz + +That's all for now, folks ;)
Andrew Greenwood
Propchange: trunk/reactos/base/services/audiosrv/audiosrv.txt ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Added: trunk/reactos/base/services/audiosrv/debug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/debu... ============================================================================== --- trunk/reactos/base/services/audiosrv/debug.c (added) +++ trunk/reactos/base/services/audiosrv/debug.c Wed Sep 19 20:54:25 2007 @@ -1,0 +1,19 @@ +/* Service debugging (simply logs to a file) */ + +#include <stdio.h> +#include <stdarg.h> + +void logmsg(char* string, ...) +{ + va_list args; + + FILE* debug_file = fopen("c:\audiosrv-debug.txt", "a"); + + va_start(args, string); + + vfprintf(debug_file, string, args); + + va_end(args); + + fclose(debug_file); +}
Propchange: trunk/reactos/base/services/audiosrv/debug.c ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Modified: trunk/reactos/base/services/audiosrv/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/main... ============================================================================== --- trunk/reactos/base/services/audiosrv/main.c (original) +++ trunk/reactos/base/services/audiosrv/main.c Wed Sep 19 20:54:25 2007 @@ -35,13 +35,19 @@ { case SERVICE_CONTROL_INTERROGATE : { + logmsg("* Interrogation\n"); return NO_ERROR; }
case SERVICE_CONTROL_STOP : case SERVICE_CONTROL_SHUTDOWN : { + logmsg("* Service Stop/Shutdown request received\n"); + + logmsg("Unregistering device notifications\n"); UnregisterDeviceNotifications(); + + logmsg("Destroying audio device list\n"); DestroyAudioDeviceList();
service_status.dwCurrentState = SERVICE_STOP_PENDING; @@ -52,11 +58,14 @@
SetServiceStatus(service_status_handle, &service_status);
+ logmsg("* Service stopped\n"); + return NO_ERROR; }
case SERVICE_CONTROL_DEVICEEVENT : { + logmsg("* Device Event\n"); return HandleDeviceEvent(dwEventType, lpEventData); }
@@ -70,9 +79,14 @@ VOID CALLBACK ServiceMain(DWORD argc, char** argv) { + logmsg("* Service starting\n"); + logmsg("Registering service control handler...\n"); service_status_handle = RegisterServiceCtrlHandlerEx(SERVICE_NAME, ServiceControlHandler, NULL); + + logmsg("Service status handle %d\n", service_status_handle); + /* TODO: Deal with errors */
/* Set these to defaults */ service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; @@ -86,29 +100,38 @@ service_status.dwCurrentState = SERVICE_START_PENDING; SetServiceStatus(service_status_handle, &service_status);
+ logmsg("Creating audio device list\n"); /* This creates the audio device list and mutex */ if ( ! CreateAudioDeviceList(AUDIO_LIST_MAX_SIZE) ) { + logmsg("Failed to create audio device list\n"); service_status.dwCurrentState = SERVICE_STOPPED; service_status.dwWin32ExitCode = -1; SetServiceStatus(service_status_handle, &service_status); return; }
+ logmsg("Registering for device notifications\n"); /* We want to know when devices are added/removed */ if ( ! RegisterForDeviceNotifications() ) { + /* FIXME: This is not fatal at present as ROS does not support this */ + logmsg("Failed to register for device notifications\n"); +/* DestroyAudioDeviceList();
service_status.dwCurrentState = SERVICE_STOPPED; service_status.dwWin32ExitCode = -1; SetServiceStatus(service_status_handle, &service_status); return; +*/ }
+ logmsg("Processing existing devices\n"); /* Now find any devices that already exist on the system */ if ( ! ProcessExistingDevices() ) { + logmsg("Could not process existing devices\n"); UnregisterDeviceNotifications(); DestroyAudioDeviceList();
@@ -118,6 +141,7 @@ return; }
+ logmsg("* Service started"); /* Tell SCM we are now running, and we may be stopped */ service_status.dwCurrentState = SERVICE_RUNNING; service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; @@ -126,6 +150,7 @@
int main() { + logmsg("Audio Service main()\n"); StartServiceCtrlDispatcher(service_table); return 0; }
Propchange: trunk/reactos/base/services/audiosrv/main.c ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Modified: trunk/reactos/base/services/audiosrv/pnp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/pnp.... ============================================================================== --- trunk/reactos/base/services/audiosrv/pnp.c (original) +++ trunk/reactos/base/services/audiosrv/pnp.c Wed Sep 19 20:54:25 2007 @@ -127,7 +127,6 @@
const GUID wdmaud_guid = {STATIC_KSCATEGORY_AUDIO};
- /* FIXME: This currently lists ALL device interfaces... */ ZeroMemory(¬ification_filter, sizeof(notification_filter)); notification_filter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); notification_filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; @@ -139,6 +138,11 @@ DEVICE_NOTIFY_SERVICE_HANDLE /* | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES*/); + + if ( ! device_notification_handle ) + { + logmsg("RegisterDeviceNotification() failed with error %d\n", GetLastError()); + }
return ( device_notification_handle != NULL ); } @@ -152,7 +156,12 @@ VOID UnregisterDeviceNotifications() { /* TODO -- NOT IMPLEMENTED! */ - device_notification_handle = NULL; + + if ( device_notification_handle ) + { + /* TODO */ + device_notification_handle = NULL; + } }
Propchange: trunk/reactos/base/services/audiosrv/pnp.c ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Propchange: trunk/reactos/base/services/audiosrv/pnp_list_lock.c ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Modified: trunk/reactos/base/services/audiosrv/pnp_list_manager.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/audiosrv/pnp_... ============================================================================== --- trunk/reactos/base/services/audiosrv/pnp_list_manager.c (original) +++ trunk/reactos/base/services/audiosrv/pnp_list_manager.c Wed Sep 19 20:54:25 2007 @@ -8,6 +8,7 @@
#include <assert.h> #include <audiosrv/audiosrv.h> +#include "audiosrv.h"
/* @@ -27,7 +28,10 @@ device = malloc(size);
if ( ! device ) + { + log("Failed to create a device descriptor (malloc fail)\n"); return NULL; + }
device->enabled = is_enabled; memcpy(device->path, path, path_length); @@ -72,9 +76,7 @@ /* We DON'T want to overshoot the end of the buffer! */ 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"); return FALSE; }
@@ -88,6 +90,8 @@ audio_device_list->size += device_info_size;
UnlockAudioDeviceList(); + + log("Device added to list\n");
return TRUE; } @@ -108,6 +112,7 @@ turning up before we're ready... */ LockAudioDeviceList();
+ log("Creating file mapping\n"); /* Expose our device list to the world */ device_list_file = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, @@ -118,7 +123,7 @@
if ( ! device_list_file ) { - /*printf("Creation of audio device list FAILED!\n");*/ + log("Creation of audio device list failed (err %d)\n", GetLastError());
UnlockAudioDeviceList(); KillAudioDeviceListLock(); @@ -126,6 +131,7 @@ return FALSE; }
+ log("Mapping view of file\n"); /* Of course, we'll need to access the list ourselves */ audio_device_list = MapViewOfFile(device_list_file, FILE_MAP_WRITE, @@ -135,7 +141,7 @@
if ( ! audio_device_list ) { - /*printf("MapViewOfFile FAILED\n");*/ + log("MapViewOfFile FAILED (err %d)\n", GetLastError());
CloseHandle(device_list_file); device_list_file = NULL; @@ -156,12 +162,16 @@
UnlockAudioDeviceList();
+ log("Device list created\n"); + return TRUE; }
VOID DestroyAudioDeviceList() { + log("Destroying device list\n"); + LockAudioDeviceList();
/*printf("Unmapping view\n");*/
Propchange: trunk/reactos/base/services/audiosrv/pnp_list_manager.c ------------------------------------------------------------------------------ eol-style:native = base/services/audiosrv/audiosrv.h
Modified: trunk/reactos/boot/bootdata/hivesys.inf URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys.inf?r... ============================================================================== --- trunk/reactos/boot/bootdata/hivesys.inf (original) +++ trunk/reactos/boot/bootdata/hivesys.inf Wed Sep 19 20:54:25 2007 @@ -480,6 +480,15 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Atapi","Type",0x00010001,0x00000001 HKLM,"SYSTEM\CurrentControlSet\Services\Atapi","Tag",0x00010001,0x00000010
+; Audio Service +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","DisplayName",0x00000000,"Audio Service" +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Description",0x00000000,"Provides audio facilities to applications" +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","ErrorControl",0x00010001,0x00000000 +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Group",0x00000000,"Audio" +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","ImagePath",0x00020000,"%SystemRoot%\system32\audiosrv.exe" +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Start",0x00010001,0x00000003 +HKLM,"SYSTEM\CurrentControlSet\Services\AudioSrv","Type",0x00010001,0x00000010 + ; BusLogic 958 miniport driver HKLM,"SYSTEM\CurrentControlSet\Services\BusLogic","ErrorControl",0x00010001,0x00000000 HKLM,"SYSTEM\CurrentControlSet\Services\BusLogic","Group",0x00000000,"SCSI Miniport"
Modified: trunk/reactos/boot/bootdata/packages/reactos.dff URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/reac... ============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff Wed Sep 19 20:54:25 2007 @@ -75,6 +75,7 @@ base\services\tcpsvcs\tcpsvcs.exe 1 base\services\tcpsvcs\quotes 5 base\services\umpnpmgr\umpnpmgr.exe 1 +base\services\audiosrv\audiosrv.exe 1
base\setup\setup\setup.exe 1 base\setup\vmwinst\vmwinst.exe 1