Device contexts are managed by the MDM, using an abstract concept of resource units, resource classes and valid class combinations.
Resource units provide a measurement for the resource manager to determine how many device contexts may be active at any given time. Each device specifies how many resource units it can process concurrently.
Besides a total resource number, each resource class has a maximum number of resource units available to it. This allows the MDM to determine how many device contexts from a particular class can be active concurrently. During the install procedure the maximum numbers are provided.
On the MCI_OPEN of a device context the required resource units and class for the device context is returned in the MMDRV_OPEN_PARMS structure. The required resource units and resource class of a device context can be changed by the MCD by calling the MDM with the MCIDRV_CHANGERESOURCE message. For example, if a waveaudio device allocated 1 resource unit for a mono wave and two units for a stereo wave, then a load command might change the required units for that device context.
The final piece of resource management is provided during install. This is the valid class combinations. A certain device might have multiple classes, but not allow certain classes to have active device contexts concurrently. The following example is the Pro AudioSpectrum 16 card. It has at most two resource units available. It uses 2 classes, one for waveform audio and the other for MIDI. Each class can have at most one resource unit consumed by a active device context. It can have any number of in-active device contexts. Finally both classes can have active device contexts concurrently. This says that this card can support one waveform audio and or one MIDI.