Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config flag and update checker github repo url #496

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/background-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct background_removal_filter : public filter_data {
int maskEveryXFrames = 1;
int maskEveryXFramesCount = 0;
int64_t blurBackground = 0;
bool enableFocalBlur = true;
bool enableFocalBlur = false;
float blurFocusPoint = 0.1f;
float blurFocusDepth = 0.1f;

Expand Down Expand Up @@ -199,7 +199,7 @@ void background_filter_defaults(obs_data_t *settings)
obs_data_set_default_int(settings, "mask_every_x_frames", 1);
obs_data_set_default_int(settings, "blur_background", 0);
obs_data_set_default_int(settings, "numThreads", 1);
obs_data_set_default_bool(settings, "enable_focal_blur", true);
obs_data_set_default_bool(settings, "enable_focal_blur", false);
obs_data_set_default_double(settings, "blur_focus_point", 0.1);
obs_data_set_default_double(settings, "blur_focus_depth", 0.0);
}
Expand Down
31 changes: 15 additions & 16 deletions src/obs-utils/obs-config-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,49 @@ void create_config_folder()
}
}

int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue)
int getConfig(config_t **config)
{
create_config_folder(); // ensure the config folder exists

// Get the config file
char *config_file_path = obs_module_config_path("config.ini");

config_t *config;
int ret = config_open(&config, config_file_path, CONFIG_OPEN_EXISTING);
int ret = config_open(config, config_file_path, CONFIG_OPEN_EXISTING);
if (ret != CONFIG_SUCCESS) {
obs_log(LOG_INFO, "Failed to open config file %s",
config_file_path);
return OBS_BGREMOVAL_CONFIG_FAIL;
}

return OBS_BGREMOVAL_CONFIG_SUCCESS;
}

int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue)
{
// Get the config file
config_t *config;
if (getConfig(&config) != OBS_BGREMOVAL_CONFIG_SUCCESS) {
*returnValue = defaultValue;
return OBS_BGREMOVAL_CONFIG_FAIL;
}

*returnValue = config_get_bool(config, "config", name);
config_close(config);

bfree(config_file_path);

return OBS_BGREMOVAL_CONFIG_SUCCESS;
}

int setFlagFromConfig(const char *name, const bool value)
int setFlagInConfig(const char *name, const bool value)
{
create_config_folder(); // ensure the config folder exists

// Get the config file
char *config_file_path = obs_module_config_path("config.ini");

config_t *config;
int ret = config_open(&config, config_file_path, CONFIG_OPEN_ALWAYS);
if (ret != CONFIG_SUCCESS) {
obs_log(LOG_INFO, "Failed to open config file %s",
config_file_path);
if (getConfig(&config) != OBS_BGREMOVAL_CONFIG_SUCCESS) {
return OBS_BGREMOVAL_CONFIG_FAIL;
}

config_set_bool(config, "config", name, value);
config_save(config);
config_close(config);

bfree(config_file_path);

return OBS_BGREMOVAL_CONFIG_SUCCESS;
}
2 changes: 1 addition & 1 deletion src/obs-utils/obs-config-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ int getFlagFromConfig(const char *name, bool *returnValue, bool defaultValue);
* @return OBS_BGREMOVAL_CONFIG_SUCCESS if the config item was found,
* OBS_BGREMOVAL_CONFIG_FAIL otherwise.
*/
int setFlagFromConfig(const char *name, const bool value);
int setFlagInConfig(const char *name, const bool value);

#endif /* OBS_CONFIG_UTILS_H */
2 changes: 1 addition & 1 deletion src/update-checker/UpdateDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ UpdateDialog::UpdateDialog(
QCheckBox *disableCheckbox = new QCheckBox("Disable update checks");
layout->addWidget(disableCheckbox);
connect(disableCheckbox, &QCheckBox::stateChanged, this, [](int state) {
setFlagFromConfig("check_for_updates", state == Qt::Unchecked);
setFlagInConfig("check_for_updates", state == Qt::Unchecked);
});

// Add a button to close the dialog
Expand Down
2 changes: 1 addition & 1 deletion src/update-checker/github-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "plugin-support.h"

static const std::string GITHUB_LATEST_RELEASE_URL =
"https://api.github.com/repos/obs-ai/obs-backgroundremoval/releases/latest";
"https://api.github.com/repos/occ-ai/obs-backgroundremoval/releases/latest";

void github_utils_get_release_information(
std::function<void(github_utils_release_information)> callback)
Expand Down
2 changes: 1 addition & 1 deletion src/update-checker/update-checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void check_update(void)
// Failed to get the config value, assume it's enabled
shouldCheckForUpdates = true;
// store the default value
setFlagFromConfig("check_for_updates", shouldCheckForUpdates);
setFlagInConfig("check_for_updates", shouldCheckForUpdates);
}

if (!shouldCheckForUpdates) {
Expand Down