diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 2f3a54560..e1ab509dd 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -324,6 +324,7 @@ struct obs_core { proc_handler_t *procs; char *locale; + char *module_config_path; bool name_store_owned; profiler_name_store_t *name_store; diff --git a/libobs/obs.c b/libobs/obs.c index 979b9601d..83f2c4188 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -687,7 +687,8 @@ extern const struct obs_source_info scene_info; extern void log_system_info(void); -static bool obs_init(const char *locale, profiler_name_store_t *store) +static bool obs_init(const char *locale, const char *module_config_path, + profiler_name_store_t *store) { obs = bzalloc(sizeof(struct obs_core)); @@ -707,6 +708,8 @@ static bool obs_init(const char *locale, profiler_name_store_t *store) if (!obs_init_hotkeys()) return false; + if (module_config_path) + obs->module_config_path = bstrdup(module_config_path); obs->locale = bstrdup(locale); obs_register_source(&scene_info); add_default_module_paths(); @@ -718,7 +721,8 @@ extern void initialize_crash_handler(void); #endif static const char *obs_startup_name = "obs_startup"; -bool obs_startup(const char *locale, profiler_name_store_t *store) +bool obs_startup(const char *locale, const char *module_config_path, + profiler_name_store_t *store) { bool success; @@ -733,7 +737,7 @@ bool obs_startup(const char *locale, profiler_name_store_t *store) initialize_crash_handler(); #endif - success = obs_init(locale, store); + success = obs_init(locale, module_config_path, store); profile_end(obs_startup_name); if (!success) obs_shutdown(); @@ -783,6 +787,7 @@ void obs_shutdown(void) if (obs->name_store_owned) profiler_name_store_free(obs->name_store); + bfree(obs->module_config_path); bfree(obs->locale); bfree(obs); obs = NULL; diff --git a/libobs/obs.h b/libobs/obs.h index 9ae70bae5..09615660b 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -241,10 +241,13 @@ struct obs_source_frame { /** * Initializes OBS * - * @param locale The locale to use for modules - * @param store The profiler name store for OBS to use or NULL + * @param locale The locale to use for modules + * @param module_config_path Path to module config storage directory + * (or NULL if none) + * @param store The profiler name store for OBS to use or NULL */ -EXPORT bool obs_startup(const char *locale, profiler_name_store_t *store); +EXPORT bool obs_startup(const char *locale, const char *module_config_path, + profiler_name_store_t *store); /** Releases all data associated with OBS and terminates the OBS context */ EXPORT void obs_shutdown(void); diff --git a/libobs/obs.hpp b/libobs/obs.hpp index e167a52d6..11fbe29e4 100644 --- a/libobs/obs.hpp +++ b/libobs/obs.hpp @@ -275,9 +275,10 @@ class OBSContext { public: inline OBSContext() {} inline OBSContext(const char *locale, + const char *module_config_path=nullptr, profiler_name_store *store=nullptr) { - obs_startup(locale, store); + obs_startup(locale, module_config_path, store); } inline ~OBSContext() diff --git a/obs/obs-app.cpp b/obs/obs-app.cpp index e7a316d24..508e119c8 100644 --- a/obs/obs-app.cpp +++ b/obs/obs-app.cpp @@ -320,6 +320,10 @@ static bool MakeUserDirs() if (!do_mkdir(path)) return false; #endif + if (GetConfigPath(path, sizeof(path), "obs-studio/plugin_config") <= 0) + return false; + if (!do_mkdir(path)) + return false; return true; } @@ -592,6 +596,16 @@ const char *OBSApp::GetRenderModule() const DL_D3D11 : DL_OPENGL; } +static bool StartupOBS(const char *locale, profiler_name_store_t *store) +{ + char path[512]; + + if (GetConfigPath(path, sizeof(path), "obs-studio/plugin_config") <= 0) + return false; + + return obs_startup(locale, path, store); +} + bool OBSApp::OBSInit() { ProfileScope("OBSApp::OBSInit"); @@ -607,7 +621,9 @@ bool OBSApp::OBSInit() config_save(globalConfig); } - obs_startup(locale.c_str(), GetProfilerNameStore()); + if (!StartupOBS(locale.c_str(), GetProfilerNameStore())) + return false; + mainWindow = new OBSBasic(); mainWindow->setAttribute(Qt::WA_DeleteOnClose, true); diff --git a/test/win/test.cpp b/test/win/test.cpp index f6c53600c..8b23378a7 100644 --- a/test/win/test.cpp +++ b/test/win/test.cpp @@ -82,7 +82,7 @@ static void CreateOBS(HWND hwnd) RECT rc; GetClientRect(hwnd, &rc); - if (!obs_startup("en-US", nullptr)) + if (!obs_startup("en-US", nullptr, nullptr)) throw "Couldn't create OBS"; struct obs_video_info ovi;