summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-13 21:01:15 -0400
committerXANTRONIX Development2022-03-13 21:01:15 -0400
commit9d0e543821fc0aeb4cde552f110edbb71153c9f2 (patch)
tree915408d2e1c9c465c3d48fdb357fc487cb35276a
parent80e7e6e258d86f165969b5a366917b72910b8282 (diff)
downloadxas-9d0e543821fc0aeb4cde552f110edbb71153c9f2.tar.gz
xas-9d0e543821fc0aeb4cde552f110edbb71153c9f2.tar.bz2
xas-9d0e543821fc0aeb4cde552f110edbb71153c9f2.zip
Handle EVENT_SET_BANK_INDEX before EVENT_ON
-rw-r--r--include/xas/seq.h4
-rw-r--r--src/seq.c14
2 files changed, 15 insertions, 3 deletions
diff --git a/include/xas/seq.h b/include/xas/seq.h
index de8567e..eabf3e3 100644
--- a/include/xas/seq.h
+++ b/include/xas/seq.h
@@ -9,8 +9,6 @@
#include <xas/spatial.h>
enum xas_seq_event_type {
- XAS_SEQ_EVENT_OFF,
- XAS_SEQ_EVENT_ON,
XAS_SEQ_EVENT_SET_POSITION,
XAS_SEQ_EVENT_SET_HEADING,
XAS_SEQ_EVENT_SET_SPEED,
@@ -20,6 +18,8 @@ enum xas_seq_event_type {
XAS_SEQ_EVENT_SET_BANK_INDEX,
XAS_SEQ_EVENT_SET_PLAYER_FLAGS,
XAS_SEQ_EVENT_SPEECH,
+ XAS_SEQ_EVENT_OFF,
+ XAS_SEQ_EVENT_ON,
XAS_SEQ_EVENT_STOP
};
diff --git a/src/seq.c b/src/seq.c
index eca1144..de56508 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -65,6 +65,18 @@ static xas_seq_event *event_tail(xas_seq_event *head) {
return head;
}
+static inline int event_lt(xas_seq_event *a, xas_seq_event *b) {
+ if (timercmp(&a->timestamp, &b->timestamp, <)) {
+ return 1;
+ } else if (!timercmp(&a->timestamp, &b->timestamp, !=)) {
+ if (a->type < b->type) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static xas_seq_event *event_list_partition(xas_seq_event *head,
xas_seq_event *end,
xas_seq_event **head_new,
@@ -75,7 +87,7 @@ static xas_seq_event *event_list_partition(xas_seq_event *head,
*tail = pivot;
while (cur != pivot) {
- if (timercmp(&cur->timestamp, &pivot->timestamp, <)) {
+ if (event_lt(cur, pivot)) {
if (*head_new == NULL) {
*head_new = cur;
}