Просмотр исходного кода

UI: Fix path calculation for disk space check

When using custom FFmpeg output mode, the check would instead use the
standard recording path which is no longer visible in the settings. This
commit also simplifies the checks by moving the duplicated code to a new
function.
Richard Stanway 6 лет назад
Родитель
Сommit
27b7f45fd7
3 измененных файлов с 31 добавлено и 13 удалено
  1. 28 6
      UI/window-basic-main.cpp
  2. 2 0
      UI/window-basic-main.hpp
  3. 1 7
      UI/window-basic-stats.cpp

+ 28 - 6
UI/window-basic-main.cpp

@@ -7548,6 +7548,29 @@ void OBSBasic::UpdatePause(bool activate)
 #define MBYTES_LEFT_STOP_REC 50ULL
 #define MAX_BYTES_LEFT (MBYTES_LEFT_STOP_REC * MBYTE)
 
+const char *OBSBasic::GetCurrentOutputPath()
+{
+	const char *path = nullptr;
+	const char *mode = config_get_string(Config(), "Output", "Mode");
+
+	if (strcmp(mode, "Advanced") == 0) {
+		const char *advanced_mode =
+			config_get_string(Config(), "AdvOut", "RecType");
+
+		if (strcmp(advanced_mode, "FFmpeg") == 0) {
+			path = config_get_string(Config(), "AdvOut",
+						 "FFFilePath");
+		} else {
+			path = config_get_string(Config(), "AdvOut",
+						 "RecFilePath");
+		}
+	} else {
+		path = config_get_string(Config(), "SimpleOutput", "FilePath");
+	}
+
+	return path;
+}
+
 void OBSBasic::DiskSpaceMessage()
 {
 	blog(LOG_ERROR, "Recording stopped because of low disk space");
@@ -7558,12 +7581,11 @@ void OBSBasic::DiskSpaceMessage()
 
 bool OBSBasic::LowDiskSpace()
 {
-	const char *mode = config_get_string(Config(), "Output", "Mode");
-	const char *path =
-		strcmp(mode, "Advanced")
-			? config_get_string(Config(), "SimpleOutput",
-					    "FilePath")
-			: config_get_string(Config(), "AdvOut", "RecFilePath");
+	const char *path;
+
+	path = GetCurrentOutputPath();
+	if (!path)
+		return false;
 
 	uint64_t num_bytes = os_get_free_disk_space(path);
 

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

@@ -681,6 +681,8 @@ public:
 
 	static OBSBasic *Get();
 
+	const char *GetCurrentOutputPath();
+
 protected:
 	virtual void closeEvent(QCloseEvent *event) override;
 	virtual void changeEvent(QEvent *event) override;

+ 1 - 7
UI/window-basic-stats.cpp

@@ -297,13 +297,7 @@ void OBSBasicStats::Update()
 
 	/* ------------------ */
 
-	const char *mode = config_get_string(main->Config(), "Output", "Mode");
-	const char *path = strcmp(mode, "Advanced")
-				   ? config_get_string(main->Config(),
-						       "SimpleOutput",
-						       "FilePath")
-				   : config_get_string(main->Config(), "AdvOut",
-						       "RecFilePath");
+	const char *path = main->GetCurrentOutputPath();
 
 #define MBYTE (1024ULL * 1024ULL)
 #define GBYTE (1024ULL * 1024ULL * 1024ULL)