IAudioSessionEvents::OnStateChanged method

The OnStateChanged method notifies the client that the stream-activity state of the session has changed.

Syntax


HRESULT OnStateChanged(
  [in] AudioSessionState NewState
);

Parameters

NewState [in]

The new session state. The value of this parameter is one of the following AudioSessionState enumeration values:

AudioSessionStateActive

AudioSessionStateInactive

AudioSessionStateExpired

Return value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

A client cannot generate a session-state-change event. The system is always the source of this type of event. Thus, unlike some other IAudioSessionEvents methods, this method does not supply a context parameter.

The system changes the state of a session from inactive to active at the time that a client opens the first stream in the session. A client opens a stream by calling the IAudioClient::Initialize method. The system changes the session state from active to inactive at the time that a client closes the last stream in the session. The client that releases the last reference to an IAudioClient object closes the stream that is associated with the object.

For a code example that implements the methods in the IAudioSessionEvents interface, see Audio Session Events.

Requirements

Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 [desktop apps | Windows Store apps]

Header

Audiopolicy.h

See also

IAudioClient Interface
IAudioClient::Initialize
IAudioSessionEvents Interface

 

 

Show: