summaryrefslogtreecommitdiff
path: root/src/til_module_context.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_module_context.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_module_context.c')
-rw-r--r--src/til_module_context.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/til_module_context.c b/src/til_module_context.c
index 9767d96..58de3d5 100644
--- a/src/til_module_context.c
+++ b/src/til_module_context.c
@@ -6,6 +6,7 @@
#include "til.h"
#include "til_jenkins.h"
#include "til_module_context.h"
+#include "til_stream.h"
/* Allocate and initialize a new til_module_context_t of size bytes.
@@ -27,7 +28,7 @@
*
* path must not be NULL, and the context takes ownership of the path; it's freed @ context_free().
*/
-void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path)
+void * til_module_context_new(til_stream_t *stream, size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path)
{
til_module_context_t *module_context;
@@ -39,6 +40,7 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
if (!module_context)
return NULL;
+ module_context->stream = stream;
module_context->seed = seed;
module_context->ticks = ticks;
module_context->n_cpus = n_cpus;
@@ -56,12 +58,14 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
*/
void * til_module_context_free(til_module_context_t *module_context)
{
- char *path;
+ char *path;
+ til_stream_t *stream;
if (!module_context)
return NULL;
path = module_context->path; /* free last just in case the module destructor makes use of it */
+ stream = module_context->stream;
if (module_context->module->destroy_context)
module_context->module->destroy_context(module_context);
@@ -70,5 +74,12 @@ void * til_module_context_free(til_module_context_t *module_context)
free(path);
+ /* cleanup any pipes this context might have had in the stream, if the
+ * module's destroy_context() also does this it's harmlessly idempotent
+ * besides wasting some cycles. But by always doing it here, we're sure
+ * to not leave dangling references.
+ */
+ til_stream_untap_owner(stream, module_context);
+
return NULL;
}
© All Rights Reserved