Implementing IAdapterPowerManagement

When implementing the IAdapterPowerManagement interface for your driver, refer to the implementation of the CAdapterCommon class in the sample audio drivers in the Microsoft Windows Driver Kit (WDK). This class handles device interrupts and performs other functions that are common to all audio adapter drivers. Your adapter's CAdapterCommon class should inherit from the IAdapterPowerManagement interface and support this interface in its NonDelegatingQueryInterface method. (For details on nondelegating interfaces, see the description of the INonDelegatingUnknown interface.)

You can use the IMP_IAdapterPowerManagement definition from header file Portcls.h to add the function declarations for the IAdapterPowerManagement::PowerChangeState, IAdapterPowerManagement::QueryPowerChangeState, and IAdapterPowerManagement::QueryDeviceCapabilities methods to your driver's CAdapterCommon class definition.

During the PortCls system driver's call to an adapter's device-startup routine (see Starting a Device), the adapter should register its IAdapterPowerManagement interface with PortCls by calling PcRegisterAdapterPowerManagement. For a code example, see the StartDevice function in the Sysvad sample driver, which is discussed in Sample Audio Drivers. The PcRegisterAdapterPowerManagement function's first parameter is an IUnknown pointer to the adapter driver's CAdapterCommon object. PortCls queries this object for its IAdapterPowerManagement interface.

When PortCls calls the adapter driver's IAdapterPowerManagement::PowerChangeState method to change the device's power state, the adapter driver should cache the device's new power state in the adapter's CAdapterCommon object. During the CAdapterCommon::Init call (see the implementation in the WDK's sample adapter drivers), the driver should set the initial power state to PowerDeviceD0 (described in DeviceState) before returning from a successful initialization. The driver should write to the hardware only if it is known to be in an appropriate power state.

Before powering down in response to a PowerChangeState call, the adapter driver should place the audio outputs in a state that prevents speaker noise from occurring when the power switches off. For example, the shutdown process might include ramping the DAC outputs to zero, turning off the DACs, and muting the MIDI lines.