obs-source: Don't un/register audio capture with no source

Fixes the log spam if a source could not be found.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-04-27 16:08:54 +02:00
parent 8bb1ca50ac
commit c46e881697

View file

@ -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);
});
}
}