IAudioSessionManager2::RegisterSessionNotification() method not notifying on second time logoff and logon

AudioLib123 K 1 Reputation point
2022-03-15T05:37:03.037+00:00

I am Programming a software which notifies on new session creation. On Logon of system, using RegisterSessionNotification() and on LogOff, using UnRegisterSessionNotification().

On first time Logoff and Logon, getting notification whenever there is a new session created with the help of OnSessionCreated(). Where as second time Logoff and LogOn, OnSessionCreated() is not triggered when new session is created or encountered. Please let me know if you need any other details.

IAudioSessionManager2::RegisterSessionNotification() method not notifying on second time logoff and logon. Where as it works perfectly(getting notification on new session) when first time logged off and logon to different user or same user in win 10. I am calling Registering and Unregistering in Service in LOGON and LOGOFF respectively.

Do I need to invoke some APIs before Unregistering or logoff second time. Please help.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,689 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,787 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 10,041 Reputation points Microsoft Vendor
    2022-03-15T07:22:16.433+00:00

    Hi,

    Welcome to Microsoft Q&A!

    According to the Doc: IAudioSessionManager2::RegisterSessionNotification method

    You must call IAudioSessionEnumerator::GetCount to begin receiving notifications. The session enumeration API discards new session notifications until the application has first retrieved the list of existing sessions. This is to prevent a race condition that can occur when a session notification arrives while the application using the session APIs is starting up. Calling GetCount triggers the enumeration API to begin sending session notifications.

    I suggest you could refer to the steps to receive session notifications and manage a list of current sessions.

    Best Regards,

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.