summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drm_fb.c2
-rw-r--r--src/main.c13
-rw-r--r--src/modules/compose/compose.c10
-rw-r--r--src/modules/drizzle/drizzle.c4
-rw-r--r--src/modules/flui2d/flui2d.c4
-rw-r--r--src/modules/julia/julia.c2
-rw-r--r--src/modules/meta2d/meta2d.c2
-rw-r--r--src/modules/montage/montage.c6
-rw-r--r--src/modules/pixbounce/pixbounce.c2
-rw-r--r--src/modules/plasma/plasma.c2
-rw-r--r--src/modules/plato/plato.c2
-rw-r--r--src/modules/ray/ray.c2
-rw-r--r--src/modules/roto/roto.c2
-rw-r--r--src/modules/rtv/rtv.c19
-rw-r--r--src/modules/snow/snow.c2
-rw-r--r--src/modules/sparkler/sparkler.c4
-rw-r--r--src/modules/spiro/spiro.c2
-rw-r--r--src/modules/stars/stars.c4
-rw-r--r--src/modules/submit/submit.c4
-rw-r--r--src/modules/swab/swab.c2
-rw-r--r--src/modules/swarm/swarm.c4
-rw-r--r--src/sdl_fb.c2
-rw-r--r--src/setup.c4
-rw-r--r--src/setup.h2
-rw-r--r--src/til.c8
-rw-r--r--src/til.h8
-rw-r--r--src/til_fb.h2
27 files changed, 62 insertions, 58 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c
index 02c40bd..67d8e68 100644
--- a/src/drm_fb.c
+++ b/src/drm_fb.c
@@ -283,7 +283,7 @@ static int mode_desc_generator(void *setup_context, const til_setting_desc_t **r
/* setup is called repeatedly as settings is constructed, until 0 is returned. */
/* a negative value is returned on error */
/* positive value indicates another setting is needed, described in next_setting */
-static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
drm_fb_setup_t context = {};
til_setting_desc_generator_t generators[] = {
diff --git a/src/main.c b/src/main.c
index c19b6b5..15bde39 100644
--- a/src/main.c
+++ b/src/main.c
@@ -51,7 +51,9 @@ static rototiller_t rototiller;
typedef struct setup_t {
til_settings_t *module;
+ void *module_setup;
til_settings_t *video;
+ void *video_setup;
} setup_t;
/* FIXME: this is unnecessarily copy-pasta, i think modules should just be made
@@ -60,7 +62,7 @@ typedef struct setup_t {
*/
/* select video backend if not yet selected, then setup the selected backend. */
-static int setup_video(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int setup_video(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
til_setting_t *setting;
const char *video;
@@ -101,14 +103,14 @@ static int setup_video(til_settings_t *settings, til_setting_t **res_setting, co
if (!strcmp(video, "drm")) {
fb_ops = &drm_fb_ops;
- return drm_fb_ops.setup(settings, res_setting, res_desc);
+ return drm_fb_ops.setup(settings, res_setting, res_desc, res_setup);
}
#endif
#ifdef HAVE_SDL
if (!strcmp(video, "sdl")) {
fb_ops = &sdl_fb_ops;
- return sdl_fb_ops.setup(settings, res_setting, res_desc);
+ return sdl_fb_ops.setup(settings, res_setting, res_desc, res_setup);
}
#endif
@@ -131,13 +133,13 @@ static int setup_from_args(til_args_t *args, setup_t *res_setup)
if (!setup.video)
goto _err;
- r = setup_interactively(setup.module, til_module_setup, args->use_defaults);
+ r = setup_interactively(setup.module, til_module_setup, args->use_defaults, &setup.module_setup);
if (r < 0)
goto _err;
if (r)
changes = 1;
- r = setup_interactively(setup.video, setup_video, args->use_defaults);
+ r = setup_interactively(setup.video, setup_video, args->use_defaults, &setup.video_setup);
if (r < 0)
goto _err;
if (r)
@@ -274,6 +276,7 @@ int main(int argc, const char *argv[])
get_ticks(&rototiller.start_tv,
&rototiller.start_tv,
rototiller.ticks_offset),
+ setup.module_setup,
&rototiller.module_context)) < 0,
"unable to create module context: %s", strerror(-r));
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index b3e2dbc..adf638c 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -36,10 +36,10 @@ typedef struct compose_context_t {
compose_layer_t layers[];
} compose_context_t;
-static void * compose_create_context(unsigned ticks, unsigned num_cpus);
+static void * compose_create_context(unsigned ticks, unsigned num_cpus, void *setup);
static void compose_destroy_context(void *context);
static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter);
-static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
static char *compose_default_layers[] = { "drizzle", "stars", "spiro", "plato", NULL };
static char **compose_layers;
@@ -55,7 +55,7 @@ til_module_t compose_module = {
};
-static void * compose_create_context(unsigned ticks, unsigned num_cpus)
+static void * compose_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
char **layers = compose_default_layers;
compose_context_t *ctxt;
@@ -78,7 +78,7 @@ static void * compose_create_context(unsigned ticks, unsigned num_cpus)
module = til_lookup_module(layers[i]);
ctxt->layers[i].module = module;
- (void) til_module_create_context(module, ticks, &ctxt->layers[i].module_ctxt);
+ (void) til_module_create_context(module, ticks, NULL, &ctxt->layers[i].module_ctxt);
ctxt->n_layers++;
}
@@ -108,7 +108,7 @@ static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus
}
-static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *layers;
int r;
diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c
index 294d671..0a53492 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -64,7 +64,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * drizzle_create_context(unsigned ticks, unsigned num_cpus)
+static void * drizzle_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
drizzle_context_t *ctxt;
@@ -153,7 +153,7 @@ static void drizzle_render_fragment(void *context, unsigned ticks, unsigned cpu,
}
-static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *viscosity;
const char *values[] = {
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index 7a30c7e..cf6024b 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -185,7 +185,7 @@ typedef struct flui2d_context_t {
} flui2d_context_t;
-static void * flui2d_create_context(unsigned ticks, unsigned num_cpus)
+static void * flui2d_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
flui2d_context_t *ctxt;
@@ -283,7 +283,7 @@ static void flui2d_render_fragment(void *context, unsigned ticks, unsigned cpu,
/* Settings hooks for configurable variables */
-static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *viscosity;
const char *diffusion;
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c
index f00c44c..dfe6726 100644
--- a/src/modules/julia/julia.c
+++ b/src/modules/julia/julia.c
@@ -66,7 +66,7 @@ static uint32_t colors[] = {
};
-static void * julia_create_context(unsigned ticks, unsigned num_cpus)
+static void * julia_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(julia_context_t));
}
diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c
index c1b2a8a..ddf20f1 100644
--- a/src/modules/meta2d/meta2d.c
+++ b/src/modules/meta2d/meta2d.c
@@ -66,7 +66,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * meta2d_create_context(unsigned ticks, unsigned num_cpus)
+static void * meta2d_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
meta2d_context_t *ctxt;
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 5782782..5a9b688 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -16,7 +16,7 @@ typedef struct montage_context_t {
} montage_context_t;
static void setup_next_module(montage_context_t *ctxt);
-static void * montage_create_context(unsigned ticks, unsigned num_cpus);
+static void * montage_create_context(unsigned ticks, unsigned num_cpus, void *setup);
static void montage_destroy_context(void *context);
static void montage_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter);
static void montage_render_fragment(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment);
@@ -32,7 +32,7 @@ til_module_t montage_module = {
};
-static void * montage_create_context(unsigned ticks, unsigned num_cpus)
+static void * montage_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
const til_module_t **modules, *rtv_module, *compose_module;
size_t n_modules;
@@ -90,7 +90,7 @@ static void * montage_create_context(unsigned ticks, unsigned num_cpus)
const til_module_t *module = ctxt->modules[i];
if (module->create_context) /* FIXME errors */
- ctxt->contexts[i] = module->create_context(ticks, 1);
+ ctxt->contexts[i] = module->create_context(ticks, 1, NULL);
}
return ctxt;
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index 3efa797..d016ff7 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -109,7 +109,7 @@ static int pick_pix(int num_pics, int last_pic)
return pix_num;
}
-static void * pixbounce_create_context(unsigned ticks, unsigned num_cpus)
+static void * pixbounce_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
pixbounce_context_t *ctxt;
diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c
index 7598fe3..c6380ef 100644
--- a/src/modules/plasma/plasma.c
+++ b/src/modules/plasma/plasma.c
@@ -52,7 +52,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab)
}
-static void * plasma_create_context(unsigned ticks, unsigned num_cpus)
+static void * plasma_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
static int initialized;
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index 05d80cb..c8aba18 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -609,7 +609,7 @@ static void draw_polyhedron(const polyhedron_t *polyhedron, m4f_t *transform, ti
}
-static void * plato_create_context(unsigned ticks, unsigned num_cpus)
+static void * plato_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
plato_context_t *ctxt;
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index 06b0180..79e14ce 100644
--- a/src/modules/ray/ray.c
+++ b/src/modules/ray/ray.c
@@ -130,7 +130,7 @@ typedef struct ray_context_t {
} ray_context_t;
-static void * ray_create_context(unsigned ticks, unsigned num_cpus)
+static void * ray_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(ray_context_t));
}
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c
index 7aff770..ac66987 100644
--- a/src/modules/roto/roto.c
+++ b/src/modules/roto/roto.c
@@ -32,7 +32,7 @@ static int32_t costab[FIXED_TRIG_LUT_SIZE], sintab[FIXED_TRIG_LUT_SIZE];
static uint8_t texture[256][256];
static color_t palette[2];
-static void * roto_create_context(unsigned ticks, unsigned num_cpus)
+static void * roto_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(roto_context_t));
}
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 1804613..b49ac37 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -24,6 +24,7 @@
typedef struct rtv_channel_t {
const til_module_t *module;
void *module_ctxt;
+ void *module_setup;
time_t last_on_time, cumulative_time;
char *settings;
txt_t *caption;
@@ -44,11 +45,11 @@ typedef struct rtv_context_t {
} rtv_context_t;
static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks);
-static void * rtv_create_context(unsigned ticks, unsigned num_cpus);
+static void * rtv_create_context(unsigned ticks, unsigned num_cpus, void *setup);
static void rtv_destroy_context(void *context);
static void rtv_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter);
static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *fragment);
-static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
static unsigned rtv_duration = RTV_DURATION_SECS;
static unsigned rtv_context_duration = RTV_CONTEXT_DURATION_SECS;
@@ -92,7 +93,7 @@ static void randomize_channels(rtv_context_t *ctxt)
}
-static char * randomize_module_setup(const til_module_t *module)
+static char * randomize_module_setup(const til_module_t *module, void **res_setup)
{
til_settings_t *settings;
til_setting_t *setting;
@@ -106,7 +107,7 @@ static char * randomize_module_setup(const til_module_t *module)
if (!settings)
return NULL;
- while (module->setup(settings, &setting, &desc) > 0) {
+ while (module->setup(settings, &setting, &desc, res_setup) > 0) {
if (desc->random) {
char *value;
@@ -181,7 +182,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks)
char *settings;
txt_t *caption;
- settings = randomize_module_setup(ctxt->channel->module);
+ settings = randomize_module_setup(ctxt->channel->module, &ctxt->channel->module_setup);
caption = txt_newf("Title: %s%s%s\nDescription: %s%s%s",
ctxt->channel->module->name,
ctxt->channel->module->author ? "\nAuthor: " : "",
@@ -199,7 +200,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks)
}
if (!ctxt->channel->module_ctxt)
- (void) til_module_create_context(ctxt->channel->module, ticks, &ctxt->channel->module_ctxt);
+ (void) til_module_create_context(ctxt->channel->module, ticks, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
ctxt->channel->last_on_time = now;
}
@@ -223,7 +224,7 @@ static int rtv_should_skip_module(const rtv_context_t *ctxt, const til_module_t
}
-static void * rtv_create_context(unsigned ticks, unsigned num_cpus)
+static void * rtv_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
rtv_context_t *ctxt;
const til_module_t **modules;
@@ -241,7 +242,7 @@ static void * rtv_create_context(unsigned ticks, unsigned num_cpus)
ctxt->snow_channel.module = &none_module;
if (rtv_snow_module) {
ctxt->snow_channel.module = til_lookup_module(rtv_snow_module);
- (void) til_module_create_context(ctxt->snow_channel.module, ticks, &ctxt->snow_channel.module_ctxt);
+ (void) til_module_create_context(ctxt->snow_channel.module, ticks, NULL, &ctxt->snow_channel.module_ctxt);
}
for (size_t i = 0; i < n_modules; i++) {
@@ -307,7 +308,7 @@ static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *f
}
-static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *channels;
const char *duration;
diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c
index cffc10c..f61f2e9 100644
--- a/src/modules/snow/snow.c
+++ b/src/modules/snow/snow.c
@@ -20,7 +20,7 @@ typedef struct snow_context_t {
} snow_context_t;
-static void * snow_create_context(unsigned ticks, unsigned n_cpus)
+static void * snow_create_context(unsigned ticks, unsigned n_cpus, void *setup)
{
snow_context_t *ctxt;
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index 7cebfcd..51184b1 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -25,7 +25,7 @@ extern particle_ops_t simple_ops;
static particles_conf_t sparkler_conf;
-static void * sparkler_create_context(unsigned ticks, unsigned num_cpus)
+static void * sparkler_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
static int initialized;
sparkler_context_t *ctxt;
@@ -96,7 +96,7 @@ static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu
/* Settings hooks for configurable variables */
-static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *show_bsp_leafs;
const char *show_bsp_matches;
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 7f31ddb..20fd7f0 100644
--- a/src/modules/spiro/spiro.c
+++ b/src/modules/spiro/spiro.c
@@ -29,7 +29,7 @@ typedef struct spiro_context_t {
} spiro_context_t;
-static void * spiro_create_context(unsigned ticks, unsigned num_cpus)
+static void * spiro_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
spiro_context_t *ctxt;
float z;
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 859fb1f..055a495 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -41,7 +41,7 @@ float get_random_unit_coord() {
}
-static void * stars_create_context(unsigned ticks, unsigned num_cpus)
+static void * stars_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
stars_context_t *ctxt;
float z;
@@ -201,7 +201,7 @@ static void stars_render_fragment(void *context, unsigned ticks, unsigned cpu, t
ctxt->offset_y = tmp_y;
}
-int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *rot_adj;
const char *rot_adj_values[] = {
diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c
index db5cf29..a2dea77 100644
--- a/src/modules/submit/submit.c
+++ b/src/modules/submit/submit.c
@@ -261,7 +261,7 @@ static void setup_grid(submit_context_t *ctxt)
}
-static void * submit_create_context(unsigned ticks, unsigned num_cpus)
+static void * submit_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
submit_context_t *ctxt;
@@ -322,7 +322,7 @@ static void submit_render_fragment(void *context, unsigned ticks, unsigned cpu,
}
-static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *values[] = {
"off",
diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c
index fee20cf..b64ca2b 100644
--- a/src/modules/swab/swab.c
+++ b/src/modules/swab/swab.c
@@ -65,7 +65,7 @@ static inline uint32_t color_to_uint32(color_t color) {
}
-static void * swab_create_context(unsigned ticks, unsigned num_cpus)
+static void * swab_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
swab_context_t *ctxt;
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index 8ff4812..ffaaa1d 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -170,7 +170,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * swarm_create_context(unsigned ticks, unsigned num_cpus)
+static void * swarm_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
swarm_context_t *ctxt;
@@ -408,7 +408,7 @@ static void swarm_render_fragment(void *context, unsigned ticks, unsigned cpu, t
}
-static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *styles[] = {
"points",
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 6aa535b..72bc7b6 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -26,7 +26,7 @@ struct sdl_fb_page_t {
};
-static int sdl_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int sdl_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *fullscreen_values[] = {
"off",
diff --git a/src/setup.c b/src/setup.c
index c811887..8f2708d 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -21,7 +21,7 @@ static int add_value(til_settings_t *settings, const char *key, const char *valu
/* returns negative on error, otherwise number of additions made to settings */
-int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults)
+int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup), int defaults, void **res_setup)
{
unsigned additions = 0;
char buf[256] = "\n";
@@ -34,7 +34,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings
/* TODO: regex and error handling */
- while ((r = setup_func(settings, &setting, &desc)) > 0) {
+ while ((r = setup_func(settings, &setting, &desc, res_setup)) > 0) {
additions++;
/* if setup_func() has returned a description for an undescribed preexisting setting,
diff --git a/src/setup.h b/src/setup.h
index 2c79fed..a32f57c 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -3,6 +3,6 @@
#include "til_settings.h"
-int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults);
+int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup), int defaults, void **res_setup);
#endif
diff --git a/src/til.c b/src/til.c
index 4d7ef63..3cbd294 100644
--- a/src/til.c
+++ b/src/til.c
@@ -144,7 +144,7 @@ void til_module_render(const til_module_t *module, void *context, unsigned ticks
}
-int til_module_create_context(const til_module_t *module, unsigned ticks, void **res_context)
+int til_module_create_context(const til_module_t *module, unsigned ticks, void *setup, void **res_context)
{
void *context;
@@ -154,7 +154,7 @@ int til_module_create_context(const til_module_t *module, unsigned ticks, void *
if (!module->create_context)
return 0;
- context = module->create_context(ticks, til_threads_num_threads(til_threads));
+ context = module->create_context(ticks, til_threads_num_threads(til_threads), setup);
if (!context)
return -ENOMEM;
@@ -178,7 +178,7 @@ void * til_module_destroy_context(const til_module_t *module, void *context)
/* select module if not yet selected, then setup the module. */
-int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
til_setting_t *setting;
const til_module_t *module;
@@ -217,7 +217,7 @@ int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, cons
return -EINVAL;
if (module->setup)
- return module->setup(settings, res_setting, res_desc);
+ return module->setup(settings, res_setting, res_desc, res_setup);
return 0;
}
diff --git a/src/til.h b/src/til.h
index 6c6c745..29bbb2c 100644
--- a/src/til.h
+++ b/src/til.h
@@ -12,12 +12,12 @@ typedef struct til_setting_desc_t til_setting_desc_t;
typedef struct til_knob_t til_knob_t;
typedef struct til_module_t {
- void * (*create_context)(unsigned ticks, unsigned n_cpus);
+ void * (*create_context)(unsigned ticks, unsigned n_cpus, void *setup);
void (*destroy_context)(void *context);
void (*prepare_frame)(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter);
void (*render_fragment)(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment);
void (*finish_frame)(void *context, unsigned ticks, til_fb_fragment_t *fragment);
- int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+ int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
size_t (*knobs)(void *context, til_knob_t **res_knobs);
char *name;
char *description;
@@ -30,8 +30,8 @@ void til_shutdown(void);
const til_module_t * til_lookup_module(const char *name);
void til_get_modules(const til_module_t ***res_modules, size_t *res_n_modules);
void til_module_render(const til_module_t *module, void *context, unsigned ticks, til_fb_fragment_t *fragment);
-int til_module_create_context(const til_module_t *module, unsigned ticks, void **res_context);
+int til_module_create_context(const til_module_t *module, unsigned ticks, void *setup, void **res_context);
void * til_module_destroy_context(const til_module_t *module, void *context);
-int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
#endif
diff --git a/src/til_fb.h b/src/til_fb.h
index f6a2972..bc553c6 100644
--- a/src/til_fb.h
+++ b/src/til_fb.h
@@ -35,7 +35,7 @@ typedef struct til_fb_t til_fb_t;
/* Supply this struct to fb_new() with the appropriate context */
typedef struct til_fb_ops_t {
- int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+ int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
int (*init)(const til_settings_t *settings, void **res_context);
void (*shutdown)(til_fb_t *fb, void *context);
int (*acquire)(til_fb_t *fb, void *context, void *page);
© All Rights Reserved