Power and State Changes in AVStream
When AVStream receives an IRP_MN_SET_POWER request, it calls a minidriver's AVStrMiniDeviceSetPower callback routine, if the minidriver has provided one.
When AVStream receives a set request of the KSPROPERTY_CONNECTION_STATE property, it calls a minidriver's AVStrMiniPinSetDeviceState callback routine, if the minidriver has provided one.
When the system wakes from a sleep state, AVStream may call a minidriver's AVStrMiniPinSetDeviceState and AVStrMiniDeviceSetPower callback routines in the reverse of the expected order. For example, AVStrMiniPinSetDeviceState may be called beforeAVStrMiniDeviceSetPower.
As a result, the driver must be prepared to handle such a reversal of the expected callback order.
This reversal does not happen when the system is powered down into a sleep state. On power down, these two callback routines always occur in the expected order. For example, AVStrMiniPinSetDeviceState is always called before AVStrMiniDeviceSetPower.
If this reversal occurs, the entire sequence looks like this:
First, the power down sequence occurs:
AVStrMiniPinSetDeviceState is called with a request to change device state from KSSTATE_RUN to KSSTATE_PAUSE.
AVStrMiniDeviceSetPower is called with a request to change power state from D0 to D2/D3.
At this point, the system is in a sleep state.
Next, the power up sequence occurs:
AVStrMiniDeviceSetPower is called with a request to change power state from D2/D3 to D0.
AVStrMiniPinSetDeviceState is called with a request to change device state from KSSTATE_PAUSE to KSSTATE_RUN.
In this scenario, steps 5 and 6 are the steps that are reversed from the expected order.
Additionally, when an application is streaming and the system initiates a power down sequence, a capture graph that is running is always placed in a pause state. If the graph was already stopped, it remains stopped.