diff --git a/libobs/obs-audio.c b/libobs/obs-audio.c index 340171e61..86a3ecbdc 100644 --- a/libobs/obs-audio.c +++ b/libobs/obs-audio.c @@ -31,8 +31,8 @@ static void push_audio_tree(obs_source_t *parent, obs_source_t *source, void *p) struct obs_core_audio *audio = p; if (da_find(audio->render_order, &source, 0) == DARRAY_INVALID) { - obs_source_addref(source); - da_push_back(audio->render_order, &source); + obs_source_t *s = obs_source_get_ref(source); + if (s) da_push_back(audio->render_order, &s); } UNUSED_PARAMETER(parent); diff --git a/libobs/obs-video.c b/libobs/obs-video.c index e7d2e1ba8..e03bfb9e7 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -58,8 +58,13 @@ static uint64_t tick_sources(uint64_t cur_time, uint64_t last_time) source = data->first_source; while (source) { - obs_source_video_tick(source, seconds); + struct obs_source *cur_source = obs_source_get_ref(source); source = (struct obs_source*)source->context.next; + + if (cur_source) { + obs_source_video_tick(cur_source, seconds); + obs_source_release(cur_source); + } } pthread_mutex_unlock(&data->sources_mutex);