Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#97

AW: TAudioVolume Komponente incl. System Mixer

  Alt 16. Mai 2018, 13:53
Boah, meine Fresse! Darauf muss man erstmal kommen.
Man muss nach Anmeldung der Notifizierung definitiv GetSessionEnumerator aufrufen, dann geht das erst.
Siehe Beispielprojekt im Anhang!

Drauf gekommen bin ich deswegen:
Zitat von Larry Osterman:
The first is that his application hasn't retrieved the current list of sessions. This is one of the really subtle things about the session enumeration APIs. In order to prevent a race condition that can occur when a session notification arrives while the application using the session APIs is starting up, the session enumeration API discards new session notifications until the application has first retrieved the list of existing sessions.

The expected usage pattern is:

Application activates a session manager2. Application registers for session notifications. Application retrieves the current list of sessions for the endpoint and stores the session control objects into a list (don't forget to addref the session).

When a new session is created, the application takes a reference to the newly created session control object and inserts it into the list if it's not already present. Note that the session control object passed into the notification will be destroyed when the session notification returns - if you call GetSessionEnumerator at this point it will probably NOT hold the newly created session (it might, it all depends on timing).
https://stackoverflow.com/a/740241
Angehängte Dateien
Dateityp: zip NotificationTest_2018-05-16_13-48-15.zip (11,8 KB, 11x aufgerufen)
  Mit Zitat antworten Zitat