summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-11-13 23:31:33 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-11-14 01:20:56 -0800
commit461b6bc98ad6a64ffefe8beedf736caef823cc25 (patch)
treefb80255d3e9d3eee592bc72df425609d2ca52d48
parent4c629d77d9bd67e9861f578d89957b3cf1472aa8 (diff)
til: introduce til_module_t.render_audio entrypoint
Simple audio rendering modules need a way to render their audio without affecting the fragment's state. By providing a til_module_t.render_audio() a module indicates it's only an audio renderer, and its render won't trigger an implicit clear of the frame's fragment. There might be a new flag added to indicate when modules are audio modules, but this is good enough for now.
-rw-r--r--src/til.c11
-rw-r--r--src/til.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/til.c b/src/til.c
index 2936fce..0e856a9 100644
--- a/src/til.c
+++ b/src/til.c
@@ -287,7 +287,16 @@ static void _til_module_render(til_module_context_t *context, til_stream_t *stre
{
unsigned start = til_ticks_now();
- module_render_fragment(context, stream, til_threads, n_cpus, ticks, fragment_ptr);
+ /* When a module provides a render_audio method, it's strictly audio and we don't do any render_fragment.
+ * If a module wants to do interesting things combining visuals and audio together, it should do the
+ * audio queueing from its prepare_frame/render_fragment/finish_frame alongside its visuals rendering,
+ * and leave render_audio NULL.
+ * FIXME TODO: assert() somewhere .render_audio isn't combined with .prepare_frame/.render_fragment/.finish_frame
+ */
+ if (context->module->render_audio)
+ context->module->render_audio(context, stream, ticks);
+ else
+ module_render_fragment(context, stream, til_threads, n_cpus, ticks, fragment_ptr);
context->last_render_duration = til_ticks_now() - start;
if (context->last_render_duration > context->max_render_duration)
diff --git a/src/til.h b/src/til.h
index 3126ced..0724bf3 100644
--- a/src/til.h
+++ b/src/til.h
@@ -30,6 +30,7 @@ typedef struct til_stream_t til_stream_t;
struct til_module_t {
til_module_context_t * (*create_context)(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup);
void (*destroy_context)(til_module_context_t *context); /* destroy gets stream in context, but the render-related functions should always use the passed-in stream so it can potentially change */
+ void (*render_audio)(til_module_context_t *context, til_stream_t *stream, unsigned ticks);
void (*prepare_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
void (*render_fragment)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
int (*finish_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr);
© All Rights Reserved