Sfoglia il codice sorgente

libobs: Add stop_audio function, change shutdown order

This fixes a crash that could occur during freeing of sources, as the
audio subsystem was destroyed before sources were released. If a source
had monitoring enabled, it would try to lock a mutex that has been
destroyed, resulting in a crash.

Freeing audio after obs_free_data was also not a solution, as the main
view is freed in obs_free_data, and the audio subsystem is still running
and trying to lock the main view channel mutex which has been freed.

This seems to be the best middle ground, making sure the audio subsystem
is stopped so it no longer tries to access the main view channel, then
freed after obs_free_data.

Fixes https://github.com/obsproject/obs-studio/issues/4409
Richard Stanway 4 anni fa
parent
commit
3dbfa4919a
1 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 12 1
      libobs/obs.c

+ 12 - 1
libobs/obs.c

@@ -597,6 +597,16 @@ static bool obs_init_audio(struct audio_output_info *ai)
 	return false;
 }
 
+static void stop_audio(void)
+{
+	struct obs_core_audio *audio = &obs->audio;
+
+	if (audio->audio) {
+		audio_output_close(audio->audio);
+		audio->audio = NULL;
+	}
+}
+
 static void obs_free_audio(void)
 {
 	struct obs_core_audio *audio = &obs->audio;
@@ -1026,6 +1036,7 @@ void obs_shutdown(void)
 	da_free(obs->transition_types);
 
 	stop_video();
+	stop_audio();
 	stop_hotkeys();
 
 	module = obs->first_module;
@@ -1036,8 +1047,8 @@ void obs_shutdown(void)
 	}
 	obs->first_module = NULL;
 
-	obs_free_audio();
 	obs_free_data();
+	obs_free_audio();
 	obs_free_video();
 	obs_free_hotkeys();
 	obs_free_graphics();