c9df41c1e2
Typedef pointers are unsafe. If you do: typedef struct bla *bla_t; then you cannot use it as a constant, such as: const bla_t, because that constant will be to the pointer itself rather than to the underlying data. I admit this was a fundamental mistake that must be corrected. All typedefs that were pointer types will now have their pointers removed from the type itself, and the pointers will be used when they are actually used as variables/parameters/returns instead. This does not break ABI though, which is pretty nice.
68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
#include <obs-module.h>
|
|
|
|
struct test_filter {
|
|
obs_source_t *source;
|
|
gs_effect_t *whatever;
|
|
};
|
|
|
|
static const char *filter_getname(void)
|
|
{
|
|
return "Test";
|
|
}
|
|
|
|
static void filter_destroy(void *data)
|
|
{
|
|
struct test_filter *tf = data;
|
|
|
|
if (tf) {
|
|
obs_enter_graphics();
|
|
|
|
gs_effect_destroy(tf->whatever);
|
|
bfree(tf);
|
|
|
|
obs_leave_graphics();
|
|
}
|
|
}
|
|
|
|
static void *filter_create(obs_data_t *settings, obs_source_t *source)
|
|
{
|
|
struct test_filter *tf = bzalloc(sizeof(struct test_filter));
|
|
char *effect_file;
|
|
|
|
obs_enter_graphics();
|
|
|
|
effect_file = obs_module_file("test.effect");
|
|
|
|
tf->source = source;
|
|
tf->whatever = gs_effect_create_from_file(effect_file, NULL);
|
|
bfree(effect_file);
|
|
if (!tf->whatever) {
|
|
filter_destroy(tf);
|
|
return NULL;
|
|
}
|
|
|
|
obs_leave_graphics();
|
|
|
|
UNUSED_PARAMETER(settings);
|
|
return tf;
|
|
}
|
|
|
|
static void filter_render(void *data, gs_effect_t *effect)
|
|
{
|
|
struct test_filter *tf = data;
|
|
obs_source_process_filter(tf->source, tf->whatever, 0, 0, GS_RGBA,
|
|
OBS_ALLOW_DIRECT_RENDERING);
|
|
|
|
UNUSED_PARAMETER(effect);
|
|
}
|
|
|
|
struct obs_source_info test_filter = {
|
|
.id = "test_filter",
|
|
.type = OBS_SOURCE_TYPE_FILTER,
|
|
.output_flags = OBS_SOURCE_VIDEO,
|
|
.get_name = filter_getname,
|
|
.create = filter_create,
|
|
.destroy = filter_destroy,
|
|
.video_render = filter_render
|
|
};
|