summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c8
-rw-r--r--src/modules/blinds/blinds.c6
-rw-r--r--src/modules/checkers/checkers.c12
-rw-r--r--src/modules/compose/compose.c22
-rw-r--r--src/modules/drizzle/drizzle.c10
-rw-r--r--src/modules/flui2d/flui2d.c8
-rw-r--r--src/modules/julia/julia.c8
-rw-r--r--src/modules/meta2d/meta2d.c8
-rw-r--r--src/modules/moire/moire.c8
-rw-r--r--src/modules/montage/montage.c18
-rw-r--r--src/modules/pixbounce/pixbounce.c6
-rw-r--r--src/modules/plasma/plasma.c8
-rw-r--r--src/modules/plato/plato.c10
-rw-r--r--src/modules/ray/ray.c10
-rw-r--r--src/modules/roto/roto.c8
-rw-r--r--src/modules/rtv/rtv.c20
-rw-r--r--src/modules/shapes/shapes.c6
-rw-r--r--src/modules/snow/snow.c8
-rw-r--r--src/modules/sparkler/sparkler.c8
-rw-r--r--src/modules/spiro/spiro.c6
-rw-r--r--src/modules/stars/stars.c16
-rw-r--r--src/modules/strobe/strobe.c10
-rw-r--r--src/modules/submit/submit.c8
-rw-r--r--src/modules/swab/swab.c8
-rw-r--r--src/modules/swarm/swarm.c6
-rw-r--r--src/modules/voronoi/voronoi.c8
-rw-r--r--src/til.c26
-rw-r--r--src/til.h17
-rw-r--r--src/til_fb.h2
-rw-r--r--src/til_module_context.c15
-rw-r--r--src/til_module_context.h4
-rw-r--r--src/til_threads.c10
-rw-r--r--src/til_threads.h3
33 files changed, 173 insertions, 158 deletions
diff --git a/src/main.c b/src/main.c
index 5b2024d..37fef55 100644
--- a/src/main.c
+++ b/src/main.c
@@ -331,10 +331,9 @@ static void * rototiller_thread(void *_rt)
unsigned ticks;
fragment = til_fb_page_get(rt->fb);
- fragment->stream = rt->stream;
gettimeofday(&now, NULL);
ticks = get_ticks(&rt->start_tv, &now, rt->ticks_offset);
- til_module_render(rt->module_context, ticks, &fragment);
+ til_module_render(rt->module_context, rt->stream, ticks, &fragment);
til_fb_fragment_submit(fragment);
if (rt->args.print_pipes) /* render threads are idle at this point */
@@ -389,8 +388,9 @@ int main(int argc, const char *argv[])
"unable to setup fps counter");
gettimeofday(&rototiller.start_tv, NULL);
- exit_if((r = til_module_create_context(
- rototiller.module, setup.seed,
+ exit_if((r = til_module_create_context( rototiller.module,
+ rototiller.stream,
+ setup.seed,
get_ticks(&rototiller.start_tv,
&rototiller.start_tv,
rototiller.ticks_offset),
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c
index 890b569..b0aebdb 100644
--- a/src/modules/blinds/blinds.c
+++ b/src/modules/blinds/blinds.c
@@ -37,14 +37,14 @@ static blinds_setup_t blinds_default_setup = {
};
-static til_module_context_t * blinds_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * blinds_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
blinds_context_t *ctxt;
if (!setup)
setup = &blinds_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(blinds_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(blinds_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -83,7 +83,7 @@ static inline void draw_blind_vertical(til_fb_fragment_t *fragment, unsigned col
/* draw blinds over the fragment */
-static void blinds_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void blinds_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
blinds_context_t *ctxt = (blinds_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c
index b7a4f11..c4a419f 100644
--- a/src/modules/checkers/checkers.c
+++ b/src/modules/checkers/checkers.c
@@ -79,7 +79,7 @@ static checkers_setup_t checkers_default_setup = {
};
-static til_module_context_t * checkers_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * checkers_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
size_t size = sizeof(checkers_context_t);
checkers_context_t *ctxt;
@@ -90,7 +90,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti
if (((checkers_setup_t *)setup)->fill_module)
size += sizeof(til_module_context_t *) * n_cpus;
- ctxt = til_module_context_new(size, ticks, seed, n_cpus, path);
+ ctxt = til_module_context_new(stream, size, ticks, seed, n_cpus, path);
if (!ctxt)
return NULL;
@@ -104,7 +104,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti
/* since checkers is already threaded, create an n_cpus=1 context per-cpu */
for (unsigned i = 0; i < n_cpus; i++) /* TODO: errors */
- (void) til_module_create_context(module, seed, ticks, 1, path /* FIXME TODO path-per-context breaks down on these per-cpu-context abuses */, module_setup, &ctxt->fill_module_contexts[i]);
+ (void) til_module_create_context(module, stream, seed, ticks, 1, path /* FIXME TODO path-per-context breaks down on these per-cpu-context abuses */, module_setup, &ctxt->fill_module_contexts[i]);
/* XXX: it would be interesting to support various patterns/layouts by varying the seed, but this will require
* more complex context allocation strategies while also maintaining the per-cpu allocation.
@@ -227,7 +227,7 @@ static int checkers_fragmenter(til_module_context_t *context, const til_fb_fragm
}
-static void checkers_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void checkers_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
checkers_context_t *ctxt = (checkers_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -255,7 +255,7 @@ static inline unsigned hash(unsigned x)
}
-static void checkers_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void checkers_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
checkers_context_t *ctxt = (checkers_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -323,7 +323,7 @@ static void checkers_render_fragment(til_module_context_t *context, unsigned tic
til_fb_fragment_fill(fragment, flags, color);
else {
/* TODO: we need a way to send down color and flags, and use the module render as a brush of sorts */
- til_module_render(ctxt->fill_module_contexts[cpu], ticks, fragment_ptr);
+ til_module_render(ctxt->fill_module_contexts[cpu], stream, ticks, fragment_ptr);
}
}
}
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index a73f2b7..92f6fd2 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -47,9 +47,9 @@ typedef struct compose_setup_t {
char *layers[];
} compose_setup_t;
-static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
+static til_module_context_t * compose_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void compose_destroy_context(til_module_context_t *context);
-static void compose_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+static void compose_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
static compose_setup_t compose_default_setup = {
@@ -67,7 +67,7 @@ til_module_t compose_module = {
};
-static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * compose_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
compose_context_t *ctxt;
size_t n;
@@ -77,7 +77,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
for (n = 0; ((compose_setup_t *)setup)->layers[n]; n++);
- ctxt = til_module_context_new(sizeof(compose_context_t) + n * sizeof(compose_layer_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(compose_context_t) + n * sizeof(compose_layer_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -89,7 +89,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
(void) til_module_randomize_setup(layer_module, rand_r(&seed), &layer_setup, NULL);
ctxt->layers[i].module = layer_module;
- (void) til_module_create_context(layer_module, rand_r(&seed), ticks, 0, path, layer_setup, &ctxt->layers[i].module_ctxt);
+ (void) til_module_create_context(layer_module, stream, rand_r(&seed), ticks, 0, path, layer_setup, &ctxt->layers[i].module_ctxt);
til_setup_free(layer_setup);
ctxt->n_layers++;
@@ -101,7 +101,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
ctxt->texture.module = til_lookup_module(((compose_setup_t *)setup)->texture);
(void) til_module_randomize_setup(ctxt->texture.module, rand_r(&seed), &texture_setup, NULL);
- (void) til_module_create_context(ctxt->texture.module, rand_r(&seed), ticks, 0, path, texture_setup, &ctxt->texture.module_ctxt);
+ (void) til_module_create_context(ctxt->texture.module, stream, rand_r(&seed), ticks, 0, path, texture_setup, &ctxt->texture.module_ctxt);
til_setup_free(texture_setup);
}
@@ -125,7 +125,7 @@ static void compose_destroy_context(til_module_context_t *context)
}
-static void compose_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void compose_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
compose_context_t *ctxt = (compose_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr, *texture = &ctxt->texture_fb;
@@ -149,17 +149,17 @@ static void compose_render_fragment(til_module_context_t *context, unsigned tick
ctxt->texture_fb.cleared = 0;
/* XXX: if when snapshotting becomes a thing, ctxt->texture_fb is snapshottable, this will likely break as-is */
- til_module_render(ctxt->texture.module_ctxt, ticks, &texture);
- til_module_render(ctxt->layers[0].module_ctxt, ticks, &fragment);
+ til_module_render(ctxt->texture.module_ctxt, stream, ticks, &texture);
+ til_module_render(ctxt->layers[0].module_ctxt, stream, ticks, &fragment);
for (size_t i = 1; i < ctxt->n_layers; i++) {
fragment->texture = texture; /* keep forcing our texture, in case something below us installed their own. */
- til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment);
+ til_module_render(ctxt->layers[i].module_ctxt, stream, ticks, &fragment);
}
} else {
for (size_t i = 0; i < ctxt->n_layers; i++) {
fragment->texture = NULL; /* keep forcing no texture, in case something below us installed their own. TODO: more formally define texture semantics as it pertains to module nesting */
- til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment);
+ til_module_render(ctxt->layers[i].module_ctxt, stream, ticks, &fragment);
}
}
diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c
index e5b79eb..307e0d3 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -85,14 +85,14 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * drizzle_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * drizzle_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
drizzle_context_t *ctxt;
if (!setup)
setup = &drizzle_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(drizzle_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(drizzle_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -117,7 +117,7 @@ static void drizzle_destroy_context(til_module_context_t *context)
}
-static void drizzle_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void drizzle_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
drizzle_context_t *ctxt = (drizzle_context_t *)context;
@@ -249,7 +249,7 @@ static void puddle_sample_normal(const puddle_t *puddle, const v2f_t *coordinate
}
-static void drizzle_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void drizzle_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
drizzle_context_t *ctxt = (drizzle_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -329,7 +329,7 @@ static void drizzle_render_fragment(til_module_context_t *context, unsigned tick
}
-static void drizzle_finish_frame(til_module_context_t *context, unsigned int ticks, til_fb_fragment_t **fragment_ptr)
+static void drizzle_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr)
{
drizzle_context_t *ctxt = (drizzle_context_t *)context;
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index 4b75520..9ae3e94 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -245,7 +245,7 @@ static void gamma_init(float gamma)
}
-static til_module_context_t * flui2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * flui2d_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
flui2d_context_t *ctxt;
@@ -253,7 +253,7 @@ static til_module_context_t * flui2d_create_context(unsigned seed, unsigned tick
if (!setup)
setup = &flui2d_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(flui2d_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(flui2d_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -273,7 +273,7 @@ static til_module_context_t * flui2d_create_context(unsigned seed, unsigned tick
/* Prepare a frame for concurrent drawing of fragment using multiple fragments */
-static void flui2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void flui2d_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
flui2d_context_t *ctxt = (flui2d_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -334,7 +334,7 @@ static void flui2d_prepare_frame(til_module_context_t *context, unsigned ticks,
/* Draw a the flui2d densities */
-static void flui2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void flui2d_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
flui2d_context_t *ctxt = (flui2d_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c
index 0dcefe5..65a15b6 100644
--- a/src/modules/julia/julia.c
+++ b/src/modules/julia/julia.c
@@ -67,11 +67,11 @@ static uint32_t colors[] = {
};
-static til_module_context_t * julia_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * julia_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
julia_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(julia_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(julia_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -106,7 +106,7 @@ static inline unsigned julia_iter(float real, float imag, float creal, float cim
/* Prepare a frame for concurrent drawing of fragment using multiple fragments */
-static void julia_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void julia_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
julia_context_t *ctxt = (julia_context_t *)context;
@@ -133,7 +133,7 @@ static void julia_prepare_frame(til_module_context_t *context, unsigned ticks, t
/* Draw a morphing Julia set */
-static void julia_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void julia_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
julia_context_t *ctxt = (julia_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c
index 978f32f..6d9d307 100644
--- a/src/modules/meta2d/meta2d.c
+++ b/src/modules/meta2d/meta2d.c
@@ -67,11 +67,11 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * meta2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * meta2d_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
meta2d_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(meta2d_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(meta2d_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -101,7 +101,7 @@ static void meta2d_destroy_context(til_module_context_t *context)
}
-static void meta2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void meta2d_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
meta2d_context_t *ctxt = (meta2d_context_t *)context;
@@ -178,7 +178,7 @@ static void meta2d_prepare_frame(til_module_context_t *context, unsigned ticks,
}
-static void meta2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void meta2d_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
meta2d_context_t *ctxt = (meta2d_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c
index 9bf782c..b010cdd 100644
--- a/src/modules/moire/moire.c
+++ b/src/modules/moire/moire.c
@@ -47,14 +47,14 @@ static moire_setup_t moire_default_setup = {
};
-static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * moire_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
moire_context_t *ctxt;
if (!setup)
setup = &moire_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(moire_context_t) + ((moire_setup_t *)setup)->n_centers * sizeof(moire_center_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(moire_context_t) + ((moire_setup_t *)setup)->n_centers * sizeof(moire_center_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -71,7 +71,7 @@ static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks
}
-static void moire_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void moire_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
moire_context_t *ctxt = (moire_context_t *)context;
@@ -84,7 +84,7 @@ static void moire_prepare_frame(til_module_context_t *context, unsigned ticks, t
}
-static void moire_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void moire_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
moire_context_t *ctxt = (moire_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 6697bc5..3ab944f 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -16,10 +16,10 @@ typedef struct montage_context_t {
size_t n_modules;
} montage_context_t;
-static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
+static til_module_context_t * montage_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void montage_destroy_context(til_module_context_t *context);
-static void montage_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
-static void montage_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+static void montage_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
+static void montage_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
til_module_t montage_module = {
@@ -32,13 +32,13 @@ til_module_t montage_module = {
};
-static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * montage_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
const til_module_t **modules, *rtv_module, *compose_module;
size_t n_modules;
montage_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(montage_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(montage_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -92,7 +92,7 @@ static til_module_context_t * montage_create_context(unsigned seed, unsigned tic
(void) til_module_randomize_setup(module, rand_r(&seed), &setup, NULL);
/* FIXME errors */
- (void) til_module_create_context(module, rand_r(&seed), ticks, 1, path, setup, &ctxt->contexts[i]);
+ (void) til_module_create_context(module, stream, rand_r(&seed), ticks, 1, path, setup, &ctxt->contexts[i]);
til_setup_free(setup);
}
@@ -210,13 +210,13 @@ static int montage_fragmenter(til_module_context_t *context, const til_fb_fragme
}
-static void montage_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void montage_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
*res_frame_plan = (til_frame_plan_t){ .fragmenter = montage_fragmenter };
}
-static void montage_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void montage_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
montage_context_t *ctxt = (montage_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -227,5 +227,5 @@ static void montage_render_fragment(til_module_context_t *context, unsigned tick
return;
}
- til_module_render(ctxt->contexts[fragment->number], ticks, fragment_ptr);
+ til_module_render(ctxt->contexts[fragment->number], stream, ticks, fragment_ptr);
}
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index f10bd5b..8a26be2 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -240,11 +240,11 @@ static uint32_t pick_color(unsigned *seedp)
return makergb(rand_r(seedp)%256, rand_r(seedp)%256, rand_r(seedp)%256, 1);
}
-static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * pixbounce_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
pixbounce_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(pixbounce_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(pixbounce_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -260,7 +260,7 @@ static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned t
return &ctxt->til_module_context;
}
-static void pixbounce_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void pixbounce_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
pixbounce_context_t *ctxt = (pixbounce_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c
index f49b396..c42efd2 100644
--- a/src/modules/plasma/plasma.c
+++ b/src/modules/plasma/plasma.c
@@ -53,7 +53,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab)
}
-static til_module_context_t * plasma_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * plasma_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
plasma_context_t *ctxt;
@@ -64,7 +64,7 @@ static til_module_context_t * plasma_create_context(unsigned seed, unsigned tick
init_plasma(costab, sintab);
}
- ctxt = til_module_context_new(sizeof(plasma_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(plasma_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -75,7 +75,7 @@ static til_module_context_t * plasma_create_context(unsigned seed, unsigned tick
/* Prepare a frame for concurrent drawing of fragment using multiple fragments */
-static void plasma_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void plasma_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
plasma_context_t *ctxt = (plasma_context_t *)context;
@@ -85,7 +85,7 @@ static void plasma_prepare_frame(til_module_context_t *context, unsigned ticks,
/* Draw a plasma effect */
-static void plasma_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void plasma_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
plasma_context_t *ctxt = (plasma_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index 1dc56a3..4334eda 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -630,11 +630,11 @@ static void draw_polyhedron(const polyhedron_t *polyhedron, m4f_t *transform, ti
}
-static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * plato_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
plato_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(plato_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(plato_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -647,14 +647,14 @@ static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks
}
-static void plato_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void plato_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
plato_context_t *ctxt = (plato_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
/* since we don't automate the rates ourselves, we don't care about the tap return values */
- (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.orbit_rate);
- (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.spin_rate);
+ (void) til_stream_tap_context(stream, context, &ctxt->taps.orbit_rate);
+ (void) til_stream_tap_context(stream, context, &ctxt->taps.spin_rate);
ctxt->r += (float)(ticks - context->ticks) * (*ctxt->orbit_rate * .001f);
ctxt->rr += (float)(ticks - context->ticks) * (*ctxt->spin_rate * .001f);
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index e3887b6..0017da3 100644
--- a/src/modules/ray/ray.c
+++ b/src/modules/ray/ray.c
@@ -132,11 +132,11 @@ typedef struct ray_context_t {
} ray_context_t;
-static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * ray_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
ray_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(ray_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(ray_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -145,7 +145,7 @@ static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks,
/* prepare a frame for concurrent rendering */
-static void ray_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void ray_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
ray_context_t *ctxt = (ray_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -178,7 +178,7 @@ static void ray_prepare_frame(til_module_context_t *context, unsigned ticks, til
/* ray trace a simple scene into the fragment */
-static void ray_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void ray_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
ray_context_t *ctxt = (ray_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -187,7 +187,7 @@ static void ray_render_fragment(til_module_context_t *context, unsigned ticks, u
}
-static void ray_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr)
+static void ray_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr)
{
ray_context_t *ctxt = (ray_context_t *)context;
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c
index c5106ab..1b20e2e 100644
--- a/src/modules/roto/roto.c
+++ b/src/modules/roto/roto.c
@@ -62,7 +62,7 @@ static void init_roto(uint8_t texture[256][256], int32_t *costab, int32_t *sinta
}
-static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * roto_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
roto_context_t *ctxt;
@@ -73,7 +73,7 @@ static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks,
init_roto(texture, costab, sintab);
}
- ctxt = til_module_context_new(sizeof(roto_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(roto_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -182,7 +182,7 @@ static uint32_t bilerp_color(uint8_t texture[256][256], color_t *palette, int tx
/* prepare a frame for concurrent rendering */
-static void roto_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void roto_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
roto_context_t *ctxt = (roto_context_t *)context;
@@ -208,7 +208,7 @@ static void roto_prepare_frame(til_module_context_t *context, unsigned ticks, ti
/* Draw a rotating checkered 256x256 texture into fragment. */
-static void roto_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void roto_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
roto_context_t *ctxt = (roto_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index a8cac2a..b7f500a 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -61,10 +61,10 @@ typedef struct rtv_setup_t {
} rtv_setup_t;
static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks);
-static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
+static til_module_context_t * rtv_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void rtv_destroy_context(til_module_context_t *context);
-static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
-static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr);
+static void rtv_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+static void rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr);
static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
static rtv_setup_t rtv_default_setup = {
@@ -188,7 +188,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, rand_r(&ctxt->til_module_context.seed), ticks, 0, ctxt->til_module_context.path, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
+ (void) til_module_create_context(ctxt->channel->module, ctxt->til_module_context.stream, rand_r(&ctxt->til_module_context.seed), ticks, 0, ctxt->til_module_context.path, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
ctxt->channel->last_on_time = now;
}
@@ -215,7 +215,7 @@ static int rtv_should_skip_module(const rtv_setup_t *setup, const til_module_t *
}
-static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * rtv_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
rtv_context_t *ctxt;
const til_module_t **modules;
@@ -232,7 +232,7 @@ static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks,
n_channels++;
}
- ctxt = til_module_context_new(sizeof(rtv_context_t) + n_channels * sizeof(rtv_channel_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(rtv_context_t) + n_channels * sizeof(rtv_channel_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -244,7 +244,7 @@ static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks,
ctxt->snow_channel.module = &rtv_none_module;
if (((rtv_setup_t *)setup)->snow_module) {
ctxt->snow_channel.module = til_lookup_module(((rtv_setup_t *)setup)->snow_module);
- (void) til_module_create_context(ctxt->snow_channel.module, rand_r(&seed), ticks, 0, path, NULL, &ctxt->snow_channel.module_ctxt);
+ (void) til_module_create_context(ctxt->snow_channel.module, stream, rand_r(&seed), ticks, 0, path, NULL, &ctxt->snow_channel.module_ctxt);
}
for (size_t i = 0; i < n_modules; i++) {
@@ -268,7 +268,7 @@ static void rtv_destroy_context(til_module_context_t *context)
}
-static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void rtv_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
rtv_context_t *ctxt = (rtv_context_t *)context;
time_t now = time(NULL);
@@ -279,11 +279,11 @@ static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, u
if (now >= ctxt->next_hide_caption)
ctxt->caption = NULL;
- til_module_render(ctxt->channel->module_ctxt, ticks, fragment_ptr);
+ til_module_render(ctxt->channel->module_ctxt, stream, ticks, fragment_ptr);
}
-static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr)
+static void rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr)
{
rtv_context_t *ctxt = (rtv_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c
index 65a13fa..1be9f03 100644
--- a/src/modules/shapes/shapes.c
+++ b/src/modules/shapes/shapes.c
@@ -98,14 +98,14 @@ static shapes_setup_t shapes_default_setup = {
};
-static til_module_context_t * shapes_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * shapes_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
shapes_context_t *ctxt;
if (!setup)
setup = &shapes_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(shapes_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(shapes_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -115,7 +115,7 @@ static til_module_context_t * shapes_create_context(unsigned seed, unsigned tick
}
-static void shapes_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void shapes_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
shapes_context_t *ctxt = (shapes_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c
index 9a86689..bcf1cc4 100644
--- a/src/modules/snow/snow.c
+++ b/src/modules/snow/snow.c
@@ -22,11 +22,11 @@ typedef struct snow_context_t {
} snow_context_t;
-static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * snow_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
snow_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -37,13 +37,13 @@ static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks,
}
-static void snow_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void snow_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
*res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu };
}
-static void snow_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void snow_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
snow_context_t *ctxt = (snow_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index 1a2c8bb..afe4f0f 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -35,14 +35,14 @@ extern particle_ops_t simple_ops;
static sparkler_setup_t sparkler_default_setup;
-static til_module_context_t * sparkler_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * sparkler_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
sparkler_context_t *ctxt;
if (!setup)
setup = &sparkler_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(sparkler_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(sparkler_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -75,7 +75,7 @@ static void sparkler_destroy_context(til_module_context_t *context)
}
-static void sparkler_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void sparkler_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
sparkler_context_t *ctxt = (sparkler_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -92,7 +92,7 @@ static void sparkler_prepare_frame(til_module_context_t *context, unsigned ticks
/* Render a 3D particle system */
-static void sparkler_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void sparkler_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
sparkler_context_t *ctxt = (sparkler_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 236dd4a..ab11aab 100644
--- a/src/modules/spiro/spiro.c
+++ b/src/modules/spiro/spiro.c
@@ -31,12 +31,12 @@ typedef struct spiro_context_t {
} spiro_context_t;
-static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * spiro_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
spiro_context_t *ctxt;
float z;
- ctxt = til_module_context_new(sizeof(spiro_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(spiro_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -53,7 +53,7 @@ static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks
return &ctxt->til_module_context;
}
-static void spiro_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void spiro_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
spiro_context_t *ctxt = (spiro_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 82619d7..26f2913 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -70,7 +70,7 @@ float get_random_unit_coord(unsigned *seed) {
}
-static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * stars_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
stars_context_t *ctxt;
float z;
@@ -79,7 +79,7 @@ static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks
if (!setup)
setup = &stars_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(stars_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(stars_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -131,7 +131,7 @@ static void stars_destroy_context(til_module_context_t *context)
}
-static void stars_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void stars_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
stars_context_t *ctxt = (stars_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -223,10 +223,10 @@ static void stars_render_fragment(til_module_context_t *context, unsigned ticks,
ctxt->points = tmp_ptr;
}
- if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.rot_angle))
+ if (!til_stream_tap_context(stream, context, &ctxt->taps.rot_angle))
*ctxt->rot_angle+=*ctxt->rot_rate;
- if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.rot_rate)) {
+ if (!til_stream_tap_context(stream, context, &ctxt->taps.rot_rate)) {
// handle rotation parameters
if(*ctxt->rot_angle>M_PI_4)
*ctxt->rot_rate=*ctxt->rot_rate-ctxt->rot_adj;
@@ -235,16 +235,16 @@ static void stars_render_fragment(til_module_context_t *context, unsigned ticks,
}
/* there's no automation of offset_angle */
- (void) til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_angle);
+ (void) til_stream_tap_context(stream, context, &ctxt->taps.offset_angle);
// handle offset parameters
- if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_x)) {
+ if (!til_stream_tap_context(stream, context, &ctxt->taps.offset_x)) {
float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle))-
(*ctxt->offset_y*sinf(*ctxt->offset_angle));
*ctxt->offset_x = tmp_x;
}
- if (!til_stream_tap_context(fragment->stream, context, &ctxt->taps.offset_y)) {
+ if (!til_stream_tap_context(stream, context, &ctxt->taps.offset_y)) {
float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle))+
(*ctxt->offset_y*cosf(*ctxt->offset_angle));
*ctxt->offset_y = tmp_y;
diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c
index bc0c365..5410ffb 100644
--- a/src/modules/strobe/strobe.c
+++ b/src/modules/strobe/strobe.c
@@ -40,14 +40,14 @@ static strobe_setup_t strobe_default_setup = {
};
-static til_module_context_t * strobe_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * strobe_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
strobe_context_t *ctxt;
if (!setup)
setup = &strobe_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(strobe_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(strobe_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -58,7 +58,7 @@ static til_module_context_t * strobe_create_context(unsigned seed, unsigned tick
}
-static void strobe_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void strobe_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
strobe_context_t *ctxt = (strobe_context_t *)context;
@@ -73,7 +73,7 @@ static void strobe_prepare_frame(til_module_context_t *context, unsigned ticks,
}
-static void strobe_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void strobe_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
strobe_context_t *ctxt = (strobe_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -85,7 +85,7 @@ static void strobe_render_fragment(til_module_context_t *context, unsigned ticks
}
-static void strobe_finish_frame(til_module_context_t *context, unsigned int ticks, til_fb_fragment_t **fragment_ptr)
+static void strobe_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr)
{
strobe_context_t *ctxt = (strobe_context_t *)context;
diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c
index f46a205..b3c7220 100644
--- a/src/modules/submit/submit.c
+++ b/src/modules/submit/submit.c
@@ -267,14 +267,14 @@ static void setup_grid(submit_context_t *ctxt)
}
-static til_module_context_t * submit_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * submit_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
submit_context_t *ctxt;
if (!setup)
setup = &submit_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(submit_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(submit_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -294,7 +294,7 @@ static void submit_destroy_context(til_module_context_t *context)
}
-static void submit_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void submit_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
submit_context_t *ctxt = (submit_context_t *)context;
@@ -317,7 +317,7 @@ static void submit_prepare_frame(til_module_context_t *context, unsigned ticks,
}
-static void submit_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void submit_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
submit_context_t *ctxt = (submit_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c
index b7ccf9d..0465de7 100644
--- a/src/modules/swab/swab.c
+++ b/src/modules/swab/swab.c
@@ -66,11 +66,11 @@ static inline uint32_t color_to_uint32(color_t color) {
}
-static til_module_context_t * swab_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * swab_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
swab_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(swab_context_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(swab_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -93,7 +93,7 @@ static void swab_destroy_context(til_module_context_t *context)
}
-static void swab_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void swab_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
swab_context_t *ctxt = (swab_context_t *)context;
@@ -103,7 +103,7 @@ static void swab_prepare_frame(til_module_context_t *context, unsigned ticks, ti
}
-static void swab_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void swab_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
swab_context_t *ctxt = (swab_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index 48b70aa..5a58210 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -181,14 +181,14 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * swarm_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * swarm_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
swarm_context_t *ctxt;
if (!setup)
setup = &swarm_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -401,7 +401,7 @@ static void swarm_draw_as_lines(swarm_context_t *ctxt, til_fb_fragment_t *fragme
}
-static void swarm_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void swarm_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
swarm_context_t *ctxt = (swarm_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c
index bf82ca3..647871b 100644
--- a/src/modules/voronoi/voronoi.c
+++ b/src/modules/voronoi/voronoi.c
@@ -80,14 +80,14 @@ static void voronoi_randomize(voronoi_context_t *ctxt)
}
-static til_module_context_t * voronoi_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
+static til_module_context_t * voronoi_create_context(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
voronoi_context_t *ctxt;
if (!setup)
setup = &voronoi_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(voronoi_context_t) + ((voronoi_setup_t *)setup)->n_cells * sizeof(voronoi_cell_t), seed, ticks, n_cpus, path);
+ ctxt = til_module_context_new(stream, sizeof(voronoi_context_t) + ((voronoi_setup_t *)setup)->n_cells * sizeof(voronoi_cell_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -281,7 +281,7 @@ static void voronoi_sample_colors(voronoi_context_t *ctxt, til_fb_fragment_t *fr
}
-static void voronoi_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void voronoi_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
voronoi_context_t *ctxt = (voronoi_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
@@ -315,7 +315,7 @@ static void voronoi_prepare_frame(til_module_context_t *context, unsigned ticks,
}
-static void voronoi_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void voronoi_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
voronoi_context_t *ctxt = (voronoi_context_t *)context;
til_fb_fragment_t *fragment = *fragment_ptr;
diff --git a/src/til.c b/src/til.c
index 9435e28..44d48eb 100644
--- a/src/til.c
+++ b/src/til.c
@@ -102,13 +102,13 @@ void til_shutdown(void)
}
-static void _blank_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
+static void _blank_prepare_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan)
{
*res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu };
}
-static void _blank_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
+static void _blank_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr)
{
til_fb_fragment_clear(*fragment_ptr);
}
@@ -164,7 +164,7 @@ void til_get_modules(const til_module_t ***res_modules, size_t *res_n_modules)
}
-static void module_render_fragment(til_module_context_t *context, til_threads_t *threads, unsigned ticks, til_fb_fragment_t **fragment_ptr)
+static void module_render_fragment(til_module_context_t *context, til_stream_t *stream, til_threads_t *threads, unsigned ticks, til_fb_fragment_t **fragment_ptr)
{
const til_module_t *module;
@@ -178,7 +178,7 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t
if (module->prepare_frame) {
til_frame_plan_t frame_plan = {};
- module->prepare_frame(context, ticks, fragment_ptr, &frame_plan);
+ module->prepare_frame(context, stream, ticks, fragment_ptr, &frame_plan);
/* XXX: any module which provides prepare_frame() must return a frame_plan.fragmenter,
* and provide render_fragment()
@@ -187,7 +187,7 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t
assert(module->render_fragment);
if (context->n_cpus > 1) {
- til_threads_frame_submit(threads, fragment_ptr, &frame_plan, module->render_fragment, context, ticks);
+ til_threads_frame_submit(threads, fragment_ptr, &frame_plan, module->render_fragment, context, stream, ticks);
til_threads_wait_idle(threads);
} else {
unsigned fragnum = 0;
@@ -197,13 +197,13 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t
frag.texture = &texture; /* fragmenter needs the space */
while (frame_plan.fragmenter(context, *fragment_ptr, fragnum++, &frag))
- module->render_fragment(context, ticks, 0, &frag_ptr);
+ module->render_fragment(context, stream, ticks, 0, &frag_ptr);
}
} else if (module->render_fragment)
- module->render_fragment(context, ticks, 0, fragment_ptr);
+ module->render_fragment(context, stream, ticks, 0, fragment_ptr);
if (module->finish_frame)
- module->finish_frame(context, ticks, fragment_ptr);
+ module->finish_frame(context, stream, ticks, fragment_ptr);
(*fragment_ptr)->cleared = 1;
}
@@ -212,9 +212,9 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t
/* This is a public interface to the threaded module rendering intended for use by
* modules that wish to get the output of other modules for their own use.
*/
-void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr)
+void til_module_render(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr)
{
- module_render_fragment(context, til_threads, ticks, fragment_ptr);
+ module_render_fragment(context, stream, til_threads, ticks, fragment_ptr);
}
@@ -223,7 +223,7 @@ void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fra
* the purpose of explicitly constraining rendering parallelization to less than n_threads,
* if n_cpus is specified > n_threads it won't increase n_threads...
*/
-int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context)
+int til_module_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context)
{
til_module_context_t *context;
char *path;
@@ -248,9 +248,9 @@ int til_module_create_context(const til_module_t *module, unsigned seed, unsigne
n_cpus = til_threads_num_threads(til_threads);
if (!module->create_context)
- context = til_module_context_new(sizeof(til_module_context_t), seed, ticks, n_cpus, path);
+ context = til_module_context_new(stream, sizeof(til_module_context_t), seed, ticks, n_cpus, path);
else
- context = module->create_context(seed, ticks, n_cpus, path, setup);
+ context = module->create_context(stream, seed, ticks, n_cpus, path, setup);
if (!context) {
free(path);
diff --git a/src/til.h b/src/til.h
index 852cb96..b863868 100644
--- a/src/til.h
+++ b/src/til.h
@@ -18,15 +18,16 @@ typedef struct til_frame_plan_t {
typedef struct til_settings_t settings;
typedef struct til_setting_desc_t til_setting_desc_t;
typedef struct til_knob_t til_knob_t;
+typedef struct til_stream_t til_stream_t;
#define TIL_MODULE_OVERLAYABLE 1u
typedef struct til_module_t {
- til_module_context_t * (*create_context)(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
- void (*destroy_context)(til_module_context_t *context);
- void (*prepare_frame)(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
- void (*render_fragment)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
- void (*finish_frame)(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr);
+ til_module_context_t * (*create_context)(til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
+ void (*destroy_context)(til_module_context_t *context); /* destroy gets stream in context, but the render-related functions should always use the passed-in stream so it can potentially change */
+ void (*prepare_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
+ void (*render_fragment)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+ void (*finish_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr);
int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
size_t (*knobs)(til_module_context_t *context, til_knob_t **res_knobs);
char *name;
@@ -40,9 +41,9 @@ void til_quiesce(void);
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(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr);
-int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context);
-til_module_context_t * til_module_destroy_context(til_module_context_t *context);
+void til_module_render(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr);
+int til_module_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context);
+til_module_context_t * til_module_destroy_context(til_module_context_t *context, til_stream_t *stream);
int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
int til_module_randomize_setup(const til_module_t *module, unsigned seed, til_setup_t **res_setup, char **res_arg);
int til_fragmenter_slice_per_cpu(til_module_context_t *context, const til_fb_fragment_t *fragment, unsigned number, til_fb_fragment_t *res_fragment);
diff --git a/src/til_fb.h b/src/til_fb.h
index 48113d7..80ffeb4 100644
--- a/src/til_fb.h
+++ b/src/til_fb.h
@@ -9,7 +9,6 @@
#include "til_setup.h"
#include "til_util.h"
-typedef struct til_stream_t til_stream_t;
typedef struct til_fb_fragment_t til_fb_fragment_t;
typedef struct til_fb_fragment_ops_t til_fb_fragment_ops_t;
@@ -22,7 +21,6 @@ typedef struct til_fb_fragment_ops_t til_fb_fragment_ops_t;
typedef struct til_fb_fragment_t {
const til_fb_fragment_ops_t *ops; /* optional opaque ops for physical fragments, NULL for strictly logical fragments */
- til_stream_t *stream; /* optional stream of continuity this fragment participates in */
til_fb_fragment_t *texture; /* optional source texture when drawing to this fragment */
uint32_t *buf; /* pointer to the first pixel in the fragment */
unsigned x, y; /* absolute coordinates of the upper left corner of this fragment */
diff --git a/src/til_module_context.c b/src/til_module_context.c
index 9767d96..58de3d5 100644
--- a/src/til_module_context.c
+++ b/src/til_module_context.c
@@ -6,6 +6,7 @@
#include "til.h"
#include "til_jenkins.h"
#include "til_module_context.h"
+#include "til_stream.h"
/* Allocate and initialize a new til_module_context_t of size bytes.
@@ -27,7 +28,7 @@
*
* path must not be NULL, and the context takes ownership of the path; it's freed @ context_free().
*/
-void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path)
+void * til_module_context_new(til_stream_t *stream, size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path)
{
til_module_context_t *module_context;
@@ -39,6 +40,7 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
if (!module_context)
return NULL;
+ module_context->stream = stream;
module_context->seed = seed;
module_context->ticks = ticks;
module_context->n_cpus = n_cpus;
@@ -56,12 +58,14 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
*/
void * til_module_context_free(til_module_context_t *module_context)
{
- char *path;
+ char *path;
+ til_stream_t *stream;
if (!module_context)
return NULL;
path = module_context->path; /* free last just in case the module destructor makes use of it */
+ stream = module_context->stream;
if (module_context->module->destroy_context)
module_context->module->destroy_context(module_context);
@@ -70,5 +74,12 @@ void * til_module_context_free(til_module_context_t *module_context)
free(path);
+ /* cleanup any pipes this context might have had in the stream, if the
+ * module's destroy_context() also does this it's harmlessly idempotent
+ * besides wasting some cycles. But by always doing it here, we're sure
+ * to not leave dangling references.
+ */
+ til_stream_untap_owner(stream, module_context);
+
return NULL;
}
diff --git a/src/til_module_context.h b/src/til_module_context.h
index b2caf28..6f4339b 100644
--- a/src/til_module_context.h
+++ b/src/til_module_context.h
@@ -5,9 +5,11 @@
typedef struct til_module_context_t til_module_context_t;
typedef struct til_module_t til_module_t;
+typedef struct til_stream_t til_stream_t;
struct til_module_context_t {
const til_module_t *module;
+ til_stream_t *stream; /* optional stream this context is part of */
unsigned seed;
unsigned ticks;
unsigned n_cpus;
@@ -15,7 +17,7 @@ struct til_module_context_t {
uint32_t path_hash;
};
-void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path);
+void * til_module_context_new(til_stream_t *stream, size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path);
void * til_module_context_free(til_module_context_t *module_context);
#endif
diff --git a/src/til_threads.c b/src/til_threads.c
index 9e55a29..b9c781f 100644
--- a/src/til_threads.c
+++ b/src/til_threads.c
@@ -22,8 +22,9 @@ typedef struct til_threads_t {
pthread_mutex_t frame_mutex;
pthread_cond_t frame_cond;
- void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+ void (*render_fragment_func)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
void *context;
+ til_stream_t *stream;
til_fb_fragment_t **fragment_ptr;
til_frame_plan_t frame_plan;
unsigned ticks;
@@ -74,7 +75,7 @@ static void * thread_func(void *_thread)
if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag))
break;
- threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr);
+ threads->render_fragment_func(threads->context, threads->stream, threads->ticks, thread->id, &frag_ptr);
frag_num += threads->n_threads;
}
} else { /* render *any* available fragment */
@@ -91,7 +92,7 @@ static void * thread_func(void *_thread)
if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag))
break;
- threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr);
+ threads->render_fragment_func(threads->context, threads->stream, threads->ticks, thread->id, &frag_ptr);
}
}
@@ -120,7 +121,7 @@ void til_threads_wait_idle(til_threads_t *threads)
/* submit a frame's fragments to the threads */
-void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, unsigned ticks)
+void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, til_stream_t *stream, unsigned ticks)
{
til_threads_wait_idle(threads); /* XXX: likely non-blocking; already happens pre page flip */
@@ -130,6 +131,7 @@ void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragme
threads->frame_plan = *frame_plan;
threads->render_fragment_func = render_fragment_func;
threads->context = context;
+ threads->stream = stream;
threads->ticks = ticks;
threads->frame_num++;
threads->n_idle = threads->next_fragment = 0;
diff --git a/src/til_threads.h b/src/til_threads.h
index 4e6836d..664a0a5 100644
--- a/src/til_threads.h
+++ b/src/til_threads.h
@@ -3,11 +3,12 @@
typedef struct til_fb_fragment_t til_fb_fragment_t;
typedef struct til_threads_t til_threads_t;
+typedef struct til_stream_t til_stream_t;
til_threads_t * til_threads_create();
void til_threads_destroy(til_threads_t *threads);
-void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, unsigned ticks);
+void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, til_stream_t *stream, unsigned ticks);
void til_threads_wait_idle(til_threads_t *threads);
unsigned til_threads_num_threads(til_threads_t *threads);
© All Rights Reserved