summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-11-13 23:41:08 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-11-14 01:21:02 -0800
commitb7f773ae87ab037b94582005729fc15a22340f97 (patch)
tree215b203c2253bdee69f63a3da7c3937983ab2979
parent2b8feba1200ecfa231aa41aed4b6ab9b183d5a05 (diff)
modules/rkt: begin til_audio integrations
- til_audio_seek() when Rocket sets the row - til_audio_{pause,unpause}() when Rocket (un)pauses This is of limited use as-is, rkt probably needs a sister concept of scenes for songs, which similarly to scenes would be selected by index in a discrete Rocket track. As-is to make music work one must always incorporate something like a modules/playit context into the current scene so it always gets rendered alongside the visuals. That's quite cumbersome and annoying. Another possibility would be introducing something like a "register" built-in that, like "ref", takes a context path, and maybe something like a pre/post setting. That would put it in the rendering path of the stream before or after any explicit renders... Then all one would need is to register a modules/playit context with the song of interest to have it play, and create that as any other rkt "scene", and reference its context from "register" which could bind a tap for controlling the registered/unregistered state. It needs more fleshing out, but what's here seems worth merging as-is for now.
-rw-r--r--src/modules/rkt/rkt.c20
-rw-r--r--src/modules/rkt/rkt.h1
2 files changed, 18 insertions, 3 deletions
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c
index 8790f53..7460161 100644
--- a/src/modules/rkt/rkt.c
+++ b/src/modules/rkt/rkt.c
@@ -1,3 +1,4 @@
+#include <math.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -8,6 +9,7 @@
#include "rocket/rocket/lib/track.h"
#include "til.h"
+#include "til_audio.h"
#include "til_fb.h"
#include "til_module_context.h"
#include "til_settings.h"
@@ -83,20 +85,28 @@ static const struct sync_track * rkt_sync_get_trackf(rkt_context_t *ctxt, const
static void rkt_sync_pause(void *context, int flag)
{
- rkt_context_t *ctxt = context;
+ rkt_context_t *ctxt = context;
- if (flag)
+ if (flag) {
ctxt->paused = 1;
- else
+ til_audio_pause(ctxt->audio_context);
+ } else {
ctxt->paused = 0;
+ til_audio_unpause(ctxt->audio_context);
+ }
}
static void rkt_sync_set_row(void *context, int row)
{
rkt_context_t *ctxt = context;
+ unsigned audio_ticks;
ctxt->rocket_row = row;
+
+ /* inform any interested parties like a music player about the seek */
+ audio_ticks = rint(ctxt->rocket_row / ctxt->rows_per_ms);
+ til_audio_seek(ctxt->audio_context, audio_ticks);
}
@@ -276,6 +286,7 @@ static til_module_context_t * rkt_create_context(const til_module_t *module, til
if (!ctxt->scene_track)
return til_module_context_free(&ctxt->til_module_context);
+ ctxt->audio_context = til_stream_get_audio_context(stream);
/* set the stream hooks early so context creates can establish taps early */
til_stream_set_hooks(stream, &rkt_stream_hooks, ctxt);
@@ -380,6 +391,9 @@ static void rkt_render_fragment(til_module_context_t *context, til_stream_t *str
ctxt->last_scene = scene;
}
+
+ if (!ctxt->paused)
+ til_audio_unpause(ctxt->audio_context);
}
diff --git a/src/modules/rkt/rkt.h b/src/modules/rkt/rkt.h
index ede973a..3afa409 100644
--- a/src/modules/rkt/rkt.h
+++ b/src/modules/rkt/rkt.h
@@ -17,6 +17,7 @@ typedef struct rkt_context_t {
til_module_context_t til_module_context;
rkt_scener_t *scener;
+ til_audio_context_t *audio_context;
struct sync_device *sync_device;
const struct sync_track *scene_track;
double rows_per_ms;
© All Rights Reserved