summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-01-19 22:48:33 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-01-21 13:33:27 -0800
commit12e2ea7549ba86893104e1b8117a2ceb50d0ebf2 (patch)
treeb6c3669bc3ff2342575b9cd8e287c964b706bffc
parentbc2a41d33785b744181ef2fee7fb05a9525c4900 (diff)
til_{tap,stream}: introduce til_tap_t.inactive
When a driving tap becomes inactive, til_stream_tap() should be able to notice and replace the driver. An example driving tap becoming inactive would be a GNU Rocket track that once had keys in it, but then had them all deleted. This should set the inactive flag so the tap's automation can take over. This gives the user at the Rocket editor the ability to both take over from the tap automation and surrender control back, by populating vs. emptying the respective track.
-rw-r--r--src/til_stream.c7
-rw-r--r--src/til_tap.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/til_stream.c b/src/til_stream.c
index 60c28d4..4109d8f 100644
--- a/src/til_stream.c
+++ b/src/til_stream.c
@@ -163,11 +163,14 @@ int til_stream_tap(til_stream_t *stream, const void *owner, const void *owner_fo
return -1;
}
- /* this looks to be our pipe, but we're not driving */
+ /* this looks to be the pipe, but we're not driving, should we be? */
+ if (pipe->driving_tap->inactive)
+ pipe->driving_tap = tap;
+
*(tap->ptr) = pipe->driving_tap->elems;
pthread_mutex_unlock(&stream->mutex);
- return 1;
+ return (tap != pipe->driving_tap);
}
}
}
diff --git a/src/til_tap.h b/src/til_tap.h
index 6fa47f4..4c0c589 100644
--- a/src/til_tap.h
+++ b/src/til_tap.h
@@ -69,7 +69,8 @@ typedef struct til_tap_t {
size_t n_elems; /* when > 1, *ptr is an array of n_elems elements. Otherwise individual variable. */
void *elems; /* points at the first element of type type, may or may not be an array of them */
const char *name;
- uint32_t name_hash; /* cached hash of name, set once @ initialization */
+ uint32_t name_hash; /* cached hash of name, set once @ initialization */
+ unsigned inactive:1; /* used to signal when a tap should be replaced as driver */
} til_tap_t;
/* just some forward declared higher-order vector and matrix types for the wrappers */
© All Rights Reserved