summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-15 17:10:04 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-21 12:51:53 -0800
commiteb19473f1a5dd412f945a4526cb7834113defa44 (patch)
tree51fb0e12584b7f56e3121b7a749997f59b715b4e
parent68347e96bbac8c60b32895c5214487f58990fea3 (diff)
til_stream: add a second void* to til_stream_pipe_t
It seems likely that pipe owners will need not only a way to differentiate themselves via the owner pointer, but also somewhere to register a pipe-specific reference. There probably needs to be a result pointer added for storing the owner_foo when the owner taps, so the owner can make use of it.
-rw-r--r--src/modules/plato/plato.c4
-rw-r--r--src/modules/stars/stars.c10
-rw-r--r--src/til_stream.c4
-rw-r--r--src/til_stream.h6
4 files changed, 13 insertions, 11 deletions
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index 259d5b0..f952674 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -653,8 +653,8 @@ static void plato_render_fragment(til_module_context_t *context, til_stream_t *s
til_fb_fragment_t *fragment = *fragment_ptr;
/* since we don't automate the rates ourselves, we don't care about the tap return values */
- (void) til_stream_tap_context(stream, context, &ctxt->taps.orbit_rate);
- (void) til_stream_tap_context(stream, context, &ctxt->taps.spin_rate);
+ (void) til_stream_tap_context(stream, context, NULL, &ctxt->taps.orbit_rate);
+ (void) til_stream_tap_context(stream, context, NULL, &ctxt->taps.spin_rate);
ctxt->r += (float)(ticks - context->ticks) * (*ctxt->orbit_rate * .001f);
ctxt->rr += (float)(ticks - context->ticks) * (*ctxt->spin_rate * .001f);
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index d64a3d8..d57de53 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -223,10 +223,10 @@ static void stars_render_fragment(til_module_context_t *context, til_stream_t *s
ctxt->points = tmp_ptr;
}
- if (!til_stream_tap_context(stream, context, &ctxt->taps.rot_angle))
+ if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.rot_angle))
*ctxt->rot_angle+=*ctxt->rot_rate;
- if (!til_stream_tap_context(stream, context, &ctxt->taps.rot_rate)) {
+ if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.rot_rate)) {
// handle rotation parameters
if(*ctxt->rot_angle>M_PI_4)
*ctxt->rot_rate=*ctxt->rot_rate-ctxt->rot_adj;
@@ -235,16 +235,16 @@ static void stars_render_fragment(til_module_context_t *context, til_stream_t *s
}
/* there's no automation of offset_angle */
- (void) til_stream_tap_context(stream, context, &ctxt->taps.offset_angle);
+ (void) til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_angle);
// handle offset parameters
- if (!til_stream_tap_context(stream, context, &ctxt->taps.offset_x)) {
+ if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_x)) {
float tmp_x = (*ctxt->offset_x*cosf(*ctxt->offset_angle))-
(*ctxt->offset_y*sinf(*ctxt->offset_angle));
*ctxt->offset_x = tmp_x;
}
- if (!til_stream_tap_context(stream, context, &ctxt->taps.offset_y)) {
+ if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.offset_y)) {
float tmp_y = (*ctxt->offset_x*sinf(*ctxt->offset_angle))+
(*ctxt->offset_y*cosf(*ctxt->offset_angle));
*ctxt->offset_y = tmp_y;
diff --git a/src/til_stream.c b/src/til_stream.c
index a47f953..5f26c72 100644
--- a/src/til_stream.c
+++ b/src/til_stream.c
@@ -73,6 +73,7 @@ typedef struct til_stream_pipe_t til_stream_pipe_t;
struct til_stream_pipe_t {
til_stream_pipe_t *next;
const void *owner;
+ const void *owner_foo;
char *parent_path;
const til_tap_t *driving_tap;
uint32_t hash;
@@ -127,7 +128,7 @@ til_stream_t * til_stream_free(til_stream_t *stream)
*
* If stream is NULL it's treated as if the key doesn't exist without a pipe creation.
*/
-int til_stream_tap(til_stream_t *stream, const void *owner, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap)
+int til_stream_tap(til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap)
{
uint32_t hash, bucket;
til_stream_pipe_t *pipe;
@@ -173,6 +174,7 @@ int til_stream_tap(til_stream_t *stream, const void *owner, const char *parent_p
}
pipe->owner = owner;
+ pipe->owner_foo = owner_foo;
pipe->driving_tap = tap;
pipe->parent_path = strdup(parent_path);
diff --git a/src/til_stream.h b/src/til_stream.h
index 560cc05..6424537 100644
--- a/src/til_stream.h
+++ b/src/til_stream.h
@@ -29,12 +29,12 @@ til_stream_t * til_stream_new(void);
til_stream_t * til_stream_free(til_stream_t *stream);
/* bare interface for non-module-context owned taps */
-int til_stream_tap(til_stream_t *stream, const void *tap_owner, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap);
+int til_stream_tap(til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap);
/* convenience helper for use within modules */
-static inline int til_stream_tap_context(til_stream_t *stream, const til_module_context_t *module_context, const til_tap_t *tap)
+static inline int til_stream_tap_context(til_stream_t *stream, const til_module_context_t *module_context, const void *owner_foo, const til_tap_t *tap)
{
- return til_stream_tap(stream, module_context, module_context->path, module_context->path_hash, tap);
+ return til_stream_tap(stream, module_context, owner_foo, module_context->path, module_context->path_hash, tap);
}
void til_stream_untap_owner(til_stream_t *stream, const void *owner);
© All Rights Reserved