mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
libobs: Refactor item signaling (add func to signal parent)
This commit is contained in:
parent
a1012c3f2c
commit
7a2337c1f2
|
@ -20,6 +20,9 @@
|
||||||
#include "graphics/math-defs.h"
|
#include "graphics/math-defs.h"
|
||||||
#include "obs-scene.h"
|
#include "obs-scene.h"
|
||||||
|
|
||||||
|
static void signal_parent(obs_scene_t *parent, const char *name,
|
||||||
|
calldata_t *params);
|
||||||
|
|
||||||
/* NOTE: For proper mutex lock order (preventing mutual cross-locks), never
|
/* NOTE: For proper mutex lock order (preventing mutual cross-locks), never
|
||||||
* lock the graphics mutex inside either of the scene mutexes.
|
* lock the graphics mutex inside either of the scene mutexes.
|
||||||
*
|
*
|
||||||
|
@ -48,11 +51,9 @@ static inline void signal_item_remove(struct obs_scene_item *item)
|
||||||
uint8_t stack[128];
|
uint8_t stack[128];
|
||||||
|
|
||||||
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
||||||
calldata_set_ptr(¶ms, "scene", item->parent);
|
|
||||||
calldata_set_ptr(¶ms, "item", item);
|
calldata_set_ptr(¶ms, "item", item);
|
||||||
|
|
||||||
signal_handler_signal(item->parent->source->context.signals,
|
signal_parent(item->parent, "item_remove", ¶ms);
|
||||||
"item_remove", ¶ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *scene_getname(void *unused)
|
static const char *scene_getname(void *unused)
|
||||||
|
@ -379,10 +380,8 @@ static void update_item_transform(struct obs_scene_item *item)
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
|
|
||||||
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
||||||
calldata_set_ptr(¶ms, "scene", item->parent);
|
|
||||||
calldata_set_ptr(¶ms, "item", item);
|
calldata_set_ptr(¶ms, "item", item);
|
||||||
signal_handler_signal(item->parent->source->context.signals,
|
signal_parent(item->parent, "item_transform", ¶ms);
|
||||||
"item_transform", ¶ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool source_size_changed(struct obs_scene_item *item)
|
static inline bool source_size_changed(struct obs_scene_item *item)
|
||||||
|
@ -1519,6 +1518,13 @@ obs_source_t *obs_sceneitem_get_source(const obs_sceneitem_t *item)
|
||||||
return item ? item->source : NULL;
|
return item ? item->source : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void signal_parent(obs_scene_t *parent, const char *command,
|
||||||
|
calldata_t *params)
|
||||||
|
{
|
||||||
|
calldata_set_ptr(params, "scene", parent);
|
||||||
|
signal_handler_signal(parent->source->context.signals, command, params);
|
||||||
|
}
|
||||||
|
|
||||||
void obs_sceneitem_select(obs_sceneitem_t *item, bool select)
|
void obs_sceneitem_select(obs_sceneitem_t *item, bool select)
|
||||||
{
|
{
|
||||||
struct calldata params;
|
struct calldata params;
|
||||||
|
@ -1531,10 +1537,9 @@ void obs_sceneitem_select(obs_sceneitem_t *item, bool select)
|
||||||
item->selected = select;
|
item->selected = select;
|
||||||
|
|
||||||
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
||||||
calldata_set_ptr(¶ms, "scene", item->parent);
|
|
||||||
calldata_set_ptr(¶ms, "item", item);
|
calldata_set_ptr(¶ms, "item", item);
|
||||||
signal_handler_signal(item->parent->source->context.signals,
|
|
||||||
command, ¶ms);
|
signal_parent(item->parent, command, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool obs_sceneitem_selected(const obs_sceneitem_t *item)
|
bool obs_sceneitem_selected(const obs_sceneitem_t *item)
|
||||||
|
@ -1583,10 +1588,7 @@ static inline void signal_reorder(struct obs_scene_item *item)
|
||||||
command = "reorder";
|
command = "reorder";
|
||||||
|
|
||||||
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
calldata_init_fixed(¶ms, stack, sizeof(stack));
|
||||||
calldata_set_ptr(¶ms, "scene", item->parent);
|
signal_parent(item->parent, command, ¶ms);
|
||||||
|
|
||||||
signal_handler_signal(item->parent->source->context.signals,
|
|
||||||
command, ¶ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void obs_sceneitem_set_order(obs_sceneitem_t *item,
|
void obs_sceneitem_set_order(obs_sceneitem_t *item,
|
||||||
|
@ -1807,12 +1809,10 @@ bool obs_sceneitem_set_visible(obs_sceneitem_t *item, bool visible)
|
||||||
item->user_visible = visible;
|
item->user_visible = visible;
|
||||||
|
|
||||||
calldata_init_fixed(&cd, stack, sizeof(stack));
|
calldata_init_fixed(&cd, stack, sizeof(stack));
|
||||||
calldata_set_ptr(&cd, "scene", item->parent);
|
|
||||||
calldata_set_ptr(&cd, "item", item);
|
calldata_set_ptr(&cd, "item", item);
|
||||||
calldata_set_bool(&cd, "visible", visible);
|
calldata_set_bool(&cd, "visible", visible);
|
||||||
|
|
||||||
signal_handler_signal(item->parent->source->context.signals,
|
signal_parent(item->parent, "item_visible", &cd);
|
||||||
"item_visible", &cd);
|
|
||||||
|
|
||||||
if (source_has_audio(item->source)) {
|
if (source_has_audio(item->source)) {
|
||||||
pthread_mutex_lock(&item->actions_mutex);
|
pthread_mutex_lock(&item->actions_mutex);
|
||||||
|
|
Loading…
Reference in a new issue