typedef struct { PCWSTR LeftVolumeName, RightVolumeName; ULONG DefaultVolume; ULONG Type; ULONG DeviceType; char Key[4]; PCWSTR PrototypeName; PIO_DPC_ROUTINE DeferredRoutine; SOUND_EXCLUDE_ROUTINE *ExclusionRoutine; SOUND_DISPATCH_ROUTINE *DispatchRoutine; SOUND_DISPATCH_ROUTINE *DevCapsRoutine; SOUND_HW_SET_VOLUME_ROUTINE *HwSetVolume; ULONG IoMethod; } SOUND_DEVICE_INIT;
The SOUND_DEVICE_INIT structure associates driver dispatch routines with a driver object. A SOUND_DEVICE_INIT structure must be defined for each logical input or output device. The structure’s definition is in devices.h.
Value |
Definition |
FILE_DEVICE_WAVE_IN |
For waveform input |
FILE_DEVICE_WAVE_OUT |
For wave output |
FILE_DEVICE_MIDI_IN |
For MIDI input |
FILE_DEVICE_MIDI_OUT |
For MIDI output |
FILE_DEVICE_SOUND |
For all other audio devices |
Value |
Definition |
WAVE_IN |
Waveform input device |
WAVE_OUT |
Waveform output device |
MIDI_IN |
MIDI input device |
MIDI_OUT |
MIDI output device |
AUX_DEVICE |
Auxiliary audio device |
MIXER_DEVICE |
Mixer device |
SYNTH_DEVICE |
MIDI Synthesizer device (adlib or opl3) |
If you are using mmdrv.dll as your user-mode driver, then you must use the prototype name that mmdrv.dll recognizes for the device. The names recognized by mmdrv.dll are predefined and their string IDs can be referenced using the following names.
Name |
Where Defined |
DD_AUX_DEVICE_NAME_U |
ntddaux.h |
DD_MIDI_IN_DEVICE_NAME_U |
ntddmidi.h |
DD_MIX_DEVICE_NAME_U |
ntddmix.h |
DD_WAVE_IN_DEVICE_NAME_U |
ntddwave.h |
If you are using a customized user-mode driver, you cannot use the predefined
names. For example, in the SOUND_DEVICE_INIT structures for the kernel-mode
driver sndblst.sys, predefined names are used for MIDI devices but not
for waveform, auxiliary, or mixer devices. The result is that mmdrv.dll
handles user-mode MIDI operations, and sndblst.dll handles all others.
If the device object does not support interrupts, this member must be NULL. For drivers using soundlib.lib, specify one of the following DPC routines.
Device Type |
DPC Routine |
Waveform input and output devices | |
MIDI input devices | |
MIDI output, auxiliary audio, and mixers |
NULL |
Dispatcher |
Purpose |
Dispatcher for auxiliary audio devices | |
Dispatcher for MIDI input and output devices | |
Dispatcher for mixer devices | |
Dispatcher for waveform input and output devices |
The function type is SOUND_DISPATCH_ROUTINE. The specified function is called by SoundDispatch.
The function type is SOUND_DISPATCH_ROUTINE. The specified function is called by the dispatcher pointed to by the DispatchRoutine member, when the dispatcher receives IRP_MJ_DEVICE_CONTROL with an accompanying request for device capabilities. Capabilities for waveform, MIDI, and auxiliary devices are written into the IRP at Irp->AssociatedIrp.SystemBuffer, in the form of either a WAVEINCAPS, WAVEOUTCAPS, MIDIINCAPS, MIDIOUTCAPS, or AUXCAPS capabilities structure. (These structures are defined in mmsystem.h and described in the Win32 SDK.)
Note: When filling in the szPname member of the capabilities structure, remember the following:
For mixer devices only, the following rules apply:
As an aid to understanding these special rules, see the mixer capabilities
function, SoundMixerDumpConfiguration, provided in sndblst.sys,
in src\mmedia\sndblst\driver\mixer.c.
The specified function is called by the dispatcher pointed to by the DispatchRoutine member, when the dispatcher receives IRP_MJ_DEVICE_CONTROL with an accompanying request to set the volume.
For devices without volume setting capabilities, use the SoundNoVolume
function. Also use SoundNoVolume for devices that include mixer
hardware, because drivers for these devices include a MIXER_INFO
structure, and volume is controlled by a routine pointed to by that
structure’s HwSetControlData member.
Device Type |
I/O Method |
Auxiliary |
DO_BUFFERED_IO |
MIDI input |
DO_DIRECT_IO |
MIDI output |
DO_DIRECT_IO |
Mixer |
DO_BUFFERED_IO |
Wave input |
DO_DIRECT_IO |
Wave output |
DO_DIRECT_IO |
For a discussion of direct I/O and buffer I/O methods, refer to the Kernel-Mode Drivers Design Guide.
The SOUND_DEVICE_INIT structure’s address is passed to SoundCreateDevice. The structure must not be freed and must be nonpaged, because SoundCreateDevice does not copy it.
You must initialize all structure members before calling SoundCreateDevice. The LeftVolumeName, RightVolumeName, and DefaultVolume members can be initialized to NULL, NULL, and 0, respectively.