New upstream version 24.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2019-09-22 23:19:10 +02:00
parent b14f9eae6d
commit 5a730d6ec3
842 changed files with 42245 additions and 33385 deletions

View file

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