diff options
Diffstat (limited to 'src/modules/rkt')
-rw-r--r-- | src/modules/rkt/rkt.c | 20 | ||||
-rw-r--r-- | src/modules/rkt/rkt.h | 1 |
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; |