Browse Source

UI: Fix crash when starting vcam before other outputs

The BasicOutputHandler::Active() function was used for checking whether
outputs had started or not.  However, the virtual camera is not used in
the subclasses; instead it's a part of the base class.  Because of that
fact, when the virtual camera is started, the procedures used to start
up the other outputs are never called, causing outputs to crash because
they hadn't been initialized properly.  For example, starting the
virtual camera, then starting stream/recording would crash.

So, as a simple fix to this, when checking the active status in the
derived classes, do not factor in the virtual camera.
jp9000 5 years ago
parent
commit
218b936b1d
2 changed files with 7 additions and 7 deletions
  1. 5 5
      UI/window-basic-main-outputs.cpp
  2. 2 2
      UI/window-basic-main-outputs.hpp

+ 5 - 5
UI/window-basic-main-outputs.cpp

@@ -725,7 +725,7 @@ const char *FindAudioEncoderFromCodec(const char *type)
 
 
 bool SimpleOutput::StartStreaming(obs_service_t *service)
 bool SimpleOutput::StartStreaming(obs_service_t *service)
 {
 {
-	if (!Active())
+	if (!Active(false))
 		SetupOutputs();
 		SetupOutputs();
 
 
 	Auth *auth = main->GetAuth();
 	Auth *auth = main->GetAuth();
@@ -885,7 +885,7 @@ void SimpleOutput::UpdateRecording()
 		Update();
 		Update();
 	}
 	}
 
 
-	if (!Active())
+	if (!Active(false))
 		SetupOutputs();
 		SetupOutputs();
 
 
 	if (!ffmpegOutput) {
 	if (!ffmpegOutput) {
@@ -1507,7 +1507,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service)
 
 
 	UpdateAudioSettings();
 	UpdateAudioSettings();
 
 
-	if (!Active())
+	if (!Active(false))
 		SetupOutputs();
 		SetupOutputs();
 
 
 	Auth *auth = main->GetAuth();
 	Auth *auth = main->GetAuth();
@@ -1671,7 +1671,7 @@ bool AdvancedOutput::StartRecording()
 
 
 	UpdateAudioSettings();
 	UpdateAudioSettings();
 
 
-	if (!Active())
+	if (!Active(false))
 		SetupOutputs();
 		SetupOutputs();
 
 
 	if (!ffmpegOutput || ffmpegRecording) {
 	if (!ffmpegOutput || ffmpegRecording) {
@@ -1740,7 +1740,7 @@ bool AdvancedOutput::StartReplayBuffer()
 
 
 	UpdateAudioSettings();
 	UpdateAudioSettings();
 
 
-	if (!Active())
+	if (!Active(false))
 		SetupOutputs();
 		SetupOutputs();
 
 
 	if (!ffmpegOutput || ffmpegRecording) {
 	if (!ffmpegOutput || ffmpegRecording) {

+ 2 - 2
UI/window-basic-main-outputs.hpp

@@ -51,10 +51,10 @@ struct BasicOutputHandler {
 
 
 	virtual void Update() = 0;
 	virtual void Update() = 0;
 
 
-	inline bool Active() const
+	inline bool Active(bool check_vcam = true) const
 	{
 	{
 		return streamingActive || recordingActive || delayActive ||
 		return streamingActive || recordingActive || delayActive ||
-		       replayBufferActive || virtualCamActive;
+		       replayBufferActive || (check_vcam && virtualCamActive);
 	}
 	}
 };
 };