Files
obs-studio/libobs/obs-core-modules-loader-nix.c
FiniteSingularityandPatTheMav 23bba4413b libobs: Add core module loading functionality
Adds a separate code path just for loading core modules based on the
list of modules created at build system generation. Paths to load core
modules from is platform-specific, but not changeable for users and is
thus not changeable by a caller.

Instead path discovery is implemented for each platform separately,
generating the necessary module loading package directly before handing
it over to the existing module load callback function.

Co-authored-by: PatTheMav <PatTheMav@users.noreply.github.com>
2026-09-23 18:53:19 -04:00

63 lines
2.2 KiB
C

/******************************************************************************
Copyright (C) 2026 by FiniteSingularity <finitesingularityttv@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "obs-core-modules.h"
#include <obs-internal.h>
#include <obs.h>
#include <util/dstr.h>
#include <util/platform.h>
const char *core_module_bin = "../" OBS_PLUGIN_PATH "/%module%";
const char *core_module_data = "../" OBS_DATA_PATH "/obs-modules/core/%module%";
extern bool find_core_module(struct obs_runtime_module_info *info, obs_find_module_callback2_t callback, void *data);
void load_core_modules(obs_find_module_callback2_t callback, void *data)
{
char *core_bin_path = os_get_executable_path_ptr(core_module_bin);
char *core_data_path = os_get_executable_path_ptr(core_module_data);
for (unsigned int i = 0; i < obs_core_modules_count; i++) {
const char *name = obs_core_modules[i];
struct dstr bin_path;
struct dstr data_path;
dstr_init_copy(&bin_path, core_bin_path);
dstr_init_copy(&data_path, core_data_path);
dstr_replace(&bin_path, "%module%", name);
dstr_replace(&data_path, "%module%", name);
struct obs_runtime_module_info module_info = {.path_info = {.binary = bin_path.array,
.data = data_path.array},
.type = OBS_MODULE_TYPE_CORE,
.name = name};
bool found = find_core_module(&module_info, callback, data);
dstr_free(&bin_path);
dstr_free(&data_path);
if (!found) {
blog(LOG_ERROR, "Failed to load core module %s", name);
break;
}
}
bfree(core_bin_path);
bfree(core_data_path);
}