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/stars/stars.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/modules/stars') 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; -- cgit v1.2.3