summaryrefslogtreecommitdiff
path: root/src/modules/rtv
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-11-14 23:26:00 -0800
committerVito Caputo <vcaputo@pengaru.com>2019-11-14 23:26:00 -0800
commit1299c8667b44058ce35b20e3d86c5ae1d5ee0995 (patch)
tree47153f36b93b69b2a4f04be86d6e6bcc645c855b /src/modules/rtv
parent350f89859501fbe759634e77733ecba2c97fd06d (diff)
rtv: add some snow between module switches
This uses the newly added snow module as a transition between modules
Diffstat (limited to 'src/modules/rtv')
-rw-r--r--src/modules/rtv/rtv.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index da6ae52..8848e82 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -24,15 +24,18 @@
* same thing over and over.
*/
+#define RTV_SNOW_DURATION_SECS 1
#define RTV_DURATION_SECS 15
typedef struct rtv_context_t {
const rototiller_module_t **modules;
size_t n_modules;
- time_t last_switch;
+ time_t next_switch;
const rototiller_module_t *module;
void *module_ctxt;
+
+ const rototiller_module_t *snow_module;
} rtv_context_t;
static void setup_next_module(rtv_context_t *ctxt);
@@ -68,15 +71,22 @@ static void setup_next_module(rtv_context_t *ctxt)
ctxt->module_ctxt = NULL;
}
- do {
- i = rand() % ctxt->n_modules;
- } while (ctxt->modules[i] == &rtv_module || ctxt->modules[i] == ctxt->module);
+ if (ctxt->module != ctxt->snow_module) {
+ ctxt->module = ctxt->snow_module;
+ ctxt->next_switch = time(NULL) + RTV_SNOW_DURATION_SECS;
+ } else {
+ do {
+ i = rand() % ctxt->n_modules;
+ } while (ctxt->modules[i] == &rtv_module ||
+ ctxt->modules[i] == ctxt->module ||
+ ctxt->modules[i] == ctxt->snow_module);
+
+ ctxt->module = ctxt->modules[i];
+ ctxt->next_switch = time(NULL) + RTV_DURATION_SECS;
+ }
- ctxt->module = ctxt->modules[i];
if (ctxt->module->create_context)
ctxt->module_ctxt = ctxt->module->create_context();
-
- ctxt->last_switch = time(NULL);
}
@@ -84,6 +94,7 @@ static void * rtv_create_context(void)
{
rtv_context_t *ctxt = calloc(1, sizeof(rtv_context_t));
+ ctxt->snow_module = rototiller_lookup_module("snow");
rototiller_get_modules(&ctxt->modules, &ctxt->n_modules);
setup_next_module(ctxt);
@@ -101,7 +112,7 @@ static void rtv_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fra
{
rtv_context_t *ctxt = context;
- if (!ctxt->last_switch || time(NULL) - ctxt->last_switch > RTV_DURATION_SECS)
+ if (time(NULL) >= ctxt->next_switch)
setup_next_module(ctxt);
rototiller_module_render(ctxt->module, ctxt->module_ctxt, fragment);
© All Rights Reserved