From c46e881697db583f56af7aedd94f14b51a490a4e Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 27 Apr 2019 16:08:54 +0200 Subject: [PATCH] obs-source: Don't un/register audio capture with no source Fixes the log spam if a source could not be found. --- source/obs/obs-source.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/obs/obs-source.cpp b/source/obs/obs-source.cpp index 2a8cf020..1f155507 100644 --- a/source/obs/obs-source.cpp +++ b/source/obs/obs-source.cpp @@ -440,10 +440,16 @@ obs::source::source() // libOBS unfortunately does not use the event system for audio data callbacks, which is kind of odd as most other // things do. So instead we'll have to manually deal with it for now. { - this->events.audio_data.set_listen_callback( - [this] { obs_source_add_audio_capture_callback(this->self, obs::source::handle_audio_data, this); }); - this->events.audio_data.set_silence_callback( - [this] { obs_source_remove_audio_capture_callback(this->self, obs::source::handle_audio_data, this); }); + this->events.audio_data.set_listen_callback([this] { + if (!this->self) + return; + obs_source_add_audio_capture_callback(this->self, obs::source::handle_audio_data, this); + }); + this->events.audio_data.set_silence_callback([this] { + if (!this->self) + return; + obs_source_remove_audio_capture_callback(this->self, obs::source::handle_audio_data, this); + }); } }