Drivers using soundlib.lib must define an exclusion routine that accepts input messages. The exclusion routine is called under the following circumstances:
·When a device is opened for writing.
The exclusion routine receives a SoundExcludeOpen message.
·When a device, previously opened for writing, is closed.
The exclusion routine receives a SoundExcludeClose message.
·When a request is directed to a device opened for writing.
The exclusion routine receives a SoundExcludeEnter message.
·When a request to a device opened for writing is complete.
The exclusion routine receives a SoundExcludeLeave message.
·When the caller wants to confirm that the drive is open.
The exclusion routine receives a SoundExcludeQueryOpen message.
The exclusion routine is specified as the ExclusionRoutine member of a SOUND_DEVICE_INIT structure. Exclusion messages are defined in devices.h. In sndblst.sys, the exclusion routine is called SoundExcludeRoutine and is contained in the file \src\mmedia\sndblst\driver\init.c. The function's purpose is to implement mutual exclusion during write operations. For sndblst.sys, SoundExcludeRoutine does this by calling KeWaitForSingleObject when it receives the SoundExcludeEnter message and KeReleaseMutex when it receives SoundExcludeLeave.
For information on mutexes, see the Kernel-Mode Drivers Design Guide.