0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

(API Change) libobs: Add global module config path

API Changed:
---------------------------
From:
- bool obs_startup(const char *locale, profiler_name_store_t *store);

To:
- bool obs_startup(const char *locale, const char *module_config_path,
		profiler_name_store_t *store);

Summary:
---------------------------
This allows plugin modules to store plugin-specific configuration data
(rather than only allowing objects to store configuration data).  This
will be useful for things like caching data, for example looking up and
storing ingests from remote (rather than storing locally), or caching
font data (so it doesn't have to build a font cache each time), among
other things.

Also adds a module-specific directory for the UI
This commit is contained in:
jp9000 2015-08-09 05:09:07 -07:00
parent 0ce756acba
commit 2bd8ab7c09
6 changed files with 35 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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