Skip to content

Commit

Permalink
libobs: Fix logging of remaining views
Browse files Browse the repository at this point in the history
OBS has been logging `1 views remain at shutdown` when in reality there
are not technically any views remaining. When views are removed, the
view itself is destroyed immediately, but the mix remains, to be
garbage collected by the graphics thread.

In this case, the view has already been removed, but the graphics
thread has not run an interation and cleaned up the mix, so this
log message appears.

Fixes the issue by checking if a mix actually has an assigned view,
instead of blindly logging existing mixes.
  • Loading branch information
tt2468 authored and kc5nra committed Jan 18, 2023
1 parent c69e407 commit 25df3e1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libobs/obs.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,16 @@ void obs_free_video_mix(struct obs_core_video_mix *video)
static void obs_free_video(void)
{
pthread_mutex_lock(&obs->video.mixes_mutex);
size_t num = obs->video.mixes.num;
if (num)
blog(LOG_WARNING, "%zu views remain at shutdown", num);
for (size_t i = 0; i < num; i++) {
obs_free_video_mix(obs->video.mixes.array[i]);
size_t num_views = 0;
for (size_t i = 0; i < obs->video.mixes.num; i++) {
struct obs_core_video_mix *video = obs->video.mixes.array[i];
if (video && video->view)
num_views++;
obs_free_video_mix(video);
obs->video.mixes.array[i] = NULL;
}
if (num_views > 0)
blog(LOG_WARNING, "Number of remaining views: %ld", num_views);
pthread_mutex_unlock(&obs->video.mixes_mutex);

pthread_mutex_destroy(&obs->video.mixes_mutex);
Expand Down

0 comments on commit 25df3e1

Please sign in to comment.