diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/rtv/rtv.c | 15 | ||||
-rw-r--r-- | src/til.c | 23 | ||||
-rw-r--r-- | src/til.h | 2 |
3 files changed, 17 insertions, 23 deletions
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 9d006bc..a73c9a5 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -174,7 +174,18 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks) char *settings_as_arg = NULL; txt_t *caption; - (void) til_module_setup_randomize(ctxt->channel->module, rand_r(&ctxt->til_module_context.seed), &ctxt->channel->module_setup, &settings_as_arg); + /* FIXME TODO: this should get seeded with a settings string from the rtv setup, so the user can + * influence the channel settings... and by just taking the per-channel settings string as-is, + * it's effectively partially evaluated until this point here, so the randomizer will leave alone + * whatever's specified while randomizing whatever isn't. Meaning you could make certain things + * static, while rtv varies everything else. The down side of that approach would be the rtv setup + * won't fully evaluate the channel settings, meaning you won't have structured guidance. But that + * should be possible with more work... there just needs to be a way to put the setup in a mode + * where leaving things unspecified is acceptable. + */ + til_settings_t *settings = til_settings_new(ctxt->til_module_context.setup->path, NULL, ctxt->channel->module->name, ctxt->channel->module->name /* XXX: we can at least toss the bare-value module name in there, but this should really come from the rtv channels= entries */); + + (void) til_module_setup_randomize(ctxt->channel->module, settings, rand_r(&ctxt->til_module_context.seed), &ctxt->channel->module_setup, &settings_as_arg); caption = txt_newf("Title: %s%s%s\nDescription: %s%s%s", ctxt->channel->module->name, ctxt->channel->module->author ? "\nAuthor: " : "", @@ -186,6 +197,8 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks) ctxt->caption = ctxt->channel->caption = caption; ctxt->channel->settings_as_arg = settings_as_arg ? settings_as_arg : strdup(""); + til_settings_free(settings); + if (ctxt->log_channels) /* TODO: we need to capture seed state too, a general solution capturing such global state would be nice */ fprintf(stderr, "rtv channel settings: \'%s\'\n", ctxt->channel->settings_as_arg); } @@ -352,31 +352,14 @@ int til_module_setup(const til_settings_t *settings, til_setting_t **res_setting /* originally taken from rtv, this randomizes a module's setup @res_setup, args @res_arg * returns 0 on on setup successful with results stored @res_*, -errno on error. */ -int til_module_setup_randomize(const til_module_t *module, unsigned seed, til_setup_t **res_setup, char **res_arg) +int til_module_setup_randomize(const til_module_t *module, til_settings_t *settings, unsigned seed, til_setup_t **res_setup, char **res_arg) { - til_settings_t *settings; til_setting_t *setting; const til_setting_desc_t *desc; int r = 0; assert(module); - - /* FIXME TODO: - * this seems wrong for two reasons: - * 1. there's no parent settings to attach this to, and there really shouldn't be such - * orphaned settings instances as we're supposed ot be able to influence their values - * externally via settings. At the very least this seems like it should be part of a - * heirarchy somewhere... which leads to #2 - * - * 2. not only does lacking a parent suggests a problem, but there should be an incoming - * settings instance to randomize which may contain some values already set which we - * would skip randomizing. The settings don't currently have any kind of attributes or - * other state to indicate which ones should always be randomized vs. ones which were - * explicitly specified to stay fixed. - */ - settings = til_settings_new(NULL, NULL, module->name, NULL); - if (!settings) - return -ENOMEM; + assert(settings); if (!module->setup) { til_setup_t *setup; @@ -465,8 +448,6 @@ int til_module_setup_randomize(const til_module_t *module, unsigned seed, til_se *res_arg = arg; } - til_settings_free(settings); - return r; } @@ -47,7 +47,7 @@ void til_module_render(til_module_context_t *context, til_stream_t *stream, unsi int til_module_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup, til_module_context_t **res_context); til_module_context_t * til_module_destroy_context(til_module_context_t *context, til_stream_t *stream); int til_module_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); -int til_module_setup_randomize(const til_module_t *module, unsigned seed, til_setup_t **res_setup, char **res_arg); +int til_module_setup_randomize(const til_module_t *module, til_settings_t *settings, unsigned seed, til_setup_t **res_setup, char **res_arg); int til_module_setup_finalize(const til_module_t *module, const til_settings_t *module_settings, til_setup_t **res_setup); int til_fragmenter_slice_per_cpu(til_module_context_t *context, const til_fb_fragment_t *fragment, unsigned number, til_fb_fragment_t *res_fragment); int til_fragmenter_tile64(til_module_context_t *context, const til_fb_fragment_t *fragment, unsigned number, til_fb_fragment_t *res_fragment); |