From 27b7f45fd7bda2ca7cd0a8de976b7bbfed90a927 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Fri, 27 Sep 2019 15:04:07 +0200 Subject: [PATCH] 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. --- UI/window-basic-main.cpp | 34 ++++++++++++++++++++++++++++------ UI/window-basic-main.hpp | 2 ++ UI/window-basic-stats.cpp | 8 +------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 712c41e63..3143bd751 100644 --- a/UI/window-basic-main.cpp +++ b/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); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index a75eb4723..d3eeab40a 100644 --- a/UI/window-basic-main.hpp +++ b/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; diff --git a/UI/window-basic-stats.cpp b/UI/window-basic-stats.cpp index 7f6e2cad7..76da53a68 100644 --- a/UI/window-basic-stats.cpp +++ b/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)