summaryrefslogtreecommitdiff
path: root/src/modules/rtv
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-06-03 14:51:39 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-06-03 14:51:39 -0700
commit09c67051ff526fd25e6929c90fcaa0ce8cfb6079 (patch)
tree2856db32c0cdb1a4da0da010ad3fc1119b6d52a4 /src/modules/rtv
parente0cbb8f476b220ef80de9bbe8159435c78d4e921 (diff)
til,modules/rtv: supply settings to til_module_setup_randomize()
Rather than creating an orphaned settings instance private to til_module_setup_randomize(), the function now requires the settings instance be provided. The one remaining caller of this function is modules::rtv. Now that rtv is responsible for creating the settings beforehand, and the settings may be created with a path prefix, rtv gets its til_module_context_t->setup.path prefixed for all the channel settings. Another improvement is now the channel settings instance gets created from the module name as the settings string. So while it's not yet possible to sparsely specify settings with others being randomized, at least now when log_channels=on is in effect, the printed args include the top-level channel module. Having proper complete paths for the rtv channel modules is especially visible in --print-paths output FYI. An interesting test for exercising all this is: ``` $ src/rototiller --module=rtv,duration=0,context_duration=0,snow_module=none,channels=all,log_channels=on --print-pipes --defaults --go 2>/tmp/channels in another terminal: $ tail -F /tmp/channels ``` watch the chaos unfold
Diffstat (limited to 'src/modules/rtv')
-rw-r--r--src/modules/rtv/rtv.c15
1 files changed, 14 insertions, 1 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);
}
© All Rights Reserved