From c748e9ddc66492d0b01d2a13b5fc46f97c20b73c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 18 Aug 2023 21:10:52 -0700 Subject: til_stream: introduce a per-stream frame counter This adds til_stream_start_frame() which advances a per-stream counter. Subsequent commits will make use of this for implementing a pre-frame competition for pipe ownership. --- src/til_stream.c | 9 +++++++++ src/til_stream.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/til_stream.c b/src/til_stream.c index 247dbf3..c508e35 100644 --- a/src/til_stream.c +++ b/src/til_stream.c @@ -92,6 +92,7 @@ struct til_stream_module_context_t { typedef struct til_stream_t { pthread_mutex_t mutex; volatile int ended; + unsigned frame; const til_stream_hooks_t *hooks; void *hooks_context; til_stream_pipe_t *pipe_buckets[TIL_STREAM_PIPE_BUCKETS_COUNT]; @@ -129,6 +130,14 @@ int til_stream_active(til_stream_t *stream) } +void til_stream_start_frame(til_stream_t *stream) +{ + assert(stream); + + stream->frame++; +} + + til_stream_t * til_stream_free(til_stream_t *stream) { unsigned leaked; diff --git a/src/til_stream.h b/src/til_stream.h index f9717af..54bbdc5 100644 --- a/src/til_stream.h +++ b/src/til_stream.h @@ -48,6 +48,7 @@ til_stream_t * til_stream_new(void); til_stream_t * til_stream_free(til_stream_t *stream); void til_stream_end(til_stream_t *stream); int til_stream_active(til_stream_t *stream); +void til_stream_start_frame(til_stream_t *stream); int til_stream_set_hooks(til_stream_t *stream, const til_stream_hooks_t *hooks, void *context); int til_stream_unset_hooks(til_stream_t *stream, const til_stream_hooks_t *hooks); -- cgit v1.2.1