From 47d8f2e497705d38a22c9b9de26d7ccff5bba842 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 4 Jan 2022 01:09:57 -0800 Subject: [PATCH] libobs: Remove all callbacks on source destroy Removes all callbacks in use on sources right when a source is about to be destroyed. Fixes a crash where callbacks would still be executed while in a destroyed state (particularly sidechain filters). Could also just mark the source as being in a destroyed state and not accept anymore obs_source_output_[audio/video] calls. --- libobs/obs-source.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 7b75336a6..f973c2e01 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -614,6 +614,16 @@ void obs_source_destroy(struct obs_source *source) if (!obs_source_valid(source, "obs_source_destroy")) return; + if (is_audio_source(source)) { + pthread_mutex_lock(&source->audio_cb_mutex); + da_free(source->audio_cb_list); + pthread_mutex_unlock(&source->audio_cb_mutex); + } + + pthread_mutex_lock(&source->caption_cb_mutex); + da_free(source->caption_cb_list); + pthread_mutex_unlock(&source->caption_cb_mutex); + if (source->info.type == OBS_SOURCE_TYPE_TRANSITION) obs_transition_clear(source);