bozbez / win-capture-audio

An OBS plugin that allows capture of independant application audio streams on Windows, in a similar fashion to OBS's game capture and Discord's application streaming.
GNU General Public License v2.0
3.78k stars 205 forks source link

Sometimes active sessions is empty after creating new source #142

Closed walker-WSH closed 2 years ago

walker-WSH commented 2 years ago

reproduce steps:

  1. create new source for this plugin
  2. then, property window shows. However, sometimes active sessions is empty or list does not include all sessions.

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 in AudioCapture::sessions is initialized one by one asynchronously after creating source. Currently, there is no logic to ensure all sessions have been inserted before calling audio_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 in obs_module_load as early as possible.


1648536743

bozbez commented 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.