From 5fd4e4331baf62d17632b2627db202459e8be6b0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 25 Jun 2023 12:26:52 -0700 Subject: modules/rkt: discretize rkt_context_t.scenes[] Make this a distinct heap allocation so it can be enlarged when editing the scenes... (preparatory commit for scenes editing) --- src/modules/rkt/rkt.c | 14 +++++++++++--- src/modules/rkt/rkt.h | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index 33bdd73..3c97bc4 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -199,6 +199,14 @@ static til_module_context_t * rkt_create_context(const til_module_t *module, til if (!ctxt) return NULL; + if (s->n_scenes) { + ctxt->scenes = calloc(s->n_scenes, sizeof(rkt_scene_t)); + if (!ctxt->scenes) + return til_module_context_free(&ctxt->til_module_context); + + ctxt->n_scenes = s->n_scenes; + } + ctxt->sync_device = sync_create_device(s->base); if (!ctxt->sync_device) return til_module_context_free(&ctxt->til_module_context); @@ -216,7 +224,7 @@ static til_module_context_t * rkt_create_context(const til_module_t *module, til /* set the stream hooks early so context creates can establish taps early */ til_stream_set_hooks(stream, &rkt_stream_hooks, ctxt); - for (size_t i = 0; i < s->n_scenes; i++) { + for (size_t i = 0; i < ctxt->n_scenes; i++) { int r; ctxt->scenes[i].module = til_lookup_module(s->scenes[i].module_name); @@ -244,7 +252,7 @@ static void rkt_destroy_context(til_module_context_t *context) if (ctxt->sync_device) sync_destroy_device(ctxt->sync_device); - for (size_t i = 0; i < ((rkt_setup_t *)context->setup)->n_scenes; i++) + for (size_t i = 0; i < ctxt->n_scenes; i++) til_module_context_free(ctxt->scenes[i].module_ctxt); free(context); @@ -264,7 +272,7 @@ static void rkt_render_fragment(til_module_context_t *context, til_stream_t *str unsigned scene; scene = (unsigned)sync_get_val(ctxt->scene_track, ctxt->rocket_row); - if (scene < ((rkt_setup_t *)context->setup)->n_scenes) { + if (scene < ctxt->n_scenes) { til_module_render(ctxt->scenes[scene].module_ctxt, stream, ticks, fragment_ptr); } else if (scene == 99999 && !((rkt_setup_t *)context->setup)->connect) { /* 99999 is treated as an "end of sequence" scene, but only honored when connect=off (player mode) */ diff --git a/src/modules/rkt/rkt.h b/src/modules/rkt/rkt.h index c4c8550..861aa6b 100644 --- a/src/modules/rkt/rkt.h +++ b/src/modules/rkt/rkt.h @@ -18,7 +18,8 @@ typedef struct rkt_context_t { double rocket_row; unsigned last_ticks; unsigned paused:1; - rkt_scene_t scenes[]; + size_t n_scenes; + rkt_scene_t *scenes; } rkt_context_t; typedef struct rkt_setup_scene_t { -- cgit v1.2.3