diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-01-15 21:06:32 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-01-21 12:51:53 -0800 |
commit | bc2a41d33785b744181ef2fee7fb05a9525c4900 (patch) | |
tree | 7615690ff8d7ec33fdb725042f5cf7fd50c4ef76 /src/til_stream.h | |
parent | 14175e11c82a0e9441df797357c8c52acd96b5e0 (diff) |
til_stream: introduce stream iterator et al
In order to implement something like a rocket module there needs
to be a way to iterate the pipes in the stream, and take
owernship of them when not already owned by rocket.
The way rocket's API works is you lookup tracks by name at
runtime. The rocket module will be a meta module that calls into
another module for rendering, arbitrarily configured via a rocket
setting a la checkers::fill_module.
So it won't be until the underlying modules do some rendering
that their taps get their respective pipes established in the
stream. Then the rocket module can look at all the pipes and for
any it doesn't own yet, it can get the tracks for those names and
take ownership while stowing the track handle in owner_foo for
the pipe.
While iterating all the pipes, the pipes already owned will have
the tracks readily available which can produce the values to
stick in the tap.
Something like that anyways, the til_stream_t api changes in this
commit are all preparatory for a rocket module.
Diffstat (limited to 'src/til_stream.h')
-rw-r--r-- | src/til_stream.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/til_stream.h b/src/til_stream.h index 6424537..49e1e58 100644 --- a/src/til_stream.h +++ b/src/til_stream.h @@ -23,8 +23,15 @@ #include "til_module_context.h" typedef struct til_stream_t til_stream_t; +typedef struct til_stream_pipe_t til_stream_pipe_t; typedef struct til_tap_t til_tap_t; +/* since pipe is opaque, pass all the member values too. pipe is still given so + * things can be done to it (like changing the ownership?) + * return 0 to stop iterating, 1 to continue, -errno on error + */ +typedef int (til_stream_iter_func_t)(void *arg, til_stream_pipe_t *pipe, const void *owner, const void *owner_foo, const til_tap_t *driving_tap); + til_stream_t * til_stream_new(void); til_stream_t * til_stream_free(til_stream_t *stream); @@ -40,4 +47,7 @@ static inline int til_stream_tap_context(til_stream_t *stream, const til_module_ void til_stream_untap_owner(til_stream_t *stream, const void *owner); void til_stream_fprint(til_stream_t *stream, FILE *out); +int til_stream_for_each_pipe(til_stream_t *stream, til_stream_iter_func_t pipe_cb, void *cb_arg); +void til_stream_pipe_set_owner(til_stream_pipe_t *pipe, const void *owner, const void *owner_foo); + #endif |