Supporting Mixer Devices

User-mode mixer drivers send IOCTL_MIX_REQUEST_NOTIFY messages to kernel-mode drivers to request notification of changes to line and control information. If a user-mode driver uses drvlib.lib, code in drvlib.lib begins continually calling DeviceIoControl, sending IOCTL_MIX_REQUEST_NOTIFY messages, after MXDM_OPEN is received. (This assumes the client has stipulated change notification when sending MXDM_OPEN.) Functions are provided in soundlib.lib to assist kernel-mode drivers in responding to IOCTL_MIX_REQUEST_NOTIFY messages. Code in soundlib.lib's SoundMixerDispatch queues the IRPs associated with these notification requests.

Kernel-mode drivers call the SoundMixerChangedItem function to queue information about line and control changes. This function, in turn, dequeues the queued IRPs, writes changed information into each IRP structure, and calls IoCompleteRequest to complete the I/O request and pass the changed information back to drvlib.lib, in user mode.

Kernel-mode drivers call SoundSetLineNotify to register a routine that soundlib.lib calls whenever the status of a line changes. For wave devices, soundlib.lib calls this routine whenever the device state should change from inactive to active, or vice versa. The routine typically sets hardware appropriately and calls SoundMixerChangedItem.

To use soundlib.lib for handling mixer devices, you must:

·Within the driver object received by DriverEntry, assign SoundDispatch to be the driver's main dispatcher for IRP control codes. See "Examining DriverEntry in sndblst.sys."

·Define a SOUND_DEVICE_INIT structure for each mixer device. Mixer drivers generally support one device instance per card. The structures' DispatchRoutine members must be set to the address of SoundMixerDispatch, which is the mixer dispatch routine within soundlib.lib for DeviceIoControl messages.

·Define a MIXER_INFO structure.

·Call SoundCreateDevice once for each SOUND_DEVICE_INIT structure you have defined.

·Assign the address of the mixer device's LOCAL_DEVICE_INFO structure to the MixerDevice member of every other device's LOCAL_DEVICE_INFO structure.

Mixer drivers should save their settings in the registry before system shutdown. To register for shutdown notification, call IoRegisterShutdownNotification. Drivers can save mixer settings in the registry in any format, but the most efficient registry data type for saving the settings is REG_BINARY. When the driver initializes, it can use either the stored settings or default settings.