(can be found in base\services\audiosrv in the source tree)
I've figured out how WinMM becomes aware of plug and play devices on XP. My implementation follows how Windows appears to do things, and works like so:
AudioSrv creates a device list in shared memory, and a mutex to protect this list from modification whilst being read (I don't think Windows does this but I do as a safeguard.)
AudioSrv then registers for audio device notifications via RegisterDeviceNotification, and uses the Setup API to find existing audio devices on the system. These are registered under the KSCATEGORY_AUDIO interface.
WinMM obtains access to the shared memory created by AudioSrv. If it can't find it (it's a named file mapping with a named mutex) then the service has either failed or is stopped. So no devices are available.
WinMM can then enumerate the device list, and pass the devices to the relevant user-installable driver (usually WDMAud.drv) to be dealt with. This is done via DRVM_INIT (WODM_INIT ?) And WODM_EXIT messages being sent to wodMessage (for Wave Out devices, anyway.)
Each entry is actually a device path - WDMAud opens the devices and sends KS messages to identify it by name etc. and then maintains the number of devices present and the information about each device.
Applications using WinMM will then see this information in their calls to waveOutGetNumDevs and waveOutGetDevCaps and so on.
The service only does anything on Windows XP at present. It's not been tested with Vista but *should* work.
It can quite happily sit next to the "official" Audio Service and will not interfere with Windows' own WinMM.
To install as a service, and start it:
Code: Select all
sc create RosAudioSrv binpath= audiosrv.exe sc start RosAudioSrv
To stop the service and delete it:
Code: Select all
sc stop RosAudioSrv sc delete RosAudioSrv
More work to be done
"Why doesn't this work on ReactOS?" I hear you ask.
In Windows there are 3 additional components:
KS.SYS - Kernel Streaming API
PORTCLS.SYS - Port Class (driver utility library)
SYSAUDIO.SYS - System Audio graph builder
One of these (either SysAudio or KS) register devices in the KSCATEGORY_AUDIO interface class.
Without these components, the ReactOS Audio Service will receive no notifications of new audio devices, and won't find any existing devices. Hence, it will sit there and do nothing.
So there's not much to look at (or hear!) yet, but I'm getting there slowly!