Browse Source

UI: Disallow exiting settings with no track in advanced mode

(cherry picked from commit 4b376929394044c5eb665484001c3d1d6c18c502)
gxalpha 2 năm trước cách đây
mục cha
commit
3f3ff4fd92

+ 4 - 0
UI/window-basic-main-outputs.cpp

@@ -1792,6 +1792,10 @@ inline void AdvancedOutput::SetupRecording()
 	unsigned int cy = 0;
 	int idx = 0;
 
+	/* Hack to allow recordings without any audio tracks selected. It is no
+	 * longer possible to select such a configuration in settings, but legacy
+	 * configurations might still have this configured and we don't want to
+	 * just break them. */
 	if (tracks == 0)
 		tracks = config_get_int(main->Config(), "AdvOut", "TrackIndex");
 

+ 17 - 8
UI/window-basic-settings.cpp

@@ -3886,14 +3886,8 @@ void OBSBasicSettings::SaveOutputSettings()
 	SaveSpinBox(ui->advOutSplitFileTime, "AdvOut", "RecSplitFileTime");
 	SaveSpinBox(ui->advOutSplitFileSize, "AdvOut", "RecSplitFileSize");
 
-	config_set_int(
-		main->Config(), "AdvOut", "RecTracks",
-		(ui->advOutRecTrack1->isChecked() ? (1 << 0) : 0) |
-			(ui->advOutRecTrack2->isChecked() ? (1 << 1) : 0) |
-			(ui->advOutRecTrack3->isChecked() ? (1 << 2) : 0) |
-			(ui->advOutRecTrack4->isChecked() ? (1 << 3) : 0) |
-			(ui->advOutRecTrack5->isChecked() ? (1 << 4) : 0) |
-			(ui->advOutRecTrack6->isChecked() ? (1 << 5) : 0));
+	config_set_int(main->Config(), "AdvOut", "RecTracks",
+		       AdvOutGetSelectedAudioTracks());
 
 	config_set_int(main->Config(), "AdvOut", "FLVTrack", CurrentFLVTrack());
 
@@ -4237,6 +4231,10 @@ bool OBSBasicSettings::QueryAllowedToClose()
 		    ui->advOutRecAEncoder->currentIndex() == -1 ||
 		    ui->advOutAEncoder->currentIndex() == -1)
 			invalidEncoder = true;
+
+		QString format = ui->advOutRecFormat->currentData().toString();
+		if (AdvOutGetSelectedAudioTracks() == 0 && format != "flv")
+			invalidTracks = true;
 	}
 
 	if (invalidEncoder) {
@@ -6179,6 +6177,17 @@ int OBSBasicSettings::SimpleOutGetSelectedAudioTracks()
 	return tracks;
 }
 
+int OBSBasicSettings::AdvOutGetSelectedAudioTracks()
+{
+	int tracks = (ui->advOutRecTrack1->isChecked() ? (1 << 0) : 0) |
+		     (ui->advOutRecTrack2->isChecked() ? (1 << 1) : 0) |
+		     (ui->advOutRecTrack3->isChecked() ? (1 << 2) : 0) |
+		     (ui->advOutRecTrack4->isChecked() ? (1 << 3) : 0) |
+		     (ui->advOutRecTrack5->isChecked() ? (1 << 4) : 0) |
+		     (ui->advOutRecTrack6->isChecked() ? (1 << 5) : 0);
+	return tracks;
+}
+
 /* Using setEditable(true) on a QComboBox when there's a custom style in use
  * does not work properly, so instead completely recreate the widget, which
  * seems to work fine. */

+ 1 - 0
UI/window-basic-settings.hpp

@@ -376,6 +376,7 @@ private:
 
 	int CurrentFLVTrack();
 	int SimpleOutGetSelectedAudioTracks();
+	int AdvOutGetSelectedAudioTracks();
 
 	OBSService GetStream1Service();