summaryrefslogtreecommitdiff
path: root/src/modules/rtv/rtv.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-11-23 16:08:07 -0800
committerVito Caputo <vcaputo@pengaru.com>2019-11-23 16:14:34 -0800
commitade362b53d721bc2e2c7a62a30c4345014e5f5ce (patch)
tree028914a89365c43047ecb9af1368d8c3304f7e5c /src/modules/rtv/rtv.c
parent796b3a8b0669ee5e09c6faba6614e3f228d36595 (diff)
rototiller: pass num_cpus to .create_context()
Back in the day, there was no {create,destroy}_context(), so passing num_cpus to just prepare_frame made sense. Modules then would implicitly initialize themselves on the first prepare_frame() call using a static initialized variable. Since then things have been decomposed a bit for more sophisticated (and cleaner) modules. It can be necessary to allocate per-cpu data structures and the natural place to do that is @ create_context(). So this commit wires that up. A later commit will probably have to plumb a "current cpu" identifier into the render_fragment() function. Because a per-cpu data structure isn't particularly useful if you can't easily address it from within your execution context.
Diffstat (limited to 'src/modules/rtv/rtv.c')
-rw-r--r--src/modules/rtv/rtv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index c4c6dd2..dd9ece8 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -31,6 +31,7 @@
typedef struct rtv_context_t {
const rototiller_module_t **modules;
size_t n_modules;
+ unsigned n_cpus;
time_t next_switch, next_hide_caption;
const rototiller_module_t *module, *last_module;
@@ -41,7 +42,7 @@ typedef struct rtv_context_t {
} rtv_context_t;
static void setup_next_module(rtv_context_t *ctxt);
-static void * rtv_create_context(void);
+static void * rtv_create_context(unsigned num_cpus);
static void rtv_destroy_context(void *context);
static void rtv_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter);
static void rtv_finish_frame(void *context, fb_fragment_t *fragment);
@@ -152,14 +153,15 @@ static void setup_next_module(rtv_context_t *ctxt)
}
if (ctxt->module->create_context)
- ctxt->module_ctxt = ctxt->module->create_context();
+ ctxt->module_ctxt = ctxt->module->create_context(ctxt->n_cpus);
}
-static void * rtv_create_context(void)
+static void * rtv_create_context(unsigned num_cpus)
{
rtv_context_t *ctxt = calloc(1, sizeof(rtv_context_t));
+ ctxt->n_cpus = num_cpus;
ctxt->snow_module = rototiller_lookup_module("snow");
rototiller_get_modules(&ctxt->modules, &ctxt->n_modules);
setup_next_module(ctxt);
© All Rights Reserved