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:
		
							parent
							
								
									8bb1ca50ac
								
							
						
					
					
						commit
						c46e881697
					
				|  | @ -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
 | 	// 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.
 | 	//  things do. So instead we'll have to manually deal with it for now.
 | ||||||
| 	{ | 	{ | ||||||
| 		this->events.audio_data.set_listen_callback( | 		this->events.audio_data.set_listen_callback([this] { | ||||||
| 			[this] { obs_source_add_audio_capture_callback(this->self, obs::source::handle_audio_data, this); }); | 			if (!this->self) | ||||||
| 		this->events.audio_data.set_silence_callback( | 				return; | ||||||
| 			[this] { obs_source_remove_audio_capture_callback(this->self, obs::source::handle_audio_data, this); }); | 			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); | ||||||
|  | 		}); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue