diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-03-13 12:40:56 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-03-13 12:40:56 -0700 |
commit | acaace32807641d62cf3ee533fb016734dc447d9 (patch) | |
tree | 394ee6a3f62fdceb3149c1e04b24e2ecf883d8fa | |
parent | 815cf7455a8f937795623705dd2426ba9a93e460 (diff) |
modules/rocket: %s/rocket/rkt/g
It's annoying to have the til module called rocket, and the sync
tracker protocol/library called rocket, so let's at least
differentiate it in code/comments/textual discussion.
Plus this results in shorter module context paths i.e.:
/rkt:scene
/rkt/compose/drizzle:rain
/rkt/compose/drizzle:viscosity
/rkt/compose/plato:spin_rate
/rkt/compose/plato:orbit_rate
vs.
/rocket:scene
etc...
These names are shown in the editor, and they'll tend to be long
but let's at least get the root name down to three chars this
way.
A rename of the files and build system update will come in a
subsequent commit
-rw-r--r-- | src/modules/rocket/rocket.c | 136 | ||||
-rw-r--r-- | src/til.c | 4 |
2 files changed, 70 insertions, 70 deletions
diff --git a/src/modules/rocket/rocket.c b/src/modules/rocket/rocket.c index 6add6be..ac361c0 100644 --- a/src/modules/rocket/rocket.c +++ b/src/modules/rocket/rocket.c @@ -23,7 +23,7 @@ * GNU Rocket (https://github.com/rocket/rocket) */ -typedef struct rocket_context_t { +typedef struct rkt_context_t { til_module_context_t til_module_context; const til_module_t *seq_module; @@ -34,9 +34,9 @@ typedef struct rocket_context_t { double rocket_row; unsigned last_ticks; unsigned paused:1; -} rocket_context_t; +} rkt_context_t; -typedef struct rocket_setup_t { +typedef struct rkt_setup_t { til_setup_t til_setup; const char *seq_module_name; const char *base; @@ -44,34 +44,34 @@ typedef struct rocket_setup_t { unsigned connect:1; const char *host; unsigned short port; -} rocket_setup_t; +} rkt_setup_t; -static rocket_setup_t rocket_default_setup = { .seq_module_name = "compose" }; +static rkt_setup_t rkt_default_setup = { .seq_module_name = "compose" }; -static til_module_context_t * rocket_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) +static til_module_context_t * rkt_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { - rocket_context_t *ctxt; + rkt_context_t *ctxt; const til_module_t *seq_module; if (!setup) - setup = &rocket_default_setup.til_setup; + setup = &rkt_default_setup.til_setup; - seq_module = til_lookup_module(((rocket_setup_t *)setup)->seq_module_name); + seq_module = til_lookup_module(((rkt_setup_t *)setup)->seq_module_name); if (!seq_module) return NULL; - ctxt = til_module_context_new(module, sizeof(rocket_context_t), stream, seed, ticks, n_cpus, path); + ctxt = til_module_context_new(module, sizeof(rkt_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; - ctxt->sync_device = sync_create_device(((rocket_setup_t *)setup)->base); + ctxt->sync_device = sync_create_device(((rkt_setup_t *)setup)->base); if (!ctxt->sync_device) return til_module_context_free(&ctxt->til_module_context); - if (((rocket_setup_t *)setup)->connect) { + if (((rkt_setup_t *)setup)->connect) { /* XXX: it'd be better if we just reconnected periodically instead of hard failing */ - if (sync_tcp_connect(ctxt->sync_device, ((rocket_setup_t *)setup)->host, ((rocket_setup_t *)setup)->port)) + if (sync_tcp_connect(ctxt->sync_device, ((rkt_setup_t *)setup)->host, ((rkt_setup_t *)setup)->port)) return til_module_context_free(&ctxt->til_module_context); } @@ -86,16 +86,16 @@ static til_module_context_t * rocket_create_context(const til_module_t *module, til_setup_free(module_setup); } - ctxt->rows_per_ms = ((rocket_setup_t *)setup)->rows_per_ms; + ctxt->rows_per_ms = ((rkt_setup_t *)setup)->rows_per_ms; ctxt->last_ticks = ticks; return &ctxt->til_module_context; } -static void rocket_destroy_context(til_module_context_t *context) +static void rkt_destroy_context(til_module_context_t *context) { - rocket_context_t *ctxt = (rocket_context_t *)context; + rkt_context_t *ctxt = (rkt_context_t *)context; if (ctxt->sync_device) sync_destroy_device(ctxt->sync_device); @@ -104,9 +104,9 @@ static void rocket_destroy_context(til_module_context_t *context) } -static void rocket_sync_pause(void *context, int flag) +static void rkt_sync_pause(void *context, int flag) { - rocket_context_t *ctxt = context; + rkt_context_t *ctxt = context; if (flag) ctxt->paused = 1; @@ -115,31 +115,31 @@ static void rocket_sync_pause(void *context, int flag) } -static void rocket_sync_set_row(void *context, int row) +static void rkt_sync_set_row(void *context, int row) { - rocket_context_t *ctxt = context; + rkt_context_t *ctxt = context; ctxt->rocket_row = row; } -static int rocket_sync_is_playing(void *context) +static int rkt_sync_is_playing(void *context) { - rocket_context_t *ctxt = context; + rkt_context_t *ctxt = context; /* returns bool, 1 for is playing */ return !ctxt->paused; } -static struct sync_cb rocket_sync_cb = { - rocket_sync_pause, - rocket_sync_set_row, - rocket_sync_is_playing, +static struct sync_cb rkt_sync_cb = { + rkt_sync_pause, + rkt_sync_set_row, + rkt_sync_is_playing, }; -typedef struct rocket_pipe_t { +typedef struct rkt_pipe_t { /* rocket basically only applies to floats, so we only need a float, its tap, and a sync track */ til_tap_t tap; @@ -155,13 +155,13 @@ typedef struct rocket_pipe_t { const struct sync_track *track; char track_name[]; -} rocket_pipe_t; +} rkt_pipe_t; -int rocket_stream_pipe_ctor(void *context, til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap, const void **res_owner, const void **res_owner_foo, const til_tap_t **res_driving_tap) +int rkt_stream_pipe_ctor(void *context, til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap, const void **res_owner, const void **res_owner_foo, const til_tap_t **res_driving_tap) { - rocket_context_t *ctxt = context; - rocket_pipe_t *rocket_pipe; + rkt_context_t *ctxt = context; + rkt_pipe_t *rkt_pipe; size_t track_name_len; assert(stream); @@ -177,35 +177,35 @@ int rocket_stream_pipe_ctor(void *context, til_stream_t *stream, const void *own /* we take ownership, and create our own tap and rocket track to stow @ owner_foo */ /* rocket has its own syntax for track names so instead of consttructing a concatenated path - * in til_stream_pipe_t and passing it to the ctor, just construct our own in the end of rocket_pipe_t + * in til_stream_pipe_t and passing it to the ctor, just construct our own in the end of rkt_pipe_t */ track_name_len = strlen(parent_path) + 1 + strlen(tap->name) + 1; - rocket_pipe = calloc(1, sizeof(rocket_pipe_t) + track_name_len); - if (!rocket_pipe) + rkt_pipe = calloc(1, sizeof(rkt_pipe_t) + track_name_len); + if (!rkt_pipe) return -ENOMEM; - snprintf(rocket_pipe->track_name, track_name_len, "%s:%s", parent_path, tap->name); - rocket_pipe->tap = til_tap_init(ctxt, tap->type, &rocket_pipe->ptr, 1, &rocket_pipe->var, tap->name); - rocket_pipe->track = sync_get_track(ctxt->sync_device, rocket_pipe->track_name); + snprintf(rkt_pipe->track_name, track_name_len, "%s:%s", parent_path, tap->name); + rkt_pipe->tap = til_tap_init(ctxt, tap->type, &rkt_pipe->ptr, 1, &rkt_pipe->var, tap->name); + rkt_pipe->track = sync_get_track(ctxt->sync_device, rkt_pipe->track_name); *res_owner = ctxt; - *res_owner_foo = rocket_pipe; - *res_driving_tap = rocket_pipe->track->num_keys ? &rocket_pipe->tap : tap; + *res_owner_foo = rkt_pipe; + *res_driving_tap = rkt_pipe->track->num_keys ? &rkt_pipe->tap : tap; return 1; } -static const til_stream_hooks_t rocket_stream_hooks = { - .pipe_ctor = rocket_stream_pipe_ctor, +static const til_stream_hooks_t rkt_stream_hooks = { + .pipe_ctor = rkt_stream_pipe_ctor, /* .pipe_dtor unneeded */ }; -static int rocket_pipe_update(void *context, til_stream_pipe_t *pipe, const void *owner, const void *owner_foo, const til_tap_t *driving_tap) +static int rkt_pipe_update(void *context, til_stream_pipe_t *pipe, const void *owner, const void *owner_foo, const til_tap_t *driving_tap) { - rocket_pipe_t *rocket_pipe = (rocket_pipe_t *)owner_foo; - rocket_context_t *ctxt = context; + rkt_pipe_t *rkt_pipe = (rkt_pipe_t *)owner_foo; + rkt_context_t *ctxt = context; double val; /* just ignore pipes we don't own (they're not types we can drive w/rocket) */ @@ -213,26 +213,26 @@ static int rocket_pipe_update(void *context, til_stream_pipe_t *pipe, const void return 0; /* when there's no keys in the track, flag as inactive so someone else can drive */ - if (!rocket_pipe->track->num_keys) { - rocket_pipe->tap.inactive = 1; + if (!rkt_pipe->track->num_keys) { + rkt_pipe->tap.inactive = 1; return 0; } - rocket_pipe->tap.inactive = 0; - if (driving_tap != &rocket_pipe->tap) - til_stream_pipe_set_driving_tap(pipe, &rocket_pipe->tap); + rkt_pipe->tap.inactive = 0; + if (driving_tap != &rkt_pipe->tap) + til_stream_pipe_set_driving_tap(pipe, &rkt_pipe->tap); /* otherwise get the current interpolated value from the rocket track @ owner_foo->track * to update owner_foo->var.[fd], which _should_ be the driving tap. */ - val = sync_get_val(rocket_pipe->track, ctxt->rocket_row); - switch (rocket_pipe->tap.type) { + val = sync_get_val(rkt_pipe->track, ctxt->rocket_row); + switch (rkt_pipe->tap.type) { case TIL_TAP_TYPE_FLOAT: - rocket_pipe->var.f = val; + rkt_pipe->var.f = val; break; case TIL_TAP_TYPE_DOUBLE: - rocket_pipe->var.d = val; + rkt_pipe->var.d = val; break; default: assert(0); @@ -242,9 +242,9 @@ static int rocket_pipe_update(void *context, til_stream_pipe_t *pipe, const void } -static void rocket_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) +static void rkt_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - rocket_context_t *ctxt = (rocket_context_t *)context; + rkt_context_t *ctxt = (rkt_context_t *)context; if (!ctxt->paused) ctxt->rocket_row += ((double)(ticks - ctxt->last_ticks)) * ctxt->rows_per_ms; @@ -252,19 +252,19 @@ static void rocket_render_fragment(til_module_context_t *context, til_stream_t * ctxt->last_ticks = ticks; /* hooks-setting is idempotent and cheap so we just always do it, and technicallly the stream can get changed out on us frame-to-frame */ - til_stream_set_hooks(stream, &rocket_stream_hooks, ctxt); + til_stream_set_hooks(stream, &rkt_stream_hooks, ctxt); /* ctxt->rocket_row needs to be updated */ - sync_update(ctxt->sync_device, ctxt->rocket_row, &rocket_sync_cb, ctxt); + sync_update(ctxt->sync_device, ctxt->rocket_row, &rkt_sync_cb, ctxt); /* this drives our per-rocket-track updates, with the tracks registered as owner_foo on the pipes, respectively */ - til_stream_for_each_pipe(stream, rocket_pipe_update, ctxt); + til_stream_for_each_pipe(stream, rkt_pipe_update, ctxt); til_module_render(ctxt->seq_module_ctxt, stream, ticks, fragment_ptr); } -static int rocket_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) +static int rkt_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup) { const char *connect_values[] = { "off", @@ -385,10 +385,10 @@ static int rocket_setup(const til_settings_t *settings, til_setting_t **res_sett if (res_setup) { const til_module_t *til_seq_module; - rocket_setup_t *setup; + rkt_setup_t *setup; unsigned ibpm, irpb; - if (!strcmp(seq_module, "rocket")) + if (!strcmp(seq_module, "rkt")) return -EINVAL; til_seq_module = til_lookup_module(seq_module); @@ -418,12 +418,12 @@ static int rocket_setup(const til_settings_t *settings, til_setting_t **res_sett } -til_module_t rocket_module = { - .create_context = rocket_create_context, - .destroy_context = rocket_destroy_context, - .render_fragment = rocket_render_fragment, - .name = "rocket", +til_module_t rkt_module = { + .create_context = rkt_create_context, + .destroy_context = rkt_destroy_context, + .render_fragment = rkt_render_fragment, + .name = "rkt", .description = "GNU Rocket module sequencer", - .setup = rocket_setup, - .flags = TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL, /* this needs refinement esp. if rocket gets split into a player and editor */ + .setup = rkt_setup, + .flags = TIL_MODULE_HERMETIC | TIL_MODULE_EXPERIMENTAL, /* this needs refinement esp. if rkt gets split into a player and editor */ }; @@ -37,7 +37,7 @@ extern til_module_t pixbounce_module; extern til_module_t plasma_module; extern til_module_t plato_module; extern til_module_t ray_module; -extern til_module_t rocket_module; +extern til_module_t rkt_module; extern til_module_t roto_module; extern til_module_t rtv_module; extern til_module_t shapes_module; @@ -65,7 +65,7 @@ static const til_module_t *modules[] = { &plasma_module, &plato_module, &ray_module, - &rocket_module, + &rkt_module, &roto_module, &rtv_module, &shapes_module, |