IAudioSessionControl::UnregisterAudioSessionNotification method (audiopolicy.h)

The UnregisterAudioSessionNotification method deletes a previous registration by the client to receive notifications.

Syntax

HRESULT UnregisterAudioSessionNotification(
  [in] IAudioSessionEvents *NewNotifications
);

Parameters

[in] NewNotifications

Pointer to a client-implemented IAudioSessionEvents interface. The client passed this same interface pointer to the session manager in a previous call to the IAudioSessionControl::RegisterAudioSessionNotification method. If the UnregisterAudioSessionNotification method succeeds, it calls the Release method on the client's IAudioSessionEvents interface.

Return value

If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values shown in the following table.

Return code Description
E_POINTER
Parameter NewNotifications is NULL.
E_NOTFOUND
The specified interface was not previously registered by the client or has already been removed.

Remarks

The client calls this method when it no longer needs to receive notifications. The UnregisterAudioSessionNotification method removes the registration of an IAudioSessionEvents interface that the client previously registered with the session manager by calling the IAudioSessionControl::RegisterAudioSessionNotification method.

Before the client releases its final reference to the IAudioSessionEvents interface, it should call UnregisterAudioSessionNotification to unregister the interface. Otherwise, the application leaks the resources held by the IAudioSessionEvents and IAudioSessionControl objects. Note that RegisterAudioSessionNotification calls the client's IAudioSessionEvents::AddRef method, and UnregisterAudioSessionNotification calls the IAudioSessionEvents::Release method. If the client errs by releasing its reference to the IAudioSessionEvents interface before calling UnregisterAudioSessionNotification, the session manager never releases its reference to the IAudioSessionEvents interface. For example, a poorly designed IAudioSessionEvents implementation might call UnregisterAudioSessionNotification from the destructor for the IAudioSessionEvents object. In this case, the client will not call UnregisterAudioSessionNotification until the session manager releases its reference to the IAudioSessionEvents interface, and the session manager will not release its reference to the IAudioSessionEvents interface until the client calls UnregisterAudioSessionNotification. For more information about the AddRef and Release methods, see the discussion of the IUnknown interface in the Windows SDK documentation.

For a code example that calls the UnregisterAudioSessionNotification method, see Audio Events for Legacy Audio Applications.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header audiopolicy.h

See also

IAudioSessionControl Interface

IAudioSessionControl::RegisterAudioSessionNotification

IAudioSessionEvents Interface