From 3cc953518d1c2b84f08f5693d3566db4462623a8 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 5 Aug 2023 00:07:16 -0700 Subject: til_setup,*: add til_setup_t.creator pointer Particularly with nested modules it's annoying to have to stow the module separate from the setup during the setup process. If the baked setup included the module pointer in the non-module-specific-setup part of the setup, then nested settings could finalize using the generic module setup wrapper and just rely on this til_setup_t.creator pointer to contain the appropriate module. Which should enable tossing out a bunch of copy-n-pasta surrounding nested modules setup. Note this has to be a void* since til_setup_t is a generic thing used equally by both the fb code and the module code. Hence why this is called "creator" and not "module", as well as the void* as opposed to til_module_t*. Also if rototiller ever grows a sound backend, the setup machinery will be reused there as well, and it'll be yet another creator handle that isn't an til_fb_ops_t or a til_module_t. It's assumed that the callers producing these setups won't be trying to pass them to the wrong places i.e. a module setup getting passed to an fb backend and vice versa. I'm mildly annoyed about having to move the various til_module_t blocks to above the module's foo_setup(), but it seemed like the least annoying option. This may be revisited. --- src/modules/rkt/rkt.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/modules/rkt') diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index f5f73e7..45073ef 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -397,6 +397,20 @@ int rkt_scene_module_setup(const til_settings_t *settings, til_setting_t **res_s } +static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); + + +til_module_t rkt_module = { + .create_context = rkt_create_context, + .destroy_context = rkt_destroy_context, + .render_fragment = rkt_render_fragment, + .name = "rkt", + .description = "GNU Rocket module sequencer", + .setup = rkt_setup, + .flags = TIL_MODULE_HERMETIC, /* this needs refinement esp. if rkt gets split into a player and editor */ +}; + + static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) { const til_settings_t *scenes_settings; @@ -596,7 +610,7 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting rkt_setup_t *setup; unsigned ibpm, irpb; - setup = til_setup_new(settings, sizeof(*setup) + n_scenes * sizeof(*setup->scenes), rkt_setup_free); + setup = til_setup_new(settings, sizeof(*setup) + n_scenes * sizeof(*setup->scenes), rkt_setup_free, &rkt_module); if (!setup) return -ENOMEM; @@ -683,14 +697,3 @@ static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting return 0; } - - -til_module_t rkt_module = { - .create_context = rkt_create_context, - .destroy_context = rkt_destroy_context, - .render_fragment = rkt_render_fragment, - .name = "rkt", - .description = "GNU Rocket module sequencer", - .setup = rkt_setup, - .flags = TIL_MODULE_HERMETIC, /* this needs refinement esp. if rkt gets split into a player and editor */ -}; -- cgit v1.2.3