New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
18
deps/obs-scripting/obs-scripting-callback.h
vendored
18
deps/obs-scripting/obs-scripting-callback.h
vendored
|
|
@ -36,10 +36,8 @@ struct script_callback {
|
|||
bool removed;
|
||||
};
|
||||
|
||||
static inline void *add_script_callback(
|
||||
struct script_callback **first,
|
||||
obs_script_t *script,
|
||||
size_t extra_size)
|
||||
static inline void *add_script_callback(struct script_callback **first,
|
||||
obs_script_t *script, size_t extra_size)
|
||||
{
|
||||
struct script_callback *cb = bzalloc(sizeof(*cb) + extra_size);
|
||||
cb->script = script;
|
||||
|
|
@ -47,7 +45,8 @@ static inline void *add_script_callback(
|
|||
struct script_callback *next = *first;
|
||||
cb->next = next;
|
||||
cb->p_prev_next = first;
|
||||
if (next) next->p_prev_next = &cb->next;
|
||||
if (next)
|
||||
next->p_prev_next = &cb->next;
|
||||
*first = cb;
|
||||
|
||||
return cb;
|
||||
|
|
@ -58,13 +57,15 @@ static inline void remove_script_callback(struct script_callback *cb)
|
|||
cb->removed = true;
|
||||
|
||||
struct script_callback *next = cb->next;
|
||||
if (next) next->p_prev_next = cb->p_prev_next;
|
||||
if (next)
|
||||
next->p_prev_next = cb->p_prev_next;
|
||||
*cb->p_prev_next = cb->next;
|
||||
|
||||
pthread_mutex_lock(&detach_mutex);
|
||||
next = detached_callbacks;
|
||||
cb->next = next;
|
||||
if (next) next->p_prev_next = &cb->next;
|
||||
if (next)
|
||||
next->p_prev_next = &cb->next;
|
||||
cb->p_prev_next = &detached_callbacks;
|
||||
detached_callbacks = cb;
|
||||
pthread_mutex_unlock(&detach_mutex);
|
||||
|
|
@ -83,7 +84,8 @@ static inline void free_script_callback(struct script_callback *cb)
|
|||
{
|
||||
pthread_mutex_lock(&detach_mutex);
|
||||
struct script_callback *next = cb->next;
|
||||
if (next) next->p_prev_next = cb->p_prev_next;
|
||||
if (next)
|
||||
next->p_prev_next = cb->p_prev_next;
|
||||
*cb->p_prev_next = cb->next;
|
||||
pthread_mutex_unlock(&detach_mutex);
|
||||
|
||||
|
|
|
|||
5
deps/obs-scripting/obs-scripting-internal.h
vendored
5
deps/obs-scripting/obs-scripting-internal.h
vendored
|
|
@ -37,9 +37,10 @@ typedef void (*defer_call_cb)(void *param);
|
|||
|
||||
extern void defer_call_post(defer_call_cb call, void *cb);
|
||||
|
||||
extern void script_log(obs_script_t *script, int level, const char *format, ...);
|
||||
extern void script_log(obs_script_t *script, int level, const char *format,
|
||||
...);
|
||||
extern void script_log_va(obs_script_t *script, int level, const char *format,
|
||||
va_list args);
|
||||
va_list args);
|
||||
|
||||
#define script_error(script, format, ...) \
|
||||
script_log(script, LOG_ERROR, format, ##__VA_ARGS__)
|
||||
|
|
|
|||
20
deps/obs-scripting/obs-scripting-logging.c
vendored
20
deps/obs-scripting/obs-scripting-logging.c
vendored
|
|
@ -22,7 +22,7 @@ static scripting_log_handler_t callback = NULL;
|
|||
static void *param = NULL;
|
||||
|
||||
void script_log_va(obs_script_t *script, int level, const char *format,
|
||||
va_list args)
|
||||
va_list args)
|
||||
{
|
||||
char msg[2048];
|
||||
const char *lang = "(Unknown)";
|
||||
|
|
@ -30,13 +30,19 @@ void script_log_va(obs_script_t *script, int level, const char *format,
|
|||
|
||||
if (script) {
|
||||
switch (script->type) {
|
||||
case OBS_SCRIPT_LANG_UNKNOWN: lang = "(Unknown language)"; break;
|
||||
case OBS_SCRIPT_LANG_LUA: lang = "Lua"; break;
|
||||
case OBS_SCRIPT_LANG_PYTHON: lang = "Python"; break;
|
||||
case OBS_SCRIPT_LANG_UNKNOWN:
|
||||
lang = "(Unknown language)";
|
||||
break;
|
||||
case OBS_SCRIPT_LANG_LUA:
|
||||
lang = "Lua";
|
||||
break;
|
||||
case OBS_SCRIPT_LANG_PYTHON:
|
||||
lang = "Python";
|
||||
break;
|
||||
}
|
||||
|
||||
start_len = snprintf(msg, sizeof(msg), "[%s: %s] ",
|
||||
lang, script->file.array);
|
||||
start_len = snprintf(msg, sizeof(msg), "[%s: %s] ", lang,
|
||||
script->file.array);
|
||||
} else {
|
||||
start_len = snprintf(msg, sizeof(msg), "[Unknown Script] ");
|
||||
}
|
||||
|
|
@ -57,7 +63,7 @@ void script_log(obs_script_t *script, int level, const char *format, ...)
|
|||
}
|
||||
|
||||
void obs_scripting_set_log_callback(scripting_log_handler_t handler,
|
||||
void *log_param)
|
||||
void *log_param)
|
||||
{
|
||||
callback = handler;
|
||||
param = log_param;
|
||||
|
|
|
|||
24
deps/obs-scripting/obs-scripting-lua-frontend.c
vendored
24
deps/obs-scripting/obs-scripting-lua-frontend.c
vendored
|
|
@ -20,12 +20,12 @@
|
|||
|
||||
#include "obs-scripting-lua.h"
|
||||
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(script, #type " *", lua_index, obs_obj, \
|
||||
NULL, __FUNCTION__, __LINE__)
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
ls_push_libobs_obj_(script, #type " *", obs_obj, ownership, \
|
||||
NULL, __FUNCTION__, __LINE__)
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(script, #type " *", lua_index, obs_obj, NULL, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
ls_push_libobs_obj_(script, #type " *", obs_obj, ownership, NULL, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define call_func(func, args, rets) \
|
||||
call_func_(script, cb->reg_idx, args, rets, #func, "frontend API")
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ static void frontend_event_callback(enum obs_frontend_event event, void *priv)
|
|||
lua_State *script = cb->script;
|
||||
|
||||
if (cb->base.removed) {
|
||||
obs_frontend_remove_event_callback(frontend_event_callback, cb);
|
||||
obs_frontend_remove_event_callback(frontend_event_callback, cb);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ static int add_event_callback(lua_State *script)
|
|||
/* ----------------------------------- */
|
||||
|
||||
static void frontend_save_callback(obs_data_t *save_data, bool saving,
|
||||
void *priv)
|
||||
void *priv)
|
||||
{
|
||||
struct lua_obs_callback *cb = priv;
|
||||
lua_State *script = cb->script;
|
||||
|
|
@ -285,11 +285,11 @@ void add_lua_frontend_funcs(lua_State *script)
|
|||
{
|
||||
lua_getglobal(script, "obslua");
|
||||
|
||||
#define add_func(name) \
|
||||
do { \
|
||||
#define add_func(name) \
|
||||
do { \
|
||||
lua_pushstring(script, "obs_frontend_" #name); \
|
||||
lua_pushcfunction(script, name); \
|
||||
lua_rawset(script, -3); \
|
||||
lua_pushcfunction(script, name); \
|
||||
lua_rawset(script, -3); \
|
||||
} while (false)
|
||||
|
||||
add_func(get_scene_names);
|
||||
|
|
|
|||
229
deps/obs-scripting/obs-scripting-lua-source.c
vendored
229
deps/obs-scripting/obs-scripting-lua-source.c
vendored
|
|
@ -23,7 +23,7 @@
|
|||
/* ========================================================================= */
|
||||
|
||||
static inline const char *get_table_string_(lua_State *script, int idx,
|
||||
const char *name, const char *func)
|
||||
const char *name, const char *func)
|
||||
{
|
||||
const char *str = "";
|
||||
|
||||
|
|
@ -38,8 +38,8 @@ static inline const char *get_table_string_(lua_State *script, int idx,
|
|||
return str;
|
||||
}
|
||||
|
||||
static inline int get_table_int_(lua_State *script, int idx,
|
||||
const char *name, const char *func)
|
||||
static inline int get_table_int_(lua_State *script, int idx, const char *name,
|
||||
const char *func)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
|
|
@ -54,7 +54,8 @@ static inline int get_table_int_(lua_State *script, int idx,
|
|||
}
|
||||
|
||||
static inline void get_callback_from_table_(lua_State *script, int idx,
|
||||
const char *name, int *p_reg_idx, const char *func)
|
||||
const char *name, int *p_reg_idx,
|
||||
const char *func)
|
||||
{
|
||||
*p_reg_idx = LUA_REFNIL;
|
||||
|
||||
|
|
@ -77,22 +78,14 @@ static inline void get_callback_from_table_(lua_State *script, int idx,
|
|||
#define get_callback_from_table(script, idx, name, p_reg_idx) \
|
||||
get_callback_from_table_(script, idx, name, p_reg_idx, __FUNCTION__)
|
||||
|
||||
bool ls_get_libobs_obj_(lua_State * script,
|
||||
const char *type,
|
||||
int lua_idx,
|
||||
void * libobs_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line)
|
||||
bool ls_get_libobs_obj_(lua_State *script, const char *type, int lua_idx,
|
||||
void *libobs_out, const char *id, const char *func,
|
||||
int line)
|
||||
{
|
||||
swig_type_info *info = SWIG_TypeQuery(script, type);
|
||||
if (info == NULL) {
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s", func, line,
|
||||
id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -100,37 +93,25 @@ bool ls_get_libobs_obj_(lua_State * script,
|
|||
if (!SWIG_IsOK(ret)) {
|
||||
warn("%s:%d: SWIG failed to convert lua object to obs "
|
||||
"object: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
func, line, id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(ls->script, #type " *", lua_index, obs_obj, \
|
||||
ls->id, __FUNCTION__, __LINE__)
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(ls->script, #type " *", lua_index, obs_obj, ls->id, \
|
||||
__FUNCTION__, __LINE__)
|
||||
|
||||
bool ls_push_libobs_obj_(lua_State * script,
|
||||
const char *type,
|
||||
void * libobs_in,
|
||||
bool ownership,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line)
|
||||
bool ls_push_libobs_obj_(lua_State *script, const char *type, void *libobs_in,
|
||||
bool ownership, const char *id, const char *func,
|
||||
int line)
|
||||
{
|
||||
swig_type_info *info = SWIG_TypeQuery(script, type);
|
||||
if (info == NULL) {
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s", func, line,
|
||||
id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -138,9 +119,9 @@ bool ls_push_libobs_obj_(lua_State * script,
|
|||
return true;
|
||||
}
|
||||
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
ls_push_libobs_obj_(ls->script, #type " *", obs_obj, ownership, \
|
||||
ls->id, __FUNCTION__, __LINE__)
|
||||
ls->id, __FUNCTION__, __LINE__)
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
|
|
@ -149,24 +130,24 @@ struct obs_lua_data;
|
|||
struct obs_lua_source {
|
||||
struct obs_lua_script *data;
|
||||
|
||||
lua_State * script;
|
||||
lua_State *script;
|
||||
const char *id;
|
||||
const char *display_name;
|
||||
int func_create;
|
||||
int func_destroy;
|
||||
int func_get_width;
|
||||
int func_get_height;
|
||||
int func_get_defaults;
|
||||
int func_get_properties;
|
||||
int func_update;
|
||||
int func_activate;
|
||||
int func_deactivate;
|
||||
int func_show;
|
||||
int func_hide;
|
||||
int func_video_tick;
|
||||
int func_video_render;
|
||||
int func_save;
|
||||
int func_load;
|
||||
int func_create;
|
||||
int func_destroy;
|
||||
int func_get_width;
|
||||
int func_get_height;
|
||||
int func_get_defaults;
|
||||
int func_get_properties;
|
||||
int func_update;
|
||||
int func_activate;
|
||||
int func_deactivate;
|
||||
int func_show;
|
||||
int func_hide;
|
||||
int func_video_tick;
|
||||
int func_video_render;
|
||||
int func_save;
|
||||
int func_load;
|
||||
|
||||
pthread_mutex_t definition_mutex;
|
||||
struct obs_lua_data *first_source;
|
||||
|
|
@ -179,29 +160,27 @@ extern pthread_mutex_t lua_source_def_mutex;
|
|||
struct obs_lua_source *first_source_def = NULL;
|
||||
|
||||
struct obs_lua_data {
|
||||
obs_source_t * source;
|
||||
obs_source_t *source;
|
||||
struct obs_lua_source *ls;
|
||||
int lua_data_ref;
|
||||
int lua_data_ref;
|
||||
|
||||
struct obs_lua_data *next;
|
||||
struct obs_lua_data **p_prev_next;
|
||||
};
|
||||
|
||||
#define call_func(name, args, rets) \
|
||||
call_func_(ls->script, ls->func_ ## name, args, rets, #name, \
|
||||
ls->display_name)
|
||||
#define have_func(name) \
|
||||
(ls->func_ ## name != LUA_REFNIL)
|
||||
#define call_func(name, args, rets) \
|
||||
call_func_(ls->script, ls->func_##name, args, rets, #name, \
|
||||
ls->display_name)
|
||||
#define have_func(name) (ls->func_##name != LUA_REFNIL)
|
||||
#define ls_push_data() \
|
||||
lua_rawgeti(ls->script, LUA_REGISTRYINDEX, ld->lua_data_ref)
|
||||
#define ls_pop(count) \
|
||||
lua_pop(ls->script, count)
|
||||
#define lock_script() \
|
||||
struct obs_lua_script *__data = ls->data; \
|
||||
#define ls_pop(count) lua_pop(ls->script, count)
|
||||
#define lock_script() \
|
||||
struct obs_lua_script *__data = ls->data; \
|
||||
struct obs_lua_script *__prev_script = current_lua_script; \
|
||||
current_lua_script = __data; \
|
||||
current_lua_script = __data; \
|
||||
pthread_mutex_lock(&__data->mutex);
|
||||
#define unlock_script() \
|
||||
#define unlock_script() \
|
||||
pthread_mutex_unlock(&__data->mutex); \
|
||||
current_lua_script = __prev_script;
|
||||
|
||||
|
|
@ -230,9 +209,9 @@ static void *obs_lua_source_create(obs_data_t *settings, obs_source_t *source)
|
|||
|
||||
int lua_data_ref = luaL_ref(ls->script, LUA_REGISTRYINDEX);
|
||||
if (lua_data_ref != LUA_REFNIL) {
|
||||
data = bmalloc(sizeof(*data));
|
||||
data->source = source;
|
||||
data->ls = ls;
|
||||
data = bmalloc(sizeof(*data));
|
||||
data->source = source;
|
||||
data->ls = ls;
|
||||
data->lua_data_ref = lua_data_ref;
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +221,8 @@ static void *obs_lua_source_create(obs_data_t *settings, obs_source_t *source)
|
|||
struct obs_lua_data *next = ls->first_source;
|
||||
data->next = next;
|
||||
data->p_prev_next = &ls->first_source;
|
||||
if (next) next->p_prev_next = &data->next;
|
||||
if (next)
|
||||
next->p_prev_next = &data->next;
|
||||
ls->first_source = data;
|
||||
}
|
||||
|
||||
|
|
@ -263,9 +243,9 @@ static void call_destroy(struct obs_lua_data *ld)
|
|||
|
||||
static void obs_lua_source_destroy(void *data)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
struct obs_lua_data * next;
|
||||
struct obs_lua_data *next;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
if (!ls->script)
|
||||
|
|
@ -280,7 +260,8 @@ static void obs_lua_source_destroy(void *data)
|
|||
fail:
|
||||
next = ld->next;
|
||||
*ld->p_prev_next = next;
|
||||
if (next) next->p_prev_next = ld->p_prev_next;
|
||||
if (next)
|
||||
next->p_prev_next = ld->p_prev_next;
|
||||
|
||||
bfree(data);
|
||||
pthread_mutex_unlock(&ls->definition_mutex);
|
||||
|
|
@ -288,9 +269,9 @@ fail:
|
|||
|
||||
static uint32_t obs_lua_source_get_width(void *data)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
uint32_t width = 0;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
uint32_t width = 0;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
if (!ls->script)
|
||||
|
|
@ -315,9 +296,9 @@ fail:
|
|||
|
||||
static uint32_t obs_lua_source_get_height(void *data)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
uint32_t height = 0;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
uint32_t height = 0;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
if (!ls->script)
|
||||
|
|
@ -363,9 +344,9 @@ fail:
|
|||
|
||||
static obs_properties_t *obs_lua_source_get_properties(void *data)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
obs_properties_t * props = NULL;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
obs_properties_t *props = NULL;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
if (!ls->script)
|
||||
|
|
@ -390,7 +371,7 @@ fail:
|
|||
|
||||
static void obs_lua_source_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
|
|
@ -411,17 +392,17 @@ fail:
|
|||
pthread_mutex_unlock(&ls->definition_mutex);
|
||||
}
|
||||
|
||||
#define DEFINE_VOID_DATA_CALLBACK(name) \
|
||||
static void obs_lua_source_ ## name(void *data) \
|
||||
{ \
|
||||
struct obs_lua_data * ld = data; \
|
||||
struct obs_lua_source *ls = ld->ls; \
|
||||
if (!have_func(name)) \
|
||||
return; \
|
||||
lock_script(); \
|
||||
ls_push_data(); \
|
||||
call_func(name, 1, 0); \
|
||||
unlock_script(); \
|
||||
#define DEFINE_VOID_DATA_CALLBACK(name) \
|
||||
static void obs_lua_source_##name(void *data) \
|
||||
{ \
|
||||
struct obs_lua_data *ld = data; \
|
||||
struct obs_lua_source *ls = ld->ls; \
|
||||
if (!have_func(name)) \
|
||||
return; \
|
||||
lock_script(); \
|
||||
ls_push_data(); \
|
||||
call_func(name, 1, 0); \
|
||||
unlock_script(); \
|
||||
}
|
||||
DEFINE_VOID_DATA_CALLBACK(activate)
|
||||
DEFINE_VOID_DATA_CALLBACK(deactivate)
|
||||
|
|
@ -431,7 +412,7 @@ DEFINE_VOID_DATA_CALLBACK(hide)
|
|||
|
||||
static void obs_lua_source_video_tick(void *data, float seconds)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
|
|
@ -454,7 +435,7 @@ fail:
|
|||
|
||||
static void obs_lua_source_video_render(void *data, gs_effect_t *effect)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
|
|
@ -477,7 +458,7 @@ fail:
|
|||
|
||||
static void obs_lua_source_save(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
|
|
@ -500,7 +481,7 @@ fail:
|
|||
|
||||
static void obs_lua_source_load(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct obs_lua_data * ld = data;
|
||||
struct obs_lua_data *ld = data;
|
||||
struct obs_lua_source *ls = ld->ls;
|
||||
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
|
|
@ -523,7 +504,7 @@ fail:
|
|||
|
||||
static void source_type_unload(struct obs_lua_source *ls)
|
||||
{
|
||||
#define unref(name) \
|
||||
#define unref(name) \
|
||||
luaL_unref(ls->script, LUA_REGISTRYINDEX, name); \
|
||||
name = LUA_REFNIL
|
||||
|
||||
|
|
@ -614,9 +595,9 @@ static int obs_lua_register_source(lua_State *script)
|
|||
v = existing ? existing : &ls;
|
||||
|
||||
v->script = script;
|
||||
v->id = id;
|
||||
v->id = id;
|
||||
|
||||
info.id = v->id;
|
||||
info.id = v->id;
|
||||
info.type = (enum obs_source_type)get_table_int(script, -1, "type");
|
||||
|
||||
info.output_flags = get_table_int(script, -1, "output_flags");
|
||||
|
|
@ -628,16 +609,14 @@ static int obs_lua_register_source(lua_State *script)
|
|||
lua_pop(script, 1);
|
||||
}
|
||||
|
||||
if (!v->display_name ||
|
||||
!*v->display_name ||
|
||||
!*info.id ||
|
||||
if (!v->display_name || !*v->display_name || !*info.id ||
|
||||
!info.output_flags)
|
||||
goto fail;
|
||||
|
||||
#define get_callback(val) \
|
||||
do { \
|
||||
get_callback_from_table(script, -1, #val, &v->func_ ## val); \
|
||||
info.val = obs_lua_source_ ## val; \
|
||||
#define get_callback(val) \
|
||||
do { \
|
||||
get_callback_from_table(script, -1, #val, &v->func_##val); \
|
||||
info.val = obs_lua_source_##val; \
|
||||
} while (false)
|
||||
|
||||
get_callback(create);
|
||||
|
|
@ -657,16 +636,21 @@ static int obs_lua_register_source(lua_State *script)
|
|||
#undef get_callback
|
||||
|
||||
get_callback_from_table(script, -1, "get_defaults",
|
||||
&v->func_get_defaults);
|
||||
&v->func_get_defaults);
|
||||
|
||||
if (!existing) {
|
||||
ls.data = current_lua_script;
|
||||
|
||||
pthread_mutex_init(&ls.definition_mutex, NULL);
|
||||
info.type_data = bmemdup(&ls, sizeof(ls));
|
||||
pthread_mutexattr_t mutexattr;
|
||||
pthread_mutexattr_init(&mutexattr);
|
||||
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&ls.definition_mutex, &mutexattr);
|
||||
pthread_mutexattr_destroy(&mutexattr);
|
||||
|
||||
info.type_data = bmemdup(&ls, sizeof(ls));
|
||||
info.free_type_data = obs_lua_source_free_type_data;
|
||||
info.get_name = obs_lua_source_get_name;
|
||||
info.get_defaults2 = obs_lua_source_get_defaults;
|
||||
info.get_name = obs_lua_source_get_name;
|
||||
info.get_defaults2 = obs_lua_source_get_defaults;
|
||||
obs_register_source(&info);
|
||||
|
||||
pthread_mutex_lock(&lua_source_def_mutex);
|
||||
|
|
@ -674,7 +658,8 @@ static int obs_lua_register_source(lua_State *script)
|
|||
|
||||
struct obs_lua_source *next = first_source_def;
|
||||
v->next = next;
|
||||
if (next) next->p_prev_next = &v->next;
|
||||
if (next)
|
||||
next->p_prev_next = &v->next;
|
||||
v->p_prev_next = &first_source_def;
|
||||
first_source_def = v;
|
||||
|
||||
|
|
@ -690,15 +675,15 @@ static int obs_lua_register_source(lua_State *script)
|
|||
|
||||
if (have_func(create)) {
|
||||
obs_source_t *source = ld->source;
|
||||
obs_data_t *settings = obs_source_get_settings(
|
||||
source);
|
||||
obs_data_t *settings =
|
||||
obs_source_get_settings(source);
|
||||
|
||||
ls_push_libobs_obj(obs_data_t, settings, false);
|
||||
ls_push_libobs_obj(obs_source_t, source, false);
|
||||
call_func(create, 2, 1);
|
||||
|
||||
ld->lua_data_ref = luaL_ref(ls->script,
|
||||
LUA_REGISTRYINDEX);
|
||||
ld->lua_data_ref =
|
||||
luaL_ref(ls->script, LUA_REGISTRYINDEX);
|
||||
obs_data_release(settings);
|
||||
}
|
||||
|
||||
|
|
@ -727,7 +712,7 @@ void add_lua_source_functions(lua_State *script)
|
|||
}
|
||||
|
||||
static inline void undef_source_type(struct obs_lua_script *data,
|
||||
struct obs_lua_source *ls)
|
||||
struct obs_lua_source *ls)
|
||||
{
|
||||
pthread_mutex_lock(&ls->definition_mutex);
|
||||
pthread_mutex_lock(&data->mutex);
|
||||
|
|
|
|||
169
deps/obs-scripting/obs-scripting-lua.c
vendored
169
deps/obs-scripting/obs-scripting-lua.c
vendored
|
|
@ -26,17 +26,17 @@
|
|||
/* ========================================================================= */
|
||||
|
||||
#if ARCH_BITS == 64
|
||||
# define ARCH_DIR "64bit"
|
||||
#define ARCH_DIR "64bit"
|
||||
#else
|
||||
# define ARCH_DIR "32bit"
|
||||
#define ARCH_DIR "32bit"
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define SO_EXT "dylib"
|
||||
#define SO_EXT "dylib"
|
||||
#elif _WIN32
|
||||
# define SO_EXT "dll"
|
||||
#define SO_EXT "dll"
|
||||
#else
|
||||
# define SO_EXT "so"
|
||||
#define SO_EXT "so"
|
||||
#endif
|
||||
|
||||
static const char *startup_script_template = "\
|
||||
|
|
@ -59,15 +59,14 @@ static struct obs_lua_script *first_tick_script = NULL;
|
|||
|
||||
pthread_mutex_t lua_source_def_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(script, #type " *", lua_index, obs_obj, \
|
||||
NULL, __FUNCTION__, __LINE__)
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
ls_push_libobs_obj_(script, #type " *", obs_obj, ownership, \
|
||||
NULL, __FUNCTION__, __LINE__)
|
||||
#define ls_get_libobs_obj(type, lua_index, obs_obj) \
|
||||
ls_get_libobs_obj_(script, #type " *", lua_index, obs_obj, NULL, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define ls_push_libobs_obj(type, obs_obj, ownership) \
|
||||
ls_push_libobs_obj_(script, #type " *", obs_obj, ownership, NULL, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define call_func(name, args, rets) \
|
||||
call_func_(script, cb->reg_idx, \
|
||||
args, rets, #name, __FUNCTION__)
|
||||
call_func_(script, cb->reg_idx, args, rets, #name, __FUNCTION__)
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
|
|
@ -98,7 +97,7 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
|
||||
if (luaL_dostring(script, startup_script) != 0) {
|
||||
script_warn(&data->base, "Error executing startup script 1: %s",
|
||||
lua_tostring(script, -1));
|
||||
lua_tostring(script, -1));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +107,7 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
|
||||
if (ret != 0) {
|
||||
script_warn(&data->base, "Error executing startup script 2: %s",
|
||||
lua_tostring(script, -1));
|
||||
lua_tostring(script, -1));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -122,13 +121,13 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
|
||||
if (luaL_loadfile(script, data->base.path.array) != 0) {
|
||||
script_warn(&data->base, "Error loading file: %s",
|
||||
lua_tostring(script, -1));
|
||||
lua_tostring(script, -1));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (lua_pcall(script, 0, LUA_MULTRET, 0) != 0) {
|
||||
script_warn(&data->base, "Error running file: %s",
|
||||
lua_tostring(script, -1));
|
||||
lua_tostring(script, -1));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +147,8 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
struct obs_lua_script *next = first_tick_script;
|
||||
data->next_tick = next;
|
||||
data->p_prev_next_tick = &first_tick_script;
|
||||
if (next) next->p_prev_next_tick = &data->next_tick;
|
||||
if (next)
|
||||
next->p_prev_next_tick = &data->next_tick;
|
||||
first_tick_script = data;
|
||||
|
||||
data->tick = luaL_ref(script, LUA_REGISTRYINDEX);
|
||||
|
|
@ -178,18 +178,20 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
if (lua_isfunction(script, -1)) {
|
||||
ls_push_libobs_obj(obs_data_t, data->base.settings, false);
|
||||
if (lua_pcall(script, 1, 0, 0) != 0) {
|
||||
script_warn(&data->base, "Error calling "
|
||||
"script_defaults: %s",
|
||||
lua_tostring(script, -1));
|
||||
script_warn(&data->base,
|
||||
"Error calling "
|
||||
"script_defaults: %s",
|
||||
lua_tostring(script, -1));
|
||||
}
|
||||
}
|
||||
|
||||
lua_getglobal(script, "script_description");
|
||||
if (lua_isfunction(script, -1)) {
|
||||
if (lua_pcall(script, 0, 1, 0) != 0) {
|
||||
script_warn(&data->base, "Error calling "
|
||||
"script_defaults: %s",
|
||||
lua_tostring(script, -1));
|
||||
script_warn(&data->base,
|
||||
"Error calling "
|
||||
"script_defaults: %s",
|
||||
lua_tostring(script, -1));
|
||||
} else {
|
||||
const char *desc = lua_tostring(script, -1);
|
||||
dstr_copy(&data->base.desc, desc);
|
||||
|
|
@ -200,9 +202,10 @@ static bool load_lua_script(struct obs_lua_script *data)
|
|||
if (lua_isfunction(script, -1)) {
|
||||
ls_push_libobs_obj(obs_data_t, data->base.settings, false);
|
||||
if (lua_pcall(script, 1, 0, 0) != 0) {
|
||||
script_warn(&data->base, "Error calling "
|
||||
"script_load: %s",
|
||||
lua_tostring(script, -1));
|
||||
script_warn(&data->base,
|
||||
"Error calling "
|
||||
"script_load: %s",
|
||||
lua_tostring(script, -1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +251,8 @@ static inline void lua_obs_timer_init(struct lua_obs_timer *timer)
|
|||
struct lua_obs_timer *next = first_timer;
|
||||
timer->next = next;
|
||||
timer->p_prev_next = &first_timer;
|
||||
if (next) next->p_prev_next = &timer->next;
|
||||
if (next)
|
||||
next->p_prev_next = &timer->next;
|
||||
first_timer = timer;
|
||||
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
|
|
@ -257,12 +261,13 @@ static inline void lua_obs_timer_init(struct lua_obs_timer *timer)
|
|||
static inline void lua_obs_timer_remove(struct lua_obs_timer *timer)
|
||||
{
|
||||
struct lua_obs_timer *next = timer->next;
|
||||
if (next) next->p_prev_next = timer->p_prev_next;
|
||||
if (next)
|
||||
next->p_prev_next = timer->p_prev_next;
|
||||
*timer->p_prev_next = timer->next;
|
||||
}
|
||||
|
||||
static inline struct lua_obs_callback *lua_obs_timer_cb(
|
||||
struct lua_obs_timer *timer)
|
||||
static inline struct lua_obs_callback *
|
||||
lua_obs_timer_cb(struct lua_obs_timer *timer)
|
||||
{
|
||||
return &((struct lua_obs_callback *)timer)[-1];
|
||||
}
|
||||
|
|
@ -273,7 +278,8 @@ static int timer_remove(lua_State *script)
|
|||
return 0;
|
||||
|
||||
struct lua_obs_callback *cb = find_lua_obs_callback(script, 1);
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -304,8 +310,8 @@ static int timer_add(lua_State *script)
|
|||
if (!ms)
|
||||
return 0;
|
||||
|
||||
struct lua_obs_callback *cb = add_lua_obs_callback_extra(script, 1,
|
||||
sizeof(struct lua_obs_timer));
|
||||
struct lua_obs_callback *cb = add_lua_obs_callback_extra(
|
||||
script, 1, sizeof(struct lua_obs_timer));
|
||||
struct lua_obs_timer *timer = lua_obs_callback_extra_data(cb);
|
||||
|
||||
timer->interval = (uint64_t)ms * 1000000ULL;
|
||||
|
|
@ -324,7 +330,7 @@ static void obs_lua_main_render_callback(void *priv, uint32_t cx, uint32_t cy)
|
|||
|
||||
if (cb->base.removed) {
|
||||
obs_remove_main_render_callback(obs_lua_main_render_callback,
|
||||
cb);
|
||||
cb);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +349,8 @@ static int obs_lua_remove_main_render_callback(lua_State *script)
|
|||
return 0;
|
||||
|
||||
struct lua_obs_callback *cb = find_lua_obs_callback(script, 1);
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -388,7 +395,8 @@ static int obs_lua_remove_tick_callback(lua_State *script)
|
|||
return 0;
|
||||
|
||||
struct lua_obs_callback *cb = find_lua_obs_callback(script, 1);
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -447,15 +455,15 @@ static int obs_lua_signal_handler_disconnect(lua_State *script)
|
|||
const char *cb_signal =
|
||||
calldata_string(&cb->base.extra, "signal");
|
||||
|
||||
if (cb_signal &&
|
||||
strcmp(signal, cb_signal) != 0 &&
|
||||
if (cb_signal && strcmp(signal, cb_signal) != 0 &&
|
||||
handler == cb_handler)
|
||||
break;
|
||||
|
||||
cb = find_next_lua_obs_callback(script, cb, 3);
|
||||
}
|
||||
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +473,7 @@ static void defer_connect(void *p_cb)
|
|||
|
||||
signal_handler_t *handler = calldata_ptr(&cb->extra, "handler");
|
||||
const char *signal = calldata_string(&cb->extra, "signal");
|
||||
signal_handler_connect(handler, signal, calldata_signal_callback, cb);
|
||||
signal_handler_connect(handler, signal, calldata_signal_callback, cb);
|
||||
}
|
||||
|
||||
static int obs_lua_signal_handler_connect(lua_State *script)
|
||||
|
|
@ -491,7 +499,7 @@ static int obs_lua_signal_handler_connect(lua_State *script)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static void calldata_signal_callback_global(void *priv, const char *signal,
|
||||
calldata_t *cd)
|
||||
calldata_t *cd)
|
||||
{
|
||||
struct lua_obs_callback *cb = priv;
|
||||
lua_State *script = cb->script;
|
||||
|
|
@ -530,7 +538,8 @@ static int obs_lua_signal_handler_disconnect_global(lua_State *script)
|
|||
cb = find_next_lua_obs_callback(script, cb, 3);
|
||||
}
|
||||
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -539,8 +548,8 @@ static void defer_connect_global(void *p_cb)
|
|||
struct script_callback *cb = p_cb;
|
||||
|
||||
signal_handler_t *handler = calldata_ptr(&cb->extra, "handler");
|
||||
signal_handler_connect_global(handler,
|
||||
calldata_signal_callback_global, cb);
|
||||
signal_handler_connect_global(handler, calldata_signal_callback_global,
|
||||
cb);
|
||||
}
|
||||
|
||||
static int obs_lua_signal_handler_connect_global(lua_State *script)
|
||||
|
|
@ -581,8 +590,11 @@ static int enum_sources(lua_State *script)
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static bool source_enum_filters_proc(obs_source_t *source, obs_source_t *filter, void *param)
|
||||
static void source_enum_filters_proc(obs_source_t *source, obs_source_t *filter,
|
||||
void *param)
|
||||
{
|
||||
UNUSED_PARAMETER(source);
|
||||
|
||||
lua_State *script = param;
|
||||
|
||||
obs_source_get_ref(filter);
|
||||
|
|
@ -590,7 +602,6 @@ static bool source_enum_filters_proc(obs_source_t *source, obs_source_t *filter,
|
|||
|
||||
size_t idx = lua_rawlen(script, -2);
|
||||
lua_rawseti(script, -2, (int)idx + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int source_enum_filters(lua_State *script)
|
||||
|
|
@ -604,11 +615,10 @@ static int source_enum_filters(lua_State *script)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static bool enum_items_proc(obs_scene_t *scene, obs_sceneitem_t *item,
|
||||
void *param)
|
||||
void *param)
|
||||
{
|
||||
lua_State *script = param;
|
||||
|
||||
|
|
@ -644,7 +654,7 @@ static void on_remove_hotkey(void *p_cb)
|
|||
obs_hotkey_id id = (obs_hotkey_id)calldata_int(&cb->base.extra, "id");
|
||||
|
||||
if (id != OBS_INVALID_HOTKEY_ID)
|
||||
defer_call_post(defer_hotkey_unregister, (void*)(uintptr_t)id);
|
||||
defer_call_post(defer_hotkey_unregister, (void *)(uintptr_t)id);
|
||||
}
|
||||
|
||||
static void hotkey_pressed(void *p_cb, bool pressed)
|
||||
|
|
@ -673,8 +683,8 @@ static void defer_hotkey_unpressed(void *p_cb)
|
|||
hotkey_pressed(p_cb, false);
|
||||
}
|
||||
|
||||
static void hotkey_callback(void *p_cb, obs_hotkey_id id,
|
||||
obs_hotkey_t *hotkey, bool pressed)
|
||||
static void hotkey_callback(void *p_cb, obs_hotkey_id id, obs_hotkey_t *hotkey,
|
||||
bool pressed)
|
||||
{
|
||||
struct lua_obs_callback *cb = p_cb;
|
||||
|
||||
|
|
@ -696,7 +706,8 @@ static int hotkey_unregister(lua_State *script)
|
|||
return 0;
|
||||
|
||||
struct lua_obs_callback *cb = find_lua_obs_callback(script, 1);
|
||||
if (cb) remove_lua_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_lua_obs_callback(cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -727,7 +738,7 @@ static int hotkey_register_frontend(lua_State *script)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static bool button_prop_clicked(obs_properties_t *props, obs_property_t *p,
|
||||
void *p_cb)
|
||||
void *p_cb)
|
||||
{
|
||||
struct lua_obs_callback *cb = p_cb;
|
||||
lua_State *script = cb->script;
|
||||
|
|
@ -773,7 +784,7 @@ static int properties_add_button(lua_State *script)
|
|||
|
||||
struct lua_obs_callback *cb = add_lua_obs_callback(script, 4);
|
||||
p = obs_properties_add_button2(props, name, text, button_prop_clicked,
|
||||
cb);
|
||||
cb);
|
||||
|
||||
if (!p || !ls_push_libobs_obj(obs_property_t, p, false))
|
||||
return 0;
|
||||
|
|
@ -783,7 +794,7 @@ static int properties_add_button(lua_State *script)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static bool modified_callback(void *p_cb, obs_properties_t *props,
|
||||
obs_property_t *p, obs_data_t *settings)
|
||||
obs_property_t *p, obs_data_t *settings)
|
||||
{
|
||||
struct lua_obs_callback *cb = p_cb;
|
||||
lua_State *script = cb->script;
|
||||
|
|
@ -976,11 +987,11 @@ static int lua_script_log(lua_State *script)
|
|||
|
||||
static void add_hook_functions(lua_State *script)
|
||||
{
|
||||
#define add_func(name, func) \
|
||||
do { \
|
||||
lua_pushstring(script, name); \
|
||||
#define add_func(name, func) \
|
||||
do { \
|
||||
lua_pushstring(script, name); \
|
||||
lua_pushcfunction(script, func); \
|
||||
lua_rawset(script, -3); \
|
||||
lua_rawset(script, -3); \
|
||||
} while (false)
|
||||
|
||||
lua_getglobal(script, "_G");
|
||||
|
|
@ -1005,31 +1016,24 @@ static void add_hook_functions(lua_State *script)
|
|||
add_func("calldata_source", calldata_source);
|
||||
add_func("calldata_sceneitem", calldata_sceneitem);
|
||||
add_func("obs_add_main_render_callback",
|
||||
obs_lua_add_main_render_callback);
|
||||
obs_lua_add_main_render_callback);
|
||||
add_func("obs_remove_main_render_callback",
|
||||
obs_lua_remove_main_render_callback);
|
||||
add_func("obs_add_tick_callback",
|
||||
obs_lua_add_tick_callback);
|
||||
add_func("obs_remove_tick_callback",
|
||||
obs_lua_remove_tick_callback);
|
||||
add_func("signal_handler_connect",
|
||||
obs_lua_signal_handler_connect);
|
||||
obs_lua_remove_main_render_callback);
|
||||
add_func("obs_add_tick_callback", obs_lua_add_tick_callback);
|
||||
add_func("obs_remove_tick_callback", obs_lua_remove_tick_callback);
|
||||
add_func("signal_handler_connect", obs_lua_signal_handler_connect);
|
||||
add_func("signal_handler_disconnect",
|
||||
obs_lua_signal_handler_disconnect);
|
||||
obs_lua_signal_handler_disconnect);
|
||||
add_func("signal_handler_connect_global",
|
||||
obs_lua_signal_handler_connect_global);
|
||||
obs_lua_signal_handler_connect_global);
|
||||
add_func("signal_handler_disconnect_global",
|
||||
obs_lua_signal_handler_disconnect_global);
|
||||
add_func("obs_hotkey_unregister",
|
||||
hotkey_unregister);
|
||||
add_func("obs_hotkey_register_frontend",
|
||||
hotkey_register_frontend);
|
||||
add_func("obs_properties_add_button",
|
||||
properties_add_button);
|
||||
obs_lua_signal_handler_disconnect_global);
|
||||
add_func("obs_hotkey_unregister", hotkey_unregister);
|
||||
add_func("obs_hotkey_register_frontend", hotkey_register_frontend);
|
||||
add_func("obs_properties_add_button", properties_add_button);
|
||||
add_func("obs_property_set_modified_callback",
|
||||
property_set_modified_callback);
|
||||
add_func("remove_current_callback",
|
||||
remove_current_callback);
|
||||
property_set_modified_callback);
|
||||
add_func("remove_current_callback", remove_current_callback);
|
||||
|
||||
lua_pop(script, 1);
|
||||
#undef add_func
|
||||
|
|
@ -1166,7 +1170,8 @@ void obs_lua_script_unload(obs_script_t *s)
|
|||
pthread_mutex_lock(&tick_mutex);
|
||||
|
||||
struct obs_lua_script *next = data->next_tick;
|
||||
if (next) next->p_prev_next_tick = data->p_prev_next_tick;
|
||||
if (next)
|
||||
next->p_prev_next_tick = data->p_prev_next_tick;
|
||||
*data->p_prev_next_tick = next;
|
||||
|
||||
pthread_mutex_unlock(&tick_mutex);
|
||||
|
|
@ -1258,7 +1263,7 @@ obs_properties_t *obs_lua_script_get_properties(obs_script_t *s)
|
|||
pthread_mutex_lock(&data->mutex);
|
||||
|
||||
call_func_(script, data->get_properties, 0, 1, "script_properties",
|
||||
__FUNCTION__);
|
||||
__FUNCTION__);
|
||||
ls_get_libobs_obj(obs_properties_t, -1, &props);
|
||||
|
||||
pthread_mutex_unlock(&data->mutex);
|
||||
|
|
|
|||
87
deps/obs-scripting/obs-scripting-lua.h
vendored
87
deps/obs-scripting/obs-scripting-lua.h
vendored
|
|
@ -46,12 +46,11 @@
|
|||
#include "obs-scripting-internal.h"
|
||||
#include "obs-scripting-callback.h"
|
||||
|
||||
#define do_log(level, format, ...) \
|
||||
blog(level, "[Lua] " format, ##__VA_ARGS__)
|
||||
#define do_log(level, format, ...) blog(level, "[Lua] " format, ##__VA_ARGS__)
|
||||
|
||||
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
|
|
@ -87,15 +86,15 @@ struct obs_lua_script {
|
|||
bool defined_sources;
|
||||
};
|
||||
|
||||
#define lock_callback() \
|
||||
struct obs_lua_script *__last_script = current_lua_script; \
|
||||
struct lua_obs_callback *__last_callback = current_lua_cb; \
|
||||
current_lua_cb = cb; \
|
||||
#define lock_callback() \
|
||||
struct obs_lua_script *__last_script = current_lua_script; \
|
||||
struct lua_obs_callback *__last_callback = current_lua_cb; \
|
||||
current_lua_cb = cb; \
|
||||
current_lua_script = (struct obs_lua_script *)cb->base.script; \
|
||||
pthread_mutex_lock(¤t_lua_script->mutex);
|
||||
#define unlock_callback() \
|
||||
#define unlock_callback() \
|
||||
pthread_mutex_unlock(¤t_lua_script->mutex); \
|
||||
current_lua_script = __last_script; \
|
||||
current_lua_script = __last_script; \
|
||||
current_lua_cb = __last_callback;
|
||||
|
||||
/* ------------------------------------------------ */
|
||||
|
|
@ -107,16 +106,13 @@ struct lua_obs_callback {
|
|||
int reg_idx;
|
||||
};
|
||||
|
||||
static inline struct lua_obs_callback *add_lua_obs_callback_extra(
|
||||
lua_State *script,
|
||||
int stack_idx,
|
||||
size_t extra_size)
|
||||
static inline struct lua_obs_callback *
|
||||
add_lua_obs_callback_extra(lua_State *script, int stack_idx, size_t extra_size)
|
||||
{
|
||||
struct obs_lua_script *data = current_lua_script;
|
||||
struct lua_obs_callback *cb = add_script_callback(
|
||||
&data->first_callback,
|
||||
(obs_script_t *)data,
|
||||
sizeof(*cb) + extra_size);
|
||||
struct lua_obs_callback *cb =
|
||||
add_script_callback(&data->first_callback, (obs_script_t *)data,
|
||||
sizeof(*cb) + extra_size);
|
||||
|
||||
lua_pushvalue(script, stack_idx);
|
||||
cb->reg_idx = luaL_ref(script, LUA_REGISTRYINDEX);
|
||||
|
|
@ -124,25 +120,26 @@ static inline struct lua_obs_callback *add_lua_obs_callback_extra(
|
|||
return cb;
|
||||
}
|
||||
|
||||
static inline struct lua_obs_callback *add_lua_obs_callback(
|
||||
lua_State *script, int stack_idx)
|
||||
static inline struct lua_obs_callback *add_lua_obs_callback(lua_State *script,
|
||||
int stack_idx)
|
||||
{
|
||||
return add_lua_obs_callback_extra(script, stack_idx, 0);
|
||||
}
|
||||
|
||||
static inline void *lua_obs_callback_extra_data(struct lua_obs_callback *cb)
|
||||
{
|
||||
return (void*)&cb[1];
|
||||
return (void *)&cb[1];
|
||||
}
|
||||
|
||||
static inline struct obs_lua_script *lua_obs_callback_script(
|
||||
struct lua_obs_callback *cb)
|
||||
static inline struct obs_lua_script *
|
||||
lua_obs_callback_script(struct lua_obs_callback *cb)
|
||||
{
|
||||
return (struct obs_lua_script *)cb->base.script;
|
||||
}
|
||||
|
||||
static inline struct lua_obs_callback *find_next_lua_obs_callback(
|
||||
lua_State *script, struct lua_obs_callback *cb, int stack_idx)
|
||||
static inline struct lua_obs_callback *
|
||||
find_next_lua_obs_callback(lua_State *script, struct lua_obs_callback *cb,
|
||||
int stack_idx)
|
||||
{
|
||||
struct obs_lua_script *data = current_lua_script;
|
||||
|
||||
|
|
@ -163,8 +160,8 @@ static inline struct lua_obs_callback *find_next_lua_obs_callback(
|
|||
return cb;
|
||||
}
|
||||
|
||||
static inline struct lua_obs_callback *find_lua_obs_callback(
|
||||
lua_State *script, int stack_idx)
|
||||
static inline struct lua_obs_callback *find_lua_obs_callback(lua_State *script,
|
||||
int stack_idx)
|
||||
{
|
||||
return find_next_lua_obs_callback(script, NULL, stack_idx);
|
||||
}
|
||||
|
|
@ -204,9 +201,8 @@ static int is_function(lua_State *script, int idx)
|
|||
|
||||
typedef int (*param_cb)(lua_State *script, int idx);
|
||||
|
||||
static inline bool verify_args1_(lua_State *script,
|
||||
param_cb param1_check,
|
||||
const char *func)
|
||||
static inline bool verify_args1_(lua_State *script, param_cb param1_check,
|
||||
const char *func)
|
||||
{
|
||||
if (lua_gettop(script) != 1) {
|
||||
warn("Wrong number of parameters for %s", func);
|
||||
|
|
@ -223,9 +219,9 @@ static inline bool verify_args1_(lua_State *script,
|
|||
#define verify_args1(script, param1_check) \
|
||||
verify_args1_(script, param1_check, __FUNCTION__)
|
||||
|
||||
static inline bool call_func_(lua_State *script,
|
||||
int reg_idx, int args, int rets,
|
||||
const char *func, const char *display_name)
|
||||
static inline bool call_func_(lua_State *script, int reg_idx, int args,
|
||||
int rets, const char *func,
|
||||
const char *display_name)
|
||||
{
|
||||
if (reg_idx == LUA_REFNIL)
|
||||
return false;
|
||||
|
|
@ -237,8 +233,7 @@ static inline bool call_func_(lua_State *script,
|
|||
|
||||
if (lua_pcall(script, args, rets, 0) != 0) {
|
||||
script_warn(&data->base, "Failed to call %s for %s: %s", func,
|
||||
display_name,
|
||||
lua_tostring(script, -1));
|
||||
display_name, lua_tostring(script, -1));
|
||||
lua_pop(script, 1);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -246,19 +241,11 @@ static inline bool call_func_(lua_State *script,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ls_get_libobs_obj_(lua_State * script,
|
||||
const char *type,
|
||||
int lua_idx,
|
||||
void * libobs_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line);
|
||||
bool ls_push_libobs_obj_(lua_State * script,
|
||||
const char *type,
|
||||
void * libobs_in,
|
||||
bool ownership,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line);
|
||||
bool ls_get_libobs_obj_(lua_State *script, const char *type, int lua_idx,
|
||||
void *libobs_out, const char *id, const char *func,
|
||||
int line);
|
||||
bool ls_push_libobs_obj_(lua_State *script, const char *type, void *libobs_in,
|
||||
bool ownership, const char *id, const char *func,
|
||||
int line);
|
||||
|
||||
extern void add_lua_source_functions(lua_State *script);
|
||||
|
|
|
|||
|
|
@ -20,12 +20,11 @@
|
|||
|
||||
#include "obs-scripting-python.h"
|
||||
|
||||
#define libobs_to_py(type, obs_obj, ownership, py_obj) \
|
||||
libobs_to_py_(#type " *", obs_obj, ownership, py_obj, \
|
||||
NULL, __func__, __LINE__)
|
||||
#define libobs_to_py(type, obs_obj, ownership, py_obj) \
|
||||
libobs_to_py_(#type " *", obs_obj, ownership, py_obj, NULL, __func__, \
|
||||
__LINE__)
|
||||
#define py_to_libobs(type, py_obj, libobs_out) \
|
||||
py_to_libobs_(#type " *", py_obj, libobs_out, \
|
||||
NULL, __func__, __LINE__)
|
||||
py_to_libobs_(#type " *", py_obj, libobs_out, NULL, __func__, __LINE__)
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
|
|
@ -257,7 +256,7 @@ static PyObject *set_current_profile(PyObject *self, PyObject *args)
|
|||
/* ----------------------------------- */
|
||||
|
||||
static void frontend_save_callback(obs_data_t *save_data, bool saving,
|
||||
void *priv)
|
||||
void *priv)
|
||||
{
|
||||
struct python_obs_callback *cb = priv;
|
||||
|
||||
|
|
@ -303,8 +302,10 @@ static PyObject *remove_save_callback(PyObject *self, PyObject *args)
|
|||
if (!py_cb || !PyFunction_Check(py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
|
|
@ -354,8 +355,7 @@ void add_python_frontend_funcs(PyObject *module)
|
|||
DEF_FUNC(add_save_callback),
|
||||
|
||||
#undef DEF_FUNC
|
||||
{0}
|
||||
};
|
||||
{0}};
|
||||
|
||||
add_functions_to_py_module(module, funcs);
|
||||
}
|
||||
|
|
|
|||
16
deps/obs-scripting/obs-scripting-python-import.c
vendored
16
deps/obs-scripting/obs-scripting-python-import.c
vendored
|
|
@ -51,18 +51,18 @@ bool import_python(const char *python_path)
|
|||
lib = os_dlopen(lib_path.array);
|
||||
if (!lib) {
|
||||
blog(LOG_WARNING, "[Python] Could not load library: %s",
|
||||
lib_path.array);
|
||||
lib_path.array);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#define IMPORT_FUNC(x) \
|
||||
do { \
|
||||
Import_##x = os_dlsym(lib, #x); \
|
||||
if (!Import_##x) { \
|
||||
#define IMPORT_FUNC(x) \
|
||||
do { \
|
||||
Import_##x = os_dlsym(lib, #x); \
|
||||
if (!Import_##x) { \
|
||||
blog(LOG_WARNING, "[Python] Failed to import: %s", \
|
||||
#x); \
|
||||
goto fail; \
|
||||
} \
|
||||
#x); \
|
||||
goto fail; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
IMPORT_FUNC(PyType_Ready);
|
||||
|
|
|
|||
201
deps/obs-scripting/obs-scripting-python-import.h
vendored
201
deps/obs-scripting/obs-scripting-python-import.h
vendored
|
|
@ -32,11 +32,11 @@
|
|||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(_DEBUG)
|
||||
# undef _DEBUG
|
||||
# include <Python.h>
|
||||
# define _DEBUG
|
||||
#undef _DEBUG
|
||||
#include <Python.h>
|
||||
#define _DEBUG
|
||||
#else
|
||||
# include <Python.h>
|
||||
#include <Python.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
@ -64,14 +64,17 @@ PY_EXTERN PyObject *(*Import_PyLong_FromVoidPtr)(void *);
|
|||
PY_EXTERN PyObject *(*Import_PyBool_FromLong)(long);
|
||||
PY_EXTERN PyGILState_STATE (*Import_PyGILState_Ensure)(void);
|
||||
PY_EXTERN PyThreadState *(*Import_PyGILState_GetThisThreadState)(void);
|
||||
PY_EXTERN void (*Import_PyErr_SetString)(PyObject *exception, const char *string);
|
||||
PY_EXTERN void (*Import_PyErr_SetString)(PyObject *exception,
|
||||
const char *string);
|
||||
PY_EXTERN PyObject *(*Import_PyErr_Occurred)(void);
|
||||
PY_EXTERN void (*Import_PyErr_Fetch)(PyObject **, PyObject **, PyObject **);
|
||||
PY_EXTERN void (*Import_PyErr_Restore)(PyObject *, PyObject *, PyObject *);
|
||||
PY_EXTERN void (*Import_PyErr_WriteUnraisable)(PyObject *);
|
||||
PY_EXTERN int (*Import_PyArg_UnpackTuple)(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
||||
PY_EXTERN int (*Import_PyArg_UnpackTuple)(PyObject *, const char *, Py_ssize_t,
|
||||
Py_ssize_t, ...);
|
||||
PY_EXTERN PyObject *(*Import_Py_BuildValue)(const char *, ...);
|
||||
PY_EXTERN int (*Import_PyRun_SimpleStringFlags)(const char *, PyCompilerFlags *);
|
||||
PY_EXTERN int (*Import_PyRun_SimpleStringFlags)(const char *,
|
||||
PyCompilerFlags *);
|
||||
PY_EXTERN void (*Import_PyErr_Print)(void);
|
||||
PY_EXTERN void (*Import_Py_SetPythonHome)(wchar_t *);
|
||||
PY_EXTERN void (*Import_Py_Initialize)(void);
|
||||
|
|
@ -82,117 +85,127 @@ PY_EXTERN int (*Import_PyEval_ThreadsInitialized)(void);
|
|||
PY_EXTERN void (*Import_PyEval_ReleaseThread)(PyThreadState *tstate);
|
||||
PY_EXTERN void (*Import_PySys_SetArgv)(int, wchar_t **);
|
||||
PY_EXTERN PyObject *(*Import_PyImport_ImportModule)(const char *name);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_CallFunctionObjArgs)(PyObject *callable, ...);
|
||||
PY_EXTERN PyObject (*Import__Py_NotImplementedStruct);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_CallFunctionObjArgs)(PyObject *callable,
|
||||
...);
|
||||
PY_EXTERN PyObject(*Import__Py_NotImplementedStruct);
|
||||
PY_EXTERN PyObject *(*Import_PyExc_TypeError);
|
||||
PY_EXTERN PyObject *(*Import_PyExc_RuntimeError);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_GetAttr)(PyObject *, PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PyUnicode_FromString)(const char *u);
|
||||
PY_EXTERN PyObject *(*Import_PyDict_GetItemString)(PyObject *dp, const char *key);
|
||||
PY_EXTERN int (*Import_PyDict_SetItemString)(PyObject *dp, const char *key, PyObject *item);
|
||||
PY_EXTERN PyObject *(*Import_PyCFunction_NewEx)(PyMethodDef *, PyObject *, PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PyDict_GetItemString)(PyObject *dp,
|
||||
const char *key);
|
||||
PY_EXTERN int (*Import_PyDict_SetItemString)(PyObject *dp, const char *key,
|
||||
PyObject *item);
|
||||
PY_EXTERN PyObject *(*Import_PyCFunction_NewEx)(PyMethodDef *, PyObject *,
|
||||
PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PyModule_GetDict)(PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PyModule_GetNameObject)(PyObject *);
|
||||
PY_EXTERN int (*Import_PyModule_AddObject)(PyObject *, const char *, PyObject *);
|
||||
PY_EXTERN int (*Import_PyModule_AddStringConstant)(PyObject *, const char *, const char *);
|
||||
PY_EXTERN int (*Import_PyModule_AddObject)(PyObject *, const char *,
|
||||
PyObject *);
|
||||
PY_EXTERN int (*Import_PyModule_AddStringConstant)(PyObject *, const char *,
|
||||
const char *);
|
||||
PY_EXTERN PyObject *(*Import_PyImport_Import)(PyObject *name);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_CallObject)(PyObject *callable_object, PyObject *args);
|
||||
PY_EXTERN struct _longobject (*Import__Py_FalseStruct);
|
||||
PY_EXTERN struct _longobject (*Import__Py_TrueStruct);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_CallObject)(PyObject *callable_object,
|
||||
PyObject *args);
|
||||
PY_EXTERN struct _longobject(*Import__Py_FalseStruct);
|
||||
PY_EXTERN struct _longobject(*Import__Py_TrueStruct);
|
||||
PY_EXTERN void (*Import_PyGILState_Release)(PyGILState_STATE);
|
||||
PY_EXTERN int (*Import_PyList_Append)(PyObject *, PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PySys_GetObject)(const char *);
|
||||
PY_EXTERN PyObject *(*Import_PyImport_ReloadModule)(PyObject *m);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_GetAttrString)(PyObject *, const char *);
|
||||
PY_EXTERN PyObject *(*Import_PyCapsule_New)(void *pointer, const char *name, PyCapsule_Destructor destructor);
|
||||
PY_EXTERN void *(*Import_PyCapsule_GetPointer)(PyObject *capsule, const char *name);
|
||||
PY_EXTERN PyObject *(*Import_PyCapsule_New)(void *pointer, const char *name,
|
||||
PyCapsule_Destructor destructor);
|
||||
PY_EXTERN void *(*Import_PyCapsule_GetPointer)(PyObject *capsule,
|
||||
const char *name);
|
||||
PY_EXTERN int (*Import_PyArg_ParseTuple)(PyObject *, const char *, ...);
|
||||
PY_EXTERN PyTypeObject (*Import_PyFunction_Type);
|
||||
PY_EXTERN PyTypeObject(*Import_PyFunction_Type);
|
||||
PY_EXTERN int (*Import_PyObject_SetAttr)(PyObject *, PyObject *, PyObject *);
|
||||
PY_EXTERN PyObject *(*Import__PyObject_New)(PyTypeObject *);
|
||||
PY_EXTERN void *(*Import_PyCapsule_Import)(const char *name, int no_block);
|
||||
PY_EXTERN void *(*Import_PyCapsule_Import)(const char *name, int no_block);
|
||||
PY_EXTERN void (*Import_PyErr_Clear)(void);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_Call)(PyObject *callable_object, PyObject *args, PyObject *kwargs);
|
||||
PY_EXTERN PyObject *(*Import_PyObject_Call)(PyObject *callable_object,
|
||||
PyObject *args, PyObject *kwargs);
|
||||
PY_EXTERN PyObject *(*Import_PyList_New)(Py_ssize_t size);
|
||||
PY_EXTERN Py_ssize_t (*Import_PyList_Size)(PyObject *);
|
||||
PY_EXTERN PyObject *(*Import_PyList_GetItem)(PyObject *, Py_ssize_t);
|
||||
PY_EXTERN PyObject *(*Import_PyUnicode_AsUTF8String)(PyObject *unicode);
|
||||
PY_EXTERN PyObject *(*Import_PyLong_FromUnsignedLongLong)(unsigned long long);
|
||||
PY_EXTERN int (*Import_PyArg_VaParse)(PyObject *, const char *, va_list);
|
||||
PY_EXTERN PyObject (*Import__Py_NoneStruct);
|
||||
PY_EXTERN PyObject(*Import__Py_NoneStruct);
|
||||
|
||||
extern bool import_python(const char *python_path);
|
||||
|
||||
# ifndef NO_REDEFS
|
||||
# define PyType_Ready Import_PyType_Ready
|
||||
# define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
|
||||
# define PyObject_IsTrue Import_PyObject_IsTrue
|
||||
# define Py_DecRef Import_Py_DecRef
|
||||
# define PyObject_Malloc Import_PyObject_Malloc
|
||||
# define PyObject_Free Import_PyObject_Free
|
||||
# define PyObject_Init Import_PyObject_Init
|
||||
# define PyUnicode_FromFormat Import_PyUnicode_FromFormat
|
||||
# define PyUnicode_Concat Import_PyUnicode_Concat
|
||||
# define PyLong_FromVoidPtr Import_PyLong_FromVoidPtr
|
||||
# define PyBool_FromLong Import_PyBool_FromLong
|
||||
# define PyGILState_Ensure Import_PyGILState_Ensure
|
||||
# define PyGILState_GetThisThreadState Import_PyGILState_GetThisThreadState
|
||||
# define PyErr_SetString Import_PyErr_SetString
|
||||
# define PyErr_Occurred Import_PyErr_Occurred
|
||||
# define PyErr_Fetch Import_PyErr_Fetch
|
||||
# define PyErr_Restore Import_PyErr_Restore
|
||||
# define PyErr_WriteUnraisable Import_PyErr_WriteUnraisable
|
||||
# define PyArg_UnpackTuple Import_PyArg_UnpackTuple
|
||||
# define Py_BuildValue Import_Py_BuildValue
|
||||
# define PyRun_SimpleStringFlags Import_PyRun_SimpleStringFlags
|
||||
# define PyErr_Print Import_PyErr_Print
|
||||
# define Py_SetPythonHome Import_Py_SetPythonHome
|
||||
# define Py_Initialize Import_Py_Initialize
|
||||
# define Py_Finalize Import_Py_Finalize
|
||||
# define Py_IsInitialized Import_Py_IsInitialized
|
||||
# define PyEval_InitThreads Import_PyEval_InitThreads
|
||||
# define PyEval_ThreadsInitialized Import_PyEval_ThreadsInitialized
|
||||
# define PyEval_ReleaseThread Import_PyEval_ReleaseThread
|
||||
# define PySys_SetArgv Import_PySys_SetArgv
|
||||
# define PyImport_ImportModule Import_PyImport_ImportModule
|
||||
# define PyObject_CallFunctionObjArgs Import_PyObject_CallFunctionObjArgs
|
||||
# define _Py_NotImplementedStruct (*Import__Py_NotImplementedStruct)
|
||||
# define PyExc_TypeError (*Import_PyExc_TypeError)
|
||||
# define PyExc_RuntimeError (*Import_PyExc_RuntimeError)
|
||||
# define PyObject_GetAttr Import_PyObject_GetAttr
|
||||
# define PyUnicode_FromString Import_PyUnicode_FromString
|
||||
# define PyDict_GetItemString Import_PyDict_GetItemString
|
||||
# define PyDict_SetItemString Import_PyDict_SetItemString
|
||||
# define PyCFunction_NewEx Import_PyCFunction_NewEx
|
||||
# define PyModule_GetDict Import_PyModule_GetDict
|
||||
# define PyModule_GetNameObject Import_PyModule_GetNameObject
|
||||
# define PyModule_AddObject Import_PyModule_AddObject
|
||||
# define PyModule_AddStringConstant Import_PyModule_AddStringConstant
|
||||
# define PyImport_Import Import_PyImport_Import
|
||||
# define PyObject_CallObject Import_PyObject_CallObject
|
||||
# define _Py_FalseStruct (*Import__Py_FalseStruct)
|
||||
# define _Py_TrueStruct (*Import__Py_TrueStruct)
|
||||
# define PyGILState_Release Import_PyGILState_Release
|
||||
# define PyList_Append Import_PyList_Append
|
||||
# define PySys_GetObject Import_PySys_GetObject
|
||||
# define PyImport_ReloadModule Import_PyImport_ReloadModule
|
||||
# define PyObject_GetAttrString Import_PyObject_GetAttrString
|
||||
# define PyCapsule_New Import_PyCapsule_New
|
||||
# define PyCapsule_GetPointer Import_PyCapsule_GetPointer
|
||||
# define PyArg_ParseTuple Import_PyArg_ParseTuple
|
||||
# define PyFunction_Type (*Import_PyFunction_Type)
|
||||
# define PyObject_SetAttr Import_PyObject_SetAttr
|
||||
# define _PyObject_New Import__PyObject_New
|
||||
# define PyCapsule_Import Import_PyCapsule_Import
|
||||
# define PyErr_Clear Import_PyErr_Clear
|
||||
# define PyObject_Call Import_PyObject_Call
|
||||
# define PyList_New Import_PyList_New
|
||||
# define PyList_Size Import_PyList_Size
|
||||
# define PyList_GetItem Import_PyList_GetItem
|
||||
# define PyUnicode_AsUTF8String Import_PyUnicode_AsUTF8String
|
||||
# define PyLong_FromUnsignedLongLong Import_PyLong_FromUnsignedLongLong
|
||||
# define PyArg_VaParse Import_PyArg_VaParse
|
||||
# define _Py_NoneStruct (*Import__Py_NoneStruct)
|
||||
# endif
|
||||
#ifndef NO_REDEFS
|
||||
#define PyType_Ready Import_PyType_Ready
|
||||
#define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
|
||||
#define PyObject_IsTrue Import_PyObject_IsTrue
|
||||
#define Py_DecRef Import_Py_DecRef
|
||||
#define PyObject_Malloc Import_PyObject_Malloc
|
||||
#define PyObject_Free Import_PyObject_Free
|
||||
#define PyObject_Init Import_PyObject_Init
|
||||
#define PyUnicode_FromFormat Import_PyUnicode_FromFormat
|
||||
#define PyUnicode_Concat Import_PyUnicode_Concat
|
||||
#define PyLong_FromVoidPtr Import_PyLong_FromVoidPtr
|
||||
#define PyBool_FromLong Import_PyBool_FromLong
|
||||
#define PyGILState_Ensure Import_PyGILState_Ensure
|
||||
#define PyGILState_GetThisThreadState Import_PyGILState_GetThisThreadState
|
||||
#define PyErr_SetString Import_PyErr_SetString
|
||||
#define PyErr_Occurred Import_PyErr_Occurred
|
||||
#define PyErr_Fetch Import_PyErr_Fetch
|
||||
#define PyErr_Restore Import_PyErr_Restore
|
||||
#define PyErr_WriteUnraisable Import_PyErr_WriteUnraisable
|
||||
#define PyArg_UnpackTuple Import_PyArg_UnpackTuple
|
||||
#define Py_BuildValue Import_Py_BuildValue
|
||||
#define PyRun_SimpleStringFlags Import_PyRun_SimpleStringFlags
|
||||
#define PyErr_Print Import_PyErr_Print
|
||||
#define Py_SetPythonHome Import_Py_SetPythonHome
|
||||
#define Py_Initialize Import_Py_Initialize
|
||||
#define Py_Finalize Import_Py_Finalize
|
||||
#define Py_IsInitialized Import_Py_IsInitialized
|
||||
#define PyEval_InitThreads Import_PyEval_InitThreads
|
||||
#define PyEval_ThreadsInitialized Import_PyEval_ThreadsInitialized
|
||||
#define PyEval_ReleaseThread Import_PyEval_ReleaseThread
|
||||
#define PySys_SetArgv Import_PySys_SetArgv
|
||||
#define PyImport_ImportModule Import_PyImport_ImportModule
|
||||
#define PyObject_CallFunctionObjArgs Import_PyObject_CallFunctionObjArgs
|
||||
#define _Py_NotImplementedStruct (*Import__Py_NotImplementedStruct)
|
||||
#define PyExc_TypeError (*Import_PyExc_TypeError)
|
||||
#define PyExc_RuntimeError (*Import_PyExc_RuntimeError)
|
||||
#define PyObject_GetAttr Import_PyObject_GetAttr
|
||||
#define PyUnicode_FromString Import_PyUnicode_FromString
|
||||
#define PyDict_GetItemString Import_PyDict_GetItemString
|
||||
#define PyDict_SetItemString Import_PyDict_SetItemString
|
||||
#define PyCFunction_NewEx Import_PyCFunction_NewEx
|
||||
#define PyModule_GetDict Import_PyModule_GetDict
|
||||
#define PyModule_GetNameObject Import_PyModule_GetNameObject
|
||||
#define PyModule_AddObject Import_PyModule_AddObject
|
||||
#define PyModule_AddStringConstant Import_PyModule_AddStringConstant
|
||||
#define PyImport_Import Import_PyImport_Import
|
||||
#define PyObject_CallObject Import_PyObject_CallObject
|
||||
#define _Py_FalseStruct (*Import__Py_FalseStruct)
|
||||
#define _Py_TrueStruct (*Import__Py_TrueStruct)
|
||||
#define PyGILState_Release Import_PyGILState_Release
|
||||
#define PyList_Append Import_PyList_Append
|
||||
#define PySys_GetObject Import_PySys_GetObject
|
||||
#define PyImport_ReloadModule Import_PyImport_ReloadModule
|
||||
#define PyObject_GetAttrString Import_PyObject_GetAttrString
|
||||
#define PyCapsule_New Import_PyCapsule_New
|
||||
#define PyCapsule_GetPointer Import_PyCapsule_GetPointer
|
||||
#define PyArg_ParseTuple Import_PyArg_ParseTuple
|
||||
#define PyFunction_Type (*Import_PyFunction_Type)
|
||||
#define PyObject_SetAttr Import_PyObject_SetAttr
|
||||
#define _PyObject_New Import__PyObject_New
|
||||
#define PyCapsule_Import Import_PyCapsule_Import
|
||||
#define PyErr_Clear Import_PyErr_Clear
|
||||
#define PyObject_Call Import_PyObject_Call
|
||||
#define PyList_New Import_PyList_New
|
||||
#define PyList_Size Import_PyList_Size
|
||||
#define PyList_GetItem Import_PyList_GetItem
|
||||
#define PyUnicode_AsUTF8String Import_PyUnicode_AsUTF8String
|
||||
#define PyLong_FromUnsignedLongLong Import_PyLong_FromUnsignedLongLong
|
||||
#define PyArg_VaParse Import_PyArg_VaParse
|
||||
#define _Py_NoneStruct (*Import__Py_NoneStruct)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
266
deps/obs-scripting/obs-scripting-python.c
vendored
266
deps/obs-scripting/obs-scripting-python.c
vendored
|
|
@ -51,7 +51,7 @@ sys.stderr = stderr_logger()\n";
|
|||
static wchar_t home_path[1024] = {0};
|
||||
#endif
|
||||
|
||||
DARRAY(char*) python_paths;
|
||||
DARRAY(char *) python_paths;
|
||||
static bool python_loaded = false;
|
||||
|
||||
static pthread_mutex_t tick_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
|
@ -63,21 +63,13 @@ struct python_obs_callback *cur_python_cb = NULL;
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
bool py_to_libobs_(const char *type,
|
||||
PyObject * py_in,
|
||||
void * libobs_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line)
|
||||
bool py_to_libobs_(const char *type, PyObject *py_in, void *libobs_out,
|
||||
const char *id, const char *func, int line)
|
||||
{
|
||||
swig_type_info *info = SWIG_TypeQuery(type);
|
||||
if (info == NULL) {
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s", func, line,
|
||||
id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -85,33 +77,21 @@ bool py_to_libobs_(const char *type,
|
|||
if (!SWIG_IsOK(ret)) {
|
||||
warn("%s:%d: SWIG failed to convert python object to obs "
|
||||
"object: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
func, line, id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool libobs_to_py_(const char *type,
|
||||
void * libobs_in,
|
||||
bool ownership,
|
||||
PyObject ** py_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line)
|
||||
bool libobs_to_py_(const char *type, void *libobs_in, bool ownership,
|
||||
PyObject **py_out, const char *id, const char *func,
|
||||
int line)
|
||||
{
|
||||
swig_type_info *info = SWIG_TypeQuery(type);
|
||||
if (info == NULL) {
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
warn("%s:%d: SWIG could not find type: %s%s%s", func, line,
|
||||
id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -119,33 +99,27 @@ bool libobs_to_py_(const char *type,
|
|||
if (*py_out == Py_None) {
|
||||
warn("%s:%d: SWIG failed to convert obs object to python "
|
||||
"object: %s%s%s",
|
||||
func,
|
||||
line,
|
||||
id ? id : "",
|
||||
id ? "::" : "",
|
||||
type);
|
||||
func, line, id ? id : "", id ? "::" : "", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define libobs_to_py(type, obs_obj, ownership, py_obj) \
|
||||
libobs_to_py_(#type " *", obs_obj, ownership, py_obj, \
|
||||
NULL, __func__, __LINE__)
|
||||
#define libobs_to_py(type, obs_obj, ownership, py_obj) \
|
||||
libobs_to_py_(#type " *", obs_obj, ownership, py_obj, NULL, __func__, \
|
||||
__LINE__)
|
||||
#define py_to_libobs(type, py_obj, libobs_out) \
|
||||
py_to_libobs_(#type " *", py_obj, libobs_out, \
|
||||
NULL, __func__, __LINE__)
|
||||
py_to_libobs_(#type " *", py_obj, libobs_out, NULL, __func__, __LINE__)
|
||||
|
||||
#define lock_callback(cb) \
|
||||
lock_python(); \
|
||||
struct obs_python_script *__last_script = cur_python_script; \
|
||||
struct python_obs_callback *__last_cb = cur_python_cb; \
|
||||
#define lock_callback(cb) \
|
||||
lock_python(); \
|
||||
struct obs_python_script *__last_script = cur_python_script; \
|
||||
struct python_obs_callback *__last_cb = cur_python_cb; \
|
||||
cur_python_script = (struct obs_python_script *)cb->base.script; \
|
||||
cur_python_cb = cb
|
||||
#define unlock_callback() \
|
||||
cur_python_cb = __last_cb; \
|
||||
#define unlock_callback() \
|
||||
cur_python_cb = __last_cb; \
|
||||
cur_python_script = __last_script; \
|
||||
unlock_python()
|
||||
|
||||
|
|
@ -174,8 +148,7 @@ void add_functions_to_py_module(PyObject *module, PyMethodDef *method_list)
|
|||
static PyObject *py_get_current_script_path(PyObject *self, PyObject *args)
|
||||
{
|
||||
UNUSED_PARAMETER(args);
|
||||
return PyDict_GetItemString(PyModule_GetDict(self),
|
||||
"__script_dir__");
|
||||
return PyDict_GetItemString(PyModule_GetDict(self), "__script_dir__");
|
||||
}
|
||||
|
||||
static void get_defaults(struct obs_python_script *data, PyObject *get_defs)
|
||||
|
|
@ -194,19 +167,19 @@ static void get_defaults(struct obs_python_script *data, PyObject *get_defs)
|
|||
|
||||
static bool load_python_script(struct obs_python_script *data)
|
||||
{
|
||||
PyObject *py_file = NULL;
|
||||
PyObject *py_module = NULL;
|
||||
PyObject *py_success = NULL;
|
||||
PyObject *py_tick = NULL;
|
||||
PyObject *py_load = NULL;
|
||||
PyObject *py_file = NULL;
|
||||
PyObject *py_module = NULL;
|
||||
PyObject *py_success = NULL;
|
||||
PyObject *py_tick = NULL;
|
||||
PyObject *py_load = NULL;
|
||||
PyObject *py_defaults = NULL;
|
||||
bool success = false;
|
||||
int ret;
|
||||
bool success = false;
|
||||
int ret;
|
||||
|
||||
cur_python_script = data;
|
||||
|
||||
if (!data->module) {
|
||||
py_file = PyUnicode_FromString(data->name.array);
|
||||
py_file = PyUnicode_FromString(data->name.array);
|
||||
py_module = PyImport_Import(py_file);
|
||||
} else {
|
||||
py_module = PyImport_ReloadModule(data->module);
|
||||
|
|
@ -223,7 +196,7 @@ static bool load_python_script(struct obs_python_script *data)
|
|||
goto fail;
|
||||
|
||||
ret = PyModule_AddStringConstant(py_module, "__script_dir__",
|
||||
data->dir.array);
|
||||
data->dir.array);
|
||||
if (py_error() || ret != 0)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -233,12 +206,9 @@ static bool load_python_script(struct obs_python_script *data)
|
|||
goto fail;
|
||||
|
||||
static PyMethodDef global_funcs[] = {
|
||||
{"script_path",
|
||||
py_get_current_script_path,
|
||||
METH_NOARGS,
|
||||
{"script_path", py_get_current_script_path, METH_NOARGS,
|
||||
"Gets the script path"},
|
||||
{0}
|
||||
};
|
||||
{0}};
|
||||
|
||||
add_functions_to_py_module(py_module, global_funcs);
|
||||
|
||||
|
|
@ -250,8 +220,8 @@ static bool load_python_script(struct obs_python_script *data)
|
|||
if (!data->save)
|
||||
PyErr_Clear();
|
||||
|
||||
data->get_properties = PyObject_GetAttrString(py_module,
|
||||
"script_properties");
|
||||
data->get_properties =
|
||||
PyObject_GetAttrString(py_module, "script_properties");
|
||||
if (!data->get_properties)
|
||||
PyErr_Clear();
|
||||
|
||||
|
|
@ -270,7 +240,8 @@ static bool load_python_script(struct obs_python_script *data)
|
|||
PyObject *py_desc = PyUnicode_AsUTF8String(py_ret);
|
||||
if (py_desc) {
|
||||
const char *desc = PyBytes_AS_STRING(py_desc);
|
||||
if (desc) dstr_copy(&data->base.desc, desc);
|
||||
if (desc)
|
||||
dstr_copy(&data->base.desc, desc);
|
||||
Py_DECREF(py_desc);
|
||||
}
|
||||
Py_XDECREF(py_ret);
|
||||
|
|
@ -286,7 +257,8 @@ static bool load_python_script(struct obs_python_script *data)
|
|||
struct obs_python_script *next = first_tick_script;
|
||||
data->next_tick = next;
|
||||
data->p_prev_next_tick = &first_tick_script;
|
||||
if (next) next->p_prev_next_tick = &data->next_tick;
|
||||
if (next)
|
||||
next->p_prev_next_tick = &data->next_tick;
|
||||
first_tick_script = data;
|
||||
|
||||
data->tick = py_tick;
|
||||
|
|
@ -332,9 +304,9 @@ fail:
|
|||
|
||||
static void unload_python_script(struct obs_python_script *data)
|
||||
{
|
||||
PyObject *py_module = data->module;
|
||||
PyObject *py_func = NULL;
|
||||
PyObject *py_ret = NULL;
|
||||
PyObject *py_module = data->module;
|
||||
PyObject *py_func = NULL;
|
||||
PyObject *py_ret = NULL;
|
||||
|
||||
cur_python_script = data;
|
||||
|
||||
|
|
@ -358,8 +330,8 @@ fail:
|
|||
static void add_to_python_path(const char *path)
|
||||
{
|
||||
PyObject *py_path_str = NULL;
|
||||
PyObject *py_path = NULL;
|
||||
int ret;
|
||||
PyObject *py_path = NULL;
|
||||
int ret;
|
||||
|
||||
if (!path || !*path)
|
||||
return;
|
||||
|
|
@ -411,7 +383,8 @@ static inline void python_obs_timer_init(struct python_obs_timer *timer)
|
|||
struct python_obs_timer *next = first_timer;
|
||||
timer->next = next;
|
||||
timer->p_prev_next = &first_timer;
|
||||
if (next) next->p_prev_next = &timer->next;
|
||||
if (next)
|
||||
next->p_prev_next = &timer->next;
|
||||
first_timer = timer;
|
||||
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
|
|
@ -420,12 +393,13 @@ static inline void python_obs_timer_init(struct python_obs_timer *timer)
|
|||
static inline void python_obs_timer_remove(struct python_obs_timer *timer)
|
||||
{
|
||||
struct python_obs_timer *next = timer->next;
|
||||
if (next) next->p_prev_next = timer->p_prev_next;
|
||||
if (next)
|
||||
next->p_prev_next = timer->p_prev_next;
|
||||
*timer->p_prev_next = timer->next;
|
||||
}
|
||||
|
||||
static inline struct python_obs_callback *python_obs_timer_cb(
|
||||
struct python_obs_timer *timer)
|
||||
static inline struct python_obs_callback *
|
||||
python_obs_timer_cb(struct python_obs_timer *timer)
|
||||
{
|
||||
return &((struct python_obs_callback *)timer)[-1];
|
||||
}
|
||||
|
|
@ -440,8 +414,10 @@ static PyObject *timer_remove(PyObject *self, PyObject *args)
|
|||
if (!parse_args(args, "O", &py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +454,7 @@ static PyObject *timer_add(PyObject *self, PyObject *args)
|
|||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = add_python_obs_callback_extra(
|
||||
script, py_cb, sizeof(struct python_obs_timer));
|
||||
script, py_cb, sizeof(struct python_obs_timer));
|
||||
struct python_obs_timer *timer = python_obs_callback_extra_data(cb);
|
||||
|
||||
timer->interval = (uint64_t)ms * 1000000ULL;
|
||||
|
|
@ -528,8 +504,10 @@ static PyObject *obs_python_remove_tick_callback(PyObject *self, PyObject *args)
|
|||
if (!py_cb || !PyFunction_Check(py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
|
|
@ -583,8 +561,8 @@ static void calldata_signal_callback(void *priv, calldata_t *cd)
|
|||
unlock_callback();
|
||||
}
|
||||
|
||||
static PyObject *obs_python_signal_handler_disconnect(
|
||||
PyObject *self, PyObject *args)
|
||||
static PyObject *obs_python_signal_handler_disconnect(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
struct obs_python_script *script = cur_python_script;
|
||||
PyObject *py_sh = NULL;
|
||||
|
|
@ -609,27 +587,28 @@ static PyObject *obs_python_signal_handler_disconnect(
|
|||
if (!py_cb || !PyFunction_Check(py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
while (cb) {
|
||||
signal_handler_t *cb_handler =
|
||||
calldata_ptr(&cb->base.extra, "handler");
|
||||
const char *cb_signal =
|
||||
calldata_string(&cb->base.extra, "signal");
|
||||
|
||||
if (cb_signal &&
|
||||
strcmp(signal, cb_signal) != 0 &&
|
||||
if (cb_signal && strcmp(signal, cb_signal) != 0 &&
|
||||
handler == cb_handler)
|
||||
break;
|
||||
|
||||
cb = find_next_python_obs_callback(script, cb, py_cb);
|
||||
}
|
||||
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
static PyObject *obs_python_signal_handler_connect(
|
||||
PyObject *self, PyObject *args)
|
||||
static PyObject *obs_python_signal_handler_connect(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
struct obs_python_script *script = cur_python_script;
|
||||
PyObject *py_sh = NULL;
|
||||
|
|
@ -663,7 +642,7 @@ static PyObject *obs_python_signal_handler_connect(
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static void calldata_signal_callback_global(void *priv, const char *signal,
|
||||
calldata_t *cd)
|
||||
calldata_t *cd)
|
||||
{
|
||||
struct python_obs_callback *cb = priv;
|
||||
|
||||
|
|
@ -688,8 +667,8 @@ static void calldata_signal_callback_global(void *priv, const char *signal,
|
|||
unlock_callback();
|
||||
}
|
||||
|
||||
static PyObject *obs_python_signal_handler_disconnect_global(
|
||||
PyObject *self, PyObject *args)
|
||||
static PyObject *obs_python_signal_handler_disconnect_global(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
struct obs_python_script *script = cur_python_script;
|
||||
PyObject *py_sh = NULL;
|
||||
|
|
@ -713,7 +692,8 @@ static PyObject *obs_python_signal_handler_disconnect_global(
|
|||
if (!py_cb || !PyFunction_Check(py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
while (cb) {
|
||||
signal_handler_t *cb_handler =
|
||||
calldata_ptr(&cb->base.extra, "handler");
|
||||
|
|
@ -724,12 +704,13 @@ static PyObject *obs_python_signal_handler_disconnect_global(
|
|||
cb = find_next_python_obs_callback(script, cb, py_cb);
|
||||
}
|
||||
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
static PyObject *obs_python_signal_handler_connect_global(
|
||||
PyObject *self, PyObject *args)
|
||||
static PyObject *obs_python_signal_handler_connect_global(PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
struct obs_python_script *script = cur_python_script;
|
||||
PyObject *py_sh = NULL;
|
||||
|
|
@ -755,8 +736,8 @@ static PyObject *obs_python_signal_handler_connect_global(
|
|||
|
||||
struct python_obs_callback *cb = add_python_obs_callback(script, py_cb);
|
||||
calldata_set_ptr(&cb->base.extra, "handler", handler);
|
||||
signal_handler_connect_global(handler,
|
||||
calldata_signal_callback_global, cb);
|
||||
signal_handler_connect_global(handler, calldata_signal_callback_global,
|
||||
cb);
|
||||
return python_none();
|
||||
}
|
||||
|
||||
|
|
@ -773,7 +754,7 @@ static void on_remove_hotkey(void *p_cb)
|
|||
obs_hotkey_id id = (obs_hotkey_id)calldata_int(&cb->base.extra, "id");
|
||||
|
||||
if (id != OBS_INVALID_HOTKEY_ID)
|
||||
defer_call_post(defer_hotkey_unregister, (void*)(uintptr_t)id);
|
||||
defer_call_post(defer_hotkey_unregister, (void *)(uintptr_t)id);
|
||||
}
|
||||
|
||||
static void hotkey_pressed(void *p_cb, bool pressed)
|
||||
|
|
@ -811,8 +792,8 @@ static inline PyObject *py_invalid_hotkey_id()
|
|||
return PyLong_FromUnsignedLongLong(OBS_INVALID_HOTKEY_ID);
|
||||
}
|
||||
|
||||
static void hotkey_callback(void *p_cb, obs_hotkey_id id,
|
||||
obs_hotkey_t *hotkey, bool pressed)
|
||||
static void hotkey_callback(void *p_cb, obs_hotkey_id id, obs_hotkey_t *hotkey,
|
||||
bool pressed)
|
||||
{
|
||||
struct python_obs_callback *cb = p_cb;
|
||||
|
||||
|
|
@ -844,8 +825,10 @@ static PyObject *hotkey_unregister(PyObject *self, PyObject *args)
|
|||
if (!py_cb || !PyFunction_Check(py_cb))
|
||||
return python_none();
|
||||
|
||||
struct python_obs_callback *cb = find_python_obs_callback(script, py_cb);
|
||||
if (cb) remove_python_obs_callback(cb);
|
||||
struct python_obs_callback *cb =
|
||||
find_python_obs_callback(script, py_cb);
|
||||
if (cb)
|
||||
remove_python_obs_callback(cb);
|
||||
|
||||
UNUSED_PARAMETER(self);
|
||||
return python_none();
|
||||
|
|
@ -879,7 +862,7 @@ static PyObject *hotkey_register_frontend(PyObject *self, PyObject *args)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static bool button_prop_clicked(obs_properties_t *props, obs_property_t *p,
|
||||
void *p_cb)
|
||||
void *p_cb)
|
||||
{
|
||||
struct python_obs_callback *cb = p_cb;
|
||||
bool ret = false;
|
||||
|
|
@ -931,7 +914,7 @@ static PyObject *properties_add_button(PyObject *self, PyObject *args)
|
|||
|
||||
struct python_obs_callback *cb = add_python_obs_callback(script, py_cb);
|
||||
p = obs_properties_add_button2(props, name, text, button_prop_clicked,
|
||||
cb);
|
||||
cb);
|
||||
|
||||
if (!p || !libobs_to_py(obs_property_t, p, false, &py_ret))
|
||||
return python_none();
|
||||
|
|
@ -943,7 +926,7 @@ static PyObject *properties_add_button(PyObject *self, PyObject *args)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static bool modified_callback(void *p_cb, obs_properties_t *props,
|
||||
obs_property_t *p, obs_data_t *settings)
|
||||
obs_property_t *p, obs_data_t *settings)
|
||||
{
|
||||
struct python_obs_callback *cb = p_cb;
|
||||
bool ret = false;
|
||||
|
|
@ -961,8 +944,8 @@ static bool modified_callback(void *p_cb, obs_properties_t *props,
|
|||
libobs_to_py(obs_property_t, p, false, &py_p) &&
|
||||
libobs_to_py(obs_data_t, settings, false, &py_settings)) {
|
||||
|
||||
PyObject *args = Py_BuildValue("(OOO)", py_props, py_p,
|
||||
py_settings);
|
||||
PyObject *args =
|
||||
Py_BuildValue("(OOO)", py_props, py_p, py_settings);
|
||||
PyObject *py_ret = PyObject_CallObject(cb->func, args);
|
||||
if (!py_error())
|
||||
ret = py_ret == Py_True;
|
||||
|
|
@ -1017,7 +1000,7 @@ static PyObject *remove_current_callback(PyObject *self, PyObject *args)
|
|||
static PyObject *calldata_source(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_ret = NULL;
|
||||
PyObject *py_cd = NULL;
|
||||
PyObject *py_cd = NULL;
|
||||
|
||||
calldata_t *cd;
|
||||
const char *name;
|
||||
|
|
@ -1039,7 +1022,7 @@ fail:
|
|||
static PyObject *calldata_sceneitem(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_ret = NULL;
|
||||
PyObject *py_cd = NULL;
|
||||
PyObject *py_cd = NULL;
|
||||
|
||||
calldata_t *cd;
|
||||
const char *name;
|
||||
|
|
@ -1086,7 +1069,7 @@ static PyObject *enum_sources(PyObject *self, PyObject *args)
|
|||
/* -------------------------------------------- */
|
||||
|
||||
static bool enum_items_proc(obs_scene_t *scene, obs_sceneitem_t *item,
|
||||
void *param)
|
||||
void *param)
|
||||
{
|
||||
PyObject *list = param;
|
||||
PyObject *py_item;
|
||||
|
|
@ -1165,7 +1148,7 @@ static PyObject *sceneitem_list_release(PyObject *self, PyObject *args)
|
|||
struct dstr cur_py_log_chunk = {0};
|
||||
|
||||
static PyObject *py_script_log_internal(PyObject *self, PyObject *args,
|
||||
bool add_endl)
|
||||
bool add_endl)
|
||||
{
|
||||
static bool calling_self = false;
|
||||
int log_level;
|
||||
|
|
@ -1195,7 +1178,7 @@ static PyObject *py_script_log_internal(PyObject *self, PyObject *args,
|
|||
*endl = 0;
|
||||
if (cur_python_script)
|
||||
script_log(&cur_python_script->base, log_level, "%s",
|
||||
start);
|
||||
start);
|
||||
else
|
||||
script_log(NULL, log_level, "%s", start);
|
||||
*endl = '\n';
|
||||
|
|
@ -1206,7 +1189,8 @@ static PyObject *py_script_log_internal(PyObject *self, PyObject *args,
|
|||
|
||||
if (start) {
|
||||
size_t len = strlen(start);
|
||||
if (len) memmove(cur_py_log_chunk.array, start, len);
|
||||
if (len)
|
||||
memmove(cur_py_log_chunk.array, start, len);
|
||||
dstr_resize(&cur_py_log_chunk, len);
|
||||
}
|
||||
|
||||
|
|
@ -1245,31 +1229,26 @@ static void add_hook_functions(PyObject *module)
|
|||
DEF_FUNC("obs_enum_sources", enum_sources),
|
||||
DEF_FUNC("obs_scene_enum_items", scene_enum_items),
|
||||
DEF_FUNC("obs_remove_tick_callback",
|
||||
obs_python_remove_tick_callback),
|
||||
DEF_FUNC("obs_add_tick_callback",
|
||||
obs_python_add_tick_callback),
|
||||
obs_python_remove_tick_callback),
|
||||
DEF_FUNC("obs_add_tick_callback", obs_python_add_tick_callback),
|
||||
DEF_FUNC("signal_handler_disconnect",
|
||||
obs_python_signal_handler_disconnect),
|
||||
obs_python_signal_handler_disconnect),
|
||||
DEF_FUNC("signal_handler_connect",
|
||||
obs_python_signal_handler_connect),
|
||||
obs_python_signal_handler_connect),
|
||||
DEF_FUNC("signal_handler_disconnect_global",
|
||||
obs_python_signal_handler_disconnect_global),
|
||||
obs_python_signal_handler_disconnect_global),
|
||||
DEF_FUNC("signal_handler_connect_global",
|
||||
obs_python_signal_handler_connect_global),
|
||||
DEF_FUNC("obs_hotkey_unregister",
|
||||
hotkey_unregister),
|
||||
obs_python_signal_handler_connect_global),
|
||||
DEF_FUNC("obs_hotkey_unregister", hotkey_unregister),
|
||||
DEF_FUNC("obs_hotkey_register_frontend",
|
||||
hotkey_register_frontend),
|
||||
DEF_FUNC("obs_properties_add_button",
|
||||
properties_add_button),
|
||||
hotkey_register_frontend),
|
||||
DEF_FUNC("obs_properties_add_button", properties_add_button),
|
||||
DEF_FUNC("obs_property_set_modified_callback",
|
||||
property_set_modified_callback),
|
||||
DEF_FUNC("remove_current_callback",
|
||||
remove_current_callback),
|
||||
property_set_modified_callback),
|
||||
DEF_FUNC("remove_current_callback", remove_current_callback),
|
||||
|
||||
#undef DEF_FUNC
|
||||
{0}
|
||||
};
|
||||
{0}};
|
||||
|
||||
add_functions_to_py_module(module, funcs);
|
||||
}
|
||||
|
|
@ -1355,7 +1334,8 @@ void obs_python_script_unload(obs_script_t *s)
|
|||
pthread_mutex_lock(&tick_mutex);
|
||||
|
||||
struct obs_python_script *next = data->next_tick;
|
||||
if (next) next->p_prev_next_tick = data->p_prev_next_tick;
|
||||
if (next)
|
||||
next->p_prev_next_tick = data->p_prev_next_tick;
|
||||
*data->p_prev_next_tick = next;
|
||||
|
||||
pthread_mutex_unlock(&tick_mutex);
|
||||
|
|
@ -1520,7 +1500,8 @@ static void python_tick(void *param, float seconds)
|
|||
while (data) {
|
||||
cur_python_script = data;
|
||||
|
||||
PyObject *py_ret = PyObject_CallObject(data->tick, args);
|
||||
PyObject *py_ret =
|
||||
PyObject_CallObject(data->tick, args);
|
||||
Py_XDECREF(py_ret);
|
||||
py_error();
|
||||
|
||||
|
|
@ -1590,7 +1571,6 @@ void obs_python_load(void)
|
|||
|
||||
pthread_mutex_init(&tick_mutex, NULL);
|
||||
pthread_mutex_init(&timer_mutex, &attr);
|
||||
|
||||
}
|
||||
|
||||
extern void add_python_frontend_funcs(PyObject *module);
|
||||
|
|
@ -1602,12 +1582,12 @@ bool obs_scripting_load_python(const char *python_path)
|
|||
if (python_loaded)
|
||||
return true;
|
||||
|
||||
/* Use external python on windows and mac */
|
||||
/* Use external python on windows and mac */
|
||||
#if RUNTIME_LINK
|
||||
# if 0
|
||||
#if 0
|
||||
struct dstr old_path = {0};
|
||||
struct dstr new_path = {0};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (!import_python(python_path))
|
||||
return false;
|
||||
|
|
@ -1615,11 +1595,11 @@ bool obs_scripting_load_python(const char *python_path)
|
|||
if (python_path && *python_path) {
|
||||
os_utf8_to_wcs(python_path, 0, home_path, 1024);
|
||||
Py_SetPythonHome(home_path);
|
||||
# if 0
|
||||
#if 0
|
||||
dstr_copy(&old_path, getenv("PATH"));
|
||||
_putenv("PYTHONPATH=");
|
||||
_putenv("PATH=");
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
UNUSED_PARAMETER(python_path);
|
||||
|
|
@ -1630,12 +1610,12 @@ bool obs_scripting_load_python(const char *python_path)
|
|||
return false;
|
||||
|
||||
#if 0
|
||||
# ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
if (pythondir && *pythondir) {
|
||||
dstr_printf(&new_path, "PATH=%s", old_path.array);
|
||||
_putenv(new_path.array);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
bfree(pythondir);
|
||||
dstr_free(&new_path);
|
||||
|
|
@ -1650,7 +1630,7 @@ bool obs_scripting_load_python(const char *python_path)
|
|||
/* Must set arguments for guis to work */
|
||||
|
||||
wchar_t *argv[] = {L"", NULL};
|
||||
int argc = sizeof(argv) / sizeof(wchar_t*) - 1;
|
||||
int argc = sizeof(argv) / sizeof(wchar_t *) - 1;
|
||||
|
||||
PySys_SetArgv(argc, argv);
|
||||
|
||||
|
|
|
|||
75
deps/obs-scripting/obs-scripting-python.h
vendored
75
deps/obs-scripting/obs-scripting-python.h
vendored
|
|
@ -55,9 +55,9 @@
|
|||
#define do_log(level, format, ...) \
|
||||
blog(level, "[Python] " format, ##__VA_ARGS__)
|
||||
|
||||
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
|
|
@ -90,43 +90,40 @@ struct python_obs_callback {
|
|||
PyObject *func;
|
||||
};
|
||||
|
||||
static inline struct python_obs_callback *add_python_obs_callback_extra(
|
||||
struct obs_python_script *script,
|
||||
PyObject *func,
|
||||
size_t extra_size)
|
||||
static inline struct python_obs_callback *
|
||||
add_python_obs_callback_extra(struct obs_python_script *script, PyObject *func,
|
||||
size_t extra_size)
|
||||
{
|
||||
struct python_obs_callback *cb = add_script_callback(
|
||||
&script->first_callback,
|
||||
(obs_script_t *)script,
|
||||
sizeof(*cb) + extra_size);
|
||||
&script->first_callback, (obs_script_t *)script,
|
||||
sizeof(*cb) + extra_size);
|
||||
|
||||
Py_XINCREF(func);
|
||||
cb->func = func;
|
||||
return cb;
|
||||
}
|
||||
|
||||
static inline struct python_obs_callback *add_python_obs_callback(
|
||||
struct obs_python_script *script,
|
||||
PyObject *func)
|
||||
static inline struct python_obs_callback *
|
||||
add_python_obs_callback(struct obs_python_script *script, PyObject *func)
|
||||
{
|
||||
return add_python_obs_callback_extra(script, func, 0);
|
||||
}
|
||||
|
||||
static inline void *python_obs_callback_extra_data(
|
||||
struct python_obs_callback *cb)
|
||||
static inline void *
|
||||
python_obs_callback_extra_data(struct python_obs_callback *cb)
|
||||
{
|
||||
return (void*)&cb[1];
|
||||
return (void *)&cb[1];
|
||||
}
|
||||
|
||||
static inline struct obs_python_script *python_obs_callback_script(
|
||||
struct python_obs_callback *cb)
|
||||
static inline struct obs_python_script *
|
||||
python_obs_callback_script(struct python_obs_callback *cb)
|
||||
{
|
||||
return (struct obs_python_script *)cb->base.script;
|
||||
}
|
||||
|
||||
static inline struct python_obs_callback *find_next_python_obs_callback(
|
||||
struct obs_python_script *script,
|
||||
struct python_obs_callback *cb, PyObject *func)
|
||||
static inline struct python_obs_callback *
|
||||
find_next_python_obs_callback(struct obs_python_script *script,
|
||||
struct python_obs_callback *cb, PyObject *func)
|
||||
{
|
||||
cb = cb ? (struct python_obs_callback *)cb->base.next
|
||||
: (struct python_obs_callback *)script->first_callback;
|
||||
|
|
@ -140,9 +137,8 @@ static inline struct python_obs_callback *find_next_python_obs_callback(
|
|||
return cb;
|
||||
}
|
||||
|
||||
static inline struct python_obs_callback *find_python_obs_callback(
|
||||
struct obs_python_script *script,
|
||||
PyObject *func)
|
||||
static inline struct python_obs_callback *
|
||||
find_python_obs_callback(struct obs_python_script *script, PyObject *func)
|
||||
{
|
||||
return find_next_python_obs_callback(script, NULL, func);
|
||||
}
|
||||
|
|
@ -167,7 +163,8 @@ static inline void free_python_obs_callback(struct python_obs_callback *cb)
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
static int parse_args_(PyObject *args, const char *func, const char *format, ...)
|
||||
static int parse_args_(PyObject *args, const char *func, const char *format,
|
||||
...)
|
||||
{
|
||||
char new_format[128];
|
||||
va_list va_args;
|
||||
|
|
@ -197,15 +194,13 @@ static inline bool py_error_(const char *func, int line)
|
|||
|
||||
#define py_error() py_error_(__FUNCTION__, __LINE__)
|
||||
|
||||
#define lock_python() \
|
||||
PyGILState_STATE gstate = PyGILState_Ensure()
|
||||
#define unlock_python() \
|
||||
PyGILState_Release(gstate)
|
||||
#define lock_python() PyGILState_STATE gstate = PyGILState_Ensure()
|
||||
#define unlock_python() PyGILState_Release(gstate)
|
||||
|
||||
struct py_source;
|
||||
typedef struct py_source py_source_t;
|
||||
|
||||
extern PyObject* py_libobs;
|
||||
extern PyObject *py_libobs;
|
||||
extern struct python_obs_callback *cur_python_cb;
|
||||
extern struct obs_python_script *cur_python_script;
|
||||
|
||||
|
|
@ -213,25 +208,17 @@ extern void py_to_obs_source_info(py_source_t *py_info);
|
|||
extern PyObject *py_obs_register_source(PyObject *self, PyObject *args);
|
||||
extern PyObject *py_obs_get_script_config_path(PyObject *self, PyObject *args);
|
||||
extern void add_functions_to_py_module(PyObject *module,
|
||||
PyMethodDef *method_list);
|
||||
PyMethodDef *method_list);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Warning: the following functions expect python to be locked! */
|
||||
|
||||
extern bool py_to_libobs_(const char *type,
|
||||
PyObject * py_in,
|
||||
void * libobs_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line);
|
||||
extern bool py_to_libobs_(const char *type, PyObject *py_in, void *libobs_out,
|
||||
const char *id, const char *func, int line);
|
||||
|
||||
extern bool libobs_to_py_(const char *type,
|
||||
void * libobs_in,
|
||||
bool ownership,
|
||||
PyObject ** py_out,
|
||||
const char *id,
|
||||
const char *func,
|
||||
int line);
|
||||
extern bool libobs_to_py_(const char *type, void *libobs_in, bool ownership,
|
||||
PyObject **py_out, const char *id, const char *func,
|
||||
int line);
|
||||
|
||||
extern bool py_call(PyObject *call, PyObject **ret, const char *arg_def, ...);
|
||||
extern bool py_import_script(const char *name);
|
||||
|
|
|
|||
21
deps/obs-scripting/obs-scripting.c
vendored
21
deps/obs-scripting/obs-scripting.c
vendored
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#if COMPILE_LUA
|
||||
extern obs_script_t *obs_lua_script_create(const char *path,
|
||||
obs_data_t *settings);
|
||||
obs_data_t *settings);
|
||||
extern bool obs_lua_script_load(obs_script_t *s);
|
||||
extern void obs_lua_script_unload(obs_script_t *s);
|
||||
extern void obs_lua_script_destroy(obs_script_t *s);
|
||||
|
|
@ -41,7 +41,7 @@ extern void obs_lua_script_save(obs_script_t *script);
|
|||
|
||||
#if COMPILE_PYTHON
|
||||
extern obs_script_t *obs_python_script_create(const char *path,
|
||||
obs_data_t *settings);
|
||||
obs_data_t *settings);
|
||||
extern bool obs_python_script_load(obs_script_t *s);
|
||||
extern void obs_python_script_unload(obs_script_t *s);
|
||||
extern void obs_python_script_destroy(obs_script_t *s);
|
||||
|
|
@ -49,7 +49,8 @@ extern void obs_python_load(void);
|
|||
extern void obs_python_unload(void);
|
||||
|
||||
extern obs_properties_t *obs_python_script_get_properties(obs_script_t *script);
|
||||
extern void obs_python_script_update(obs_script_t *script, obs_data_t *settings);
|
||||
extern void obs_python_script_update(obs_script_t *script,
|
||||
obs_data_t *settings);
|
||||
extern void obs_python_script_save(obs_script_t *script);
|
||||
#endif
|
||||
|
||||
|
|
@ -66,8 +67,7 @@ static const char *supported_formats[] = {
|
|||
#if COMPILE_PYTHON
|
||||
"py",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
NULL};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ void obs_scripting_unload(void)
|
|||
if (!scripting_loaded)
|
||||
return;
|
||||
|
||||
/* ---------------------- */
|
||||
/* ---------------------- */
|
||||
|
||||
#if COMPILE_LUA
|
||||
obs_lua_unload();
|
||||
|
|
@ -195,7 +195,7 @@ void obs_scripting_unload(void)
|
|||
pthread_mutex_destroy(&detach_mutex);
|
||||
|
||||
blog(LOG_INFO, "[Scripting] Total detached callbacks: %d",
|
||||
total_detached);
|
||||
total_detached);
|
||||
|
||||
/* ---------------------- */
|
||||
|
||||
|
|
@ -223,11 +223,10 @@ const char **obs_scripting_supported_formats(void)
|
|||
}
|
||||
|
||||
static inline bool pointer_valid(const void *x, const char *name,
|
||||
const char *func)
|
||||
const char *func)
|
||||
{
|
||||
if (!x) {
|
||||
blog(LOG_WARNING, "obs-scripting: [%s] %s is null",
|
||||
func, name);
|
||||
blog(LOG_WARNING, "obs-scripting: [%s] %s is null", func, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +255,7 @@ obs_script_t *obs_script_create(const char *path, obs_data_t *settings)
|
|||
} else
|
||||
#endif
|
||||
#if COMPILE_PYTHON
|
||||
if (strcmp(ext, ".py") == 0) {
|
||||
if (strcmp(ext, ".py") == 0) {
|
||||
script = obs_python_script_create(path, settings);
|
||||
} else
|
||||
#endif
|
||||
|
|
|
|||
11
deps/obs-scripting/obs-scripting.h
vendored
11
deps/obs-scripting/obs-scripting.h
vendored
|
|
@ -39,14 +39,11 @@ EXPORT bool obs_scripting_load(void);
|
|||
EXPORT void obs_scripting_unload(void);
|
||||
EXPORT const char **obs_scripting_supported_formats(void);
|
||||
|
||||
typedef void (*scripting_log_handler_t)(
|
||||
void *p,
|
||||
obs_script_t *script,
|
||||
int lvl,
|
||||
const char *msg);
|
||||
typedef void (*scripting_log_handler_t)(void *p, obs_script_t *script, int lvl,
|
||||
const char *msg);
|
||||
|
||||
EXPORT void obs_scripting_set_log_callback(
|
||||
scripting_log_handler_t handler, void *param);
|
||||
EXPORT void obs_scripting_set_log_callback(scripting_log_handler_t handler,
|
||||
void *param);
|
||||
|
||||
EXPORT bool obs_scripting_python_runtime_linked(void);
|
||||
EXPORT bool obs_scripting_python_loaded(void);
|
||||
|
|
|
|||
13
deps/obs-scripting/obslua/CMakeLists.txt
vendored
13
deps/obs-scripting/obslua/CMakeLists.txt
vendored
|
|
@ -1,6 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(obslua)
|
||||
|
||||
if(POLICY CMP0078)
|
||||
cmake_policy(SET CMP0078 OLD)
|
||||
endif()
|
||||
|
||||
find_package(SWIG 2 REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
|
|
@ -16,7 +20,14 @@ endif()
|
|||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SWIG_ADD_MODULE(obslua lua obslua.i ../cstrcache.cpp ../cstrcache.h)
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.7.2)
|
||||
SWIG_ADD_LIBRARY(obslua
|
||||
LANGUAGE lua
|
||||
TYPE MODULE
|
||||
SOURCES obslua.i ../cstrcache.cpp ../cstrcache.h)
|
||||
else()
|
||||
SWIG_ADD_MODULE(obslua lua obslua.i ../cstrcache.cpp ../cstrcache.h)
|
||||
endif()
|
||||
SWIG_LINK_LIBRARIES(obslua obs-scripting libobs ${LUA_LIBRARIES} ${EXTRA_LIBS})
|
||||
|
||||
function(install_plugin_bin_swig target additional_target)
|
||||
|
|
|
|||
13
deps/obs-scripting/obspython/CMakeLists.txt
vendored
13
deps/obs-scripting/obspython/CMakeLists.txt
vendored
|
|
@ -1,6 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(obspython)
|
||||
|
||||
if(POLICY CMP0078)
|
||||
cmake_policy(SET CMP0078 OLD)
|
||||
endif()
|
||||
|
||||
find_package(SWIG 2 REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
|
|
@ -30,7 +34,14 @@ if(WIN32)
|
|||
string(REGEX REPLACE "_d" "" PYTHON_LIBRARIES "${PYTHON_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
SWIG_ADD_MODULE(obspython python obspython.i ../cstrcache.cpp ../cstrcache.h)
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.7.2)
|
||||
SWIG_ADD_LIBRARY(obspython
|
||||
LANGUAGE python
|
||||
TYPE MODULE
|
||||
SOURCES obspython.i ../cstrcache.cpp ../cstrcache.h)
|
||||
else()
|
||||
SWIG_ADD_MODULE(obspython python obspython.i ../cstrcache.cpp ../cstrcache.h)
|
||||
endif()
|
||||
SWIG_LINK_LIBRARIES(obspython obs-scripting libobs ${PYTHON_LIBRARIES})
|
||||
|
||||
function(install_plugin_bin_swig target additional_target)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue