From b08baac7e388bf32fefd4f1ab129b28d5fc57aa9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 11 Jan 2023 15:22:01 -0800 Subject: * turn til_fb_fragment_t.stream into a discrete parameter This was mostly done out of convenience at the expense of turning the fragment struct into more of a junk drawer. But properly cleaning up owned stream pipes on context destroy makes the inappropriateness of being part of til_fb_fragment_t glaringly apparent. Now the stream is just a separate thing passed to context create, with a reference kept in the context for use throughout. Cleanup of the owned pipes on the stream supplied to context create is automagic when the context gets destroyed. Note that despite there being a stream in the module context, the stream to use is still supplied to all the rendering family functions (prepare/render/finish) and it's the passed-in stream which should be used by these functions. This is done to support the possibility of switching out the stream frame-to-frame, which may be interesting. Imagine doing things like a latent stream and a future stream and switching between them on the fly for instance. If there's a sequencing composite module, it could flip between multiple sets of tracks or jump around multiple streams with the visuals immediately flipping accordingly. This should fix the --print-pipes crashing issues caused by lack of cleanup when contexts were removed (like rtv does so often). --- src/modules/compose/compose.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/modules/compose') 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); } } -- cgit v1.2.3