Enabling and Disabling Drivers

The DriverProc function calls two functions, Enable and Disable, to enable and disable the driver. These functions are part of the driver. Their implementation is dependent upon the target hardware and the structure of the driver.

Generally, when a driver is enabled, you initialize the hardware, hook interrupts, allocate any memory you need, and set a flag to indicate that the driver is enabled. The exact sequence your device driver follows is determined by the requirements and structure of your device driver. For example, the Bravado device driver uses interrupts only for streaming data. When enabled, it will hook its interrupts only if it was disabled while streaming data.

If your driver has not been enabled by MMSYSTEM, or if it failed the enable process, the driver should return MMSYSERR_NOTENABLED for any messages it receives from client applications. When a driver is disabled, you free any memory you allocated, unhook interrupts, reset the hardware, and set a flag to indicate the driver is not enabled.

It's possible for a driver to receive a DRV_DISABLE message while it is sending or receiving audio data, resulting in a DRV_DISABLE/DRV_ENABLE message pair. For example, this can happen when the user switches to an MS-DOS application while Windows is running in standard mode.

The following table indicates how audio and video device drivers should respond to a DRV_DISABLE/DRV_ENABLE message pair.

Driver type Responds as if
Waveform output The driver is paused with a WODM_PAUSE message, and then restarted with a WODM_RESTART message.
Waveform input The driver is stopped with a WIDM_STOP message, and then restarted with a WIDM_START message.
MIDI output The driver is disabled, and then re-enabled. If the driver is asynchronous, output stops when the driver is disabled and continues when the driver is re-enabled.
MIDI input The driver is stopped with a MIDM_STOP message, and then restarted with a MIDM_START message.
Video capture The driver is stopped with a DVM_STREAM_STOP message, and then restarted with a DVM_STREAM_START message.