Browse Source

UI: Make SetupOutputs virtual instead of ignoring vcam

In 218b936b1dae, the virtual camera was ignored when checking the active
state, which is kind of a lackluster solution.  Instead, this makes
SetupOutputs() a virtual function, and calls it before starting the
virtual camera to be more consistent with the rest of the outputs.
jp9000 5 years ago
parent
commit
7286ee427a
2 changed files with 13 additions and 9 deletions
  1. 10 7
      UI/window-basic-main-outputs.cpp
  2. 3 2
      UI/window-basic-main-outputs.hpp

+ 10 - 7
UI/window-basic-main-outputs.cpp

@@ -213,6 +213,9 @@ bool BasicOutputHandler::StartVirtualCam()
 	if (main->vcamEnabled) {
 		obs_output_set_media(virtualCam, obs_get_video(),
 				     obs_get_audio());
+		if (!Active())
+			SetupOutputs();
+
 		return obs_output_start(virtualCam);
 	}
 	return false;
@@ -264,7 +267,7 @@ struct SimpleOutput : BasicOutputHandler {
 	void UpdateRecordingAudioSettings();
 	virtual void Update() override;
 
-	void SetupOutputs();
+	void SetupOutputs() override;
 	int GetAudioBitrate() const;
 
 	void LoadRecordingPreset_h264(const char *encoder);
@@ -725,7 +728,7 @@ const char *FindAudioEncoderFromCodec(const char *type)
 
 bool SimpleOutput::StartStreaming(obs_service_t *service)
 {
-	if (!Active(false))
+	if (!Active())
 		SetupOutputs();
 
 	Auth *auth = main->GetAuth();
@@ -885,7 +888,7 @@ void SimpleOutput::UpdateRecording()
 		Update();
 	}
 
-	if (!Active(false))
+	if (!Active())
 		SetupOutputs();
 
 	if (!ffmpegOutput) {
@@ -1058,7 +1061,7 @@ struct AdvancedOutput : BasicOutputHandler {
 	inline void SetupStreaming();
 	inline void SetupRecording();
 	inline void SetupFFmpeg();
-	void SetupOutputs();
+	void SetupOutputs() override;
 	int GetAudioBitrate(size_t i) const;
 
 	virtual bool StartStreaming(obs_service_t *service) override;
@@ -1507,7 +1510,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service)
 
 	UpdateAudioSettings();
 
-	if (!Active(false))
+	if (!Active())
 		SetupOutputs();
 
 	Auth *auth = main->GetAuth();
@@ -1671,7 +1674,7 @@ bool AdvancedOutput::StartRecording()
 
 	UpdateAudioSettings();
 
-	if (!Active(false))
+	if (!Active())
 		SetupOutputs();
 
 	if (!ffmpegOutput || ffmpegRecording) {
@@ -1740,7 +1743,7 @@ bool AdvancedOutput::StartReplayBuffer()
 
 	UpdateAudioSettings();
 
-	if (!Active(false))
+	if (!Active())
 		SetupOutputs();
 
 	if (!ffmpegOutput || ffmpegRecording) {

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

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