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.
This commit is contained in:
Richard Stanway 2019-09-27 15:04:07 +02:00
parent 66967b7a55
commit 27b7f45fd7
3 changed files with 31 additions and 13 deletions

View file

@ -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);

View file

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

View file

@ -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)