diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-06-25 12:26:52 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 21:09:11 -0700 |
commit | 5fd4e4331baf62d17632b2627db202459e8be6b0 (patch) | |
tree | 2a0a9e1bca4f917c66579a128c9fe8e45d535458 | |
parent | 40d001b40aeca62f21a77687b96144c8d0487069 (diff) |
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)
-rw-r--r-- | src/modules/rkt/rkt.c | 14 | ||||
-rw-r--r-- | src/modules/rkt/rkt.h | 3 |
2 files changed, 13 insertions, 4 deletions
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 { |