From 0d9aa593e68f33da8ea71a04b930bb6093dbaccb Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 11 May 2023 12:51:00 -0700 Subject: modules/*: stop storing setup by value in contexts With setup refcounting and a reference bound to the context, we should just dereference the single instance. The way setups are used it just as a read-only thing to affect context behavior... Note I've left the module-type-specific setup pointer despite it duplicating the setup pointer in the module_context. This is just a convenience thing so the accessors don't have to cast the general til_setup_t* to my_module_setup_t* everywhere. --- src/modules/strobe/strobe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/strobe/strobe.c') diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index 634a46b..495b95b 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -28,7 +28,7 @@ typedef struct strobe_setup_t { typedef struct strobe_context_t { til_module_context_t til_module_context; - strobe_setup_t setup; + strobe_setup_t *setup; unsigned ticks; unsigned flash:1; unsigned flash_ready:1; @@ -43,7 +43,7 @@ static til_module_context_t * strobe_create_context(const til_module_t *module, if (!ctxt) return NULL; - ctxt->setup = *(strobe_setup_t *)setup; + ctxt->setup = (strobe_setup_t *)setup; ctxt->ticks = ticks; return &ctxt->til_module_context; @@ -56,7 +56,7 @@ static void strobe_prepare_frame(til_module_context_t *context, til_stream_t *st *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu }; - if (ctxt->flash_ready && (ticks - ctxt->ticks >= (unsigned)(ctxt->setup.period * 1000.f))){ + if (ctxt->flash_ready && (ticks - ctxt->ticks >= (unsigned)(ctxt->setup->period * 1000.f))){ ctxt->flash = 1; ctxt->flash_ready = 0; } else { -- cgit v1.2.3