Closed walker-WSH closed 2 years ago
Yeah I agree there should be a singleton SessionMonitor instance that the sources subscribe to, and returns a list of the currently tracked sessions on subscribe. This should be easier than trying to guess when the SessionMonitor has finished collecting all of the sessions on startup, and just needs some care, probably with an extra critical section, to prevent race hazards when returning the initial session list.
reproduce steps:
I debugged it, and find the reason:
After creating source,
audio_capture_properties
will be called soon and sessions will be filled for displaying. However, sessions saved inAudioCapture::sessions
is initialized one by one asynchronously after creating source. Currently, there is no logic to ensure all sessions have been inserted before callingaudio_capture_properties
In fact, I wonder why the session monitor is not created as single instance, instead of being member variable of
AudioCapture
. If it is a single instance, we can start thread inobs_module_load
as early as possible.