I'm currently working on audio sessions. Let's say I have an audio session which was obtained by enumerating all sessions with GetSessionEnumerator and GetSession. It is possible to register notifications to know when the sessions had its volume changed, state changed, ... with RegisterAudioSessionNotification.
However, I didn't find how to know when the session has been removed. According to the doc, there is no session expiration mecanism provided by the API.
With that information in mind, there are two behaviours I do not understand:
In windows' volume mixer (sndvol), when you terminate an application producing sound, the icon and volume slider associated with it disappears from the list. How does sndvol know this since there is no expiration mecanism?
Here's a scenario:
a. you have n audio sessions active
b. you enumerate these sessions and listen for new ones
c. you launch an app producing sound, the session created notification fires up, you now have n+1 sessions in your list
d. you terminate the app. You still have n+1 notifications since there is no expiration mecanism
e. What I don't understand: If you re-enumerate audio sessions, you will get n sessions. How come the extra session of the terminated app is still working if it's not event in the list when you re-enumerate? Moreover, why did it disappear from the list?
Does anyone have any information? I've been searching for weeks, without results!
Thank you very much!
Edit: So I've studied sndvol a bit, and found an interesting interface: {604e2ae7-c4c5-4032-93ff-88b26cdd75b8} which sndvol queries to every session from IAudioSessionControl. Appaently this is a private interface without documentation. Interesting thing: if that query fails, the session is not shown in sndvol! This seems to be confirmed here
I couldn't find any more info on that interface.