adjust file locations to be more portable
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
lib_LTLIBRARIES = libobs.la
|
||||
if OS_WIN
|
||||
if ARCH_X86
|
||||
libobsdir = ../build/bin/32bit
|
||||
else
|
||||
libobsdir = ../build/bin/64bit
|
||||
endif
|
||||
else
|
||||
libobsdir = $(libdir)
|
||||
endif
|
||||
|
||||
libobs_LTLIBRARIES = libobs.la
|
||||
libobs_la_LDFLAGS = -no-undefined --version-info 0:0:0
|
||||
|
||||
if OS_WIN
|
||||
@@ -45,5 +55,9 @@ libobs_la_SOURCES = obs.c \
|
||||
graphics/vec4.c
|
||||
|
||||
if OS_WIN
|
||||
libobs_la_SOURCES += util/platform-windows.c
|
||||
libobs_la_SOURCES += util/platform-windows.c obs-windows.c
|
||||
endif
|
||||
|
||||
if OS_NIX
|
||||
libobs_la_SOURCES += util/platform-nix.c obs-nix.c
|
||||
endif
|
||||
|
@@ -76,12 +76,16 @@ complete:
|
||||
dstr_free(&enum_name);
|
||||
}
|
||||
|
||||
extern char *find_plugin(const char *plugin);
|
||||
|
||||
int obs_load_module(const char *path)
|
||||
{
|
||||
struct obs_module mod;
|
||||
bool (*module_load)(void) = NULL;
|
||||
char *plugin_path = find_plugin(path);
|
||||
|
||||
mod.module = os_dlopen(path);
|
||||
bfree(plugin_path);
|
||||
if (!mod.module)
|
||||
return MODULE_FILENOTFOUND;
|
||||
|
||||
|
51
libobs/obs-nix.c
Normal file
51
libobs/obs-nix.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/******************************************************************************
|
||||
Copyright (C) 2013 by Hugh Bailey <obs.jim@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 3 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 <stdlib.h>
|
||||
|
||||
#include "util/dstr.h"
|
||||
#include "obs.h"
|
||||
|
||||
/*
|
||||
* /usr/local/lib/obs-plugins
|
||||
* /usr/lib/obs-plugins
|
||||
*/
|
||||
char *find_plugin(const char *plugin)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* /usr/local/share/libobs
|
||||
* /usr/share/libobs
|
||||
*/
|
||||
char *find_libobs_data_file(const char *file)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* /usr/local/share/obs-plugins
|
||||
* /usr/share/obs-plugins
|
||||
*/
|
||||
char *obs_find_plugin_file(const char *file)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
52
libobs/obs-windows.c
Normal file
52
libobs/obs-windows.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
Copyright (C) 2013 by Hugh Bailey <obs.jim@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 3 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 "util/platform.h"
|
||||
#include "util/dstr.h"
|
||||
#include "obs.h"
|
||||
#include "obs-data.h"
|
||||
|
||||
/* on windows, plugin files are located in [base directory]/plugins/[bit] */
|
||||
char *find_plugin(const char *plugin)
|
||||
{
|
||||
struct dstr path;
|
||||
#ifdef _WIN64
|
||||
dstr_init_copy(&path, "../../plugins/64bit/");
|
||||
#else
|
||||
dstr_init_copy(&path, "../../plugins/32bit/");
|
||||
#endif
|
||||
dstr_cat(&path, plugin);
|
||||
return path.array;
|
||||
}
|
||||
|
||||
/* on windows, points to [base directory]/libobs */
|
||||
char *find_libobs_data_file(const char *file)
|
||||
{
|
||||
struct dstr path;
|
||||
dstr_init_copy(&path, "../../libobs/");
|
||||
dstr_cat(&path, file);
|
||||
return path.array;
|
||||
}
|
||||
|
||||
/* on windows, data files should always be in [base directory]/data */
|
||||
char *obs_find_plugin_file(const char *file)
|
||||
{
|
||||
struct dstr path;
|
||||
dstr_init_copy(&path, "../../data/");
|
||||
dstr_cat(&path, file);
|
||||
return path.array;
|
||||
}
|
@@ -21,6 +21,8 @@
|
||||
|
||||
struct obs_data *obs = NULL;
|
||||
|
||||
extern char *find_libobs_data_file(const char *file);
|
||||
|
||||
static bool obs_init_graphics(const char *graphics_module,
|
||||
struct gs_init_data *graphics_data, struct video_info *vi)
|
||||
{
|
||||
@@ -46,8 +48,10 @@ static bool obs_init_graphics(const char *graphics_module,
|
||||
}
|
||||
|
||||
if (success) {
|
||||
obs->default_effect = gs_create_effect_from_file(
|
||||
"data/effects/default.effect", NULL);
|
||||
char *filename = find_libobs_data_file("default.effect");
|
||||
obs->default_effect = gs_create_effect_from_file( filename,
|
||||
NULL);
|
||||
bfree(filename);
|
||||
if (!obs->default_effect)
|
||||
success = false;
|
||||
}
|
||||
|
@@ -184,6 +184,14 @@ EXPORT media_t obs_media(void);
|
||||
EXPORT void obs_set_primary_source(obs_source_t source);
|
||||
EXPORT obs_source_t obs_get_primary_source(void);
|
||||
|
||||
/**
|
||||
* Returns the location of a plugin data file.
|
||||
*
|
||||
* file: Name of file to locate. For example, "myplugin/mydata.data"
|
||||
* returns: Output string, or NULL if not found. Use bfree to free string.
|
||||
*/
|
||||
EXPORT char *obs_find_plugin_file(const char *file);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Display context */
|
||||
|
73
libobs/util/platform-nix.c
Normal file
73
libobs/util/platform-nix.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/******************************************************************************
|
||||
Copyright (c) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dstr.h"
|
||||
#include "platform.h"
|
||||
|
||||
void *os_dlopen(const char *path)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *os_dlsym(void *module, const char *func)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void os_dlclose(void *module)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void os_sleepto_ns(uint64_t time_target)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void os_sleep_ms(uint32_t duration)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
uint64_t os_gettime_ns(void)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t os_gettime_ms(void)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* should return $HOME/ */
|
||||
char *os_get_home_path(void)
|
||||
{
|
||||
/* TODO */
|
||||
return NULL;
|
||||
}
|
@@ -22,9 +22,12 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#include "base.h"
|
||||
#include "platform.h"
|
||||
#include "bmem.h"
|
||||
#include "dstr.h"
|
||||
|
||||
#include "../../deps/w32-pthreads/pthread.h"
|
||||
|
||||
@@ -68,7 +71,16 @@ void *os_dlopen(const char *path)
|
||||
|
||||
void *os_dlsym(void *module, const char *func)
|
||||
{
|
||||
return (void*)GetProcAddress(module, func);
|
||||
struct dstr dll_name;
|
||||
void *handle;
|
||||
|
||||
dstr_init_copy(&dll_name, module);
|
||||
dstr_cat(&dll_name, ".dll");
|
||||
|
||||
handle = (void*)GetProcAddress(module, func);
|
||||
|
||||
dstr_free(&dll_name);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void os_dlclose(void *module)
|
||||
@@ -136,6 +148,18 @@ uint64_t os_gettime_ms(void)
|
||||
return time_val;
|
||||
}
|
||||
|
||||
/* returns %appdata% on windows */
|
||||
char *os_get_home_path(void)
|
||||
{
|
||||
char *out;
|
||||
wchar_t path_utf16[MAX_PATH];
|
||||
SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
|
||||
path_utf16);
|
||||
|
||||
os_wcs_to_utf8(path_utf16, 0, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
#ifdef PTW32_STATIC_LIB
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
|
||||
|
@@ -70,6 +70,8 @@ EXPORT void os_sleep_ms(uint32_t duration);
|
||||
EXPORT uint64_t os_gettime_ns(void);
|
||||
EXPORT uint64_t os_gettime_ms(void);
|
||||
|
||||
EXPORT char *os_get_home_path(void);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
EXPORT int fseeko(FILE *stream, off_t offset, int whence);
|
||||
EXPORT off_t ftello(FILE *stream);
|
||||
|
Reference in New Issue
Block a user