summaryrefslogtreecommitdiff
path: root/src/til_threads.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-11 15:22:01 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-11 22:31:31 -0800
commitb08baac7e388bf32fefd4f1ab129b28d5fc57aa9 (patch)
tree51e7b414c88ef5637b038f6747be15898d54618d /src/til_threads.c
parent470305ae1c7b038fa0ad58223a2d48f60158a7bf (diff)
* turn til_fb_fragment_t.stream into a discrete parameter
This was mostly done out of convenience at the expense of turning the fragment struct into more of a junk drawer. But properly cleaning up owned stream pipes on context destroy makes the inappropriateness of being part of til_fb_fragment_t glaringly apparent. Now the stream is just a separate thing passed to context create, with a reference kept in the context for use throughout. Cleanup of the owned pipes on the stream supplied to context create is automagic when the context gets destroyed. Note that despite there being a stream in the module context, the stream to use is still supplied to all the rendering family functions (prepare/render/finish) and it's the passed-in stream which should be used by these functions. This is done to support the possibility of switching out the stream frame-to-frame, which may be interesting. Imagine doing things like a latent stream and a future stream and switching between them on the fly for instance. If there's a sequencing composite module, it could flip between multiple sets of tracks or jump around multiple streams with the visuals immediately flipping accordingly. This should fix the --print-pipes crashing issues caused by lack of cleanup when contexts were removed (like rtv does so often).
Diffstat (limited to 'src/til_threads.c')
-rw-r--r--src/til_threads.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/til_threads.c b/src/til_threads.c
index 9e55a29..b9c781f 100644
--- a/src/til_threads.c
+++ b/src/til_threads.c
@@ -22,8 +22,9 @@ typedef struct til_threads_t {
pthread_mutex_t frame_mutex;
pthread_cond_t frame_cond;
- void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
+ void (*render_fragment_func)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
void *context;
+ til_stream_t *stream;
til_fb_fragment_t **fragment_ptr;
til_frame_plan_t frame_plan;
unsigned ticks;
@@ -74,7 +75,7 @@ static void * thread_func(void *_thread)
if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag))
break;
- threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr);
+ threads->render_fragment_func(threads->context, threads->stream, threads->ticks, thread->id, &frag_ptr);
frag_num += threads->n_threads;
}
} else { /* render *any* available fragment */
@@ -91,7 +92,7 @@ static void * thread_func(void *_thread)
if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag))
break;
- threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr);
+ threads->render_fragment_func(threads->context, threads->stream, threads->ticks, thread->id, &frag_ptr);
}
}
@@ -120,7 +121,7 @@ void til_threads_wait_idle(til_threads_t *threads)
/* submit a frame's fragments to the threads */
-void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, unsigned ticks)
+void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, til_stream_t *stream, unsigned ticks)
{
til_threads_wait_idle(threads); /* XXX: likely non-blocking; already happens pre page flip */
@@ -130,6 +131,7 @@ void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragme
threads->frame_plan = *frame_plan;
threads->render_fragment_func = render_fragment_func;
threads->context = context;
+ threads->stream = stream;
threads->ticks = ticks;
threads->frame_num++;
threads->n_idle = threads->next_fragment = 0;
© All Rights Reserved