aboutsummaryrefslogtreecommitdiff
path: root/include/melisma/ring.h
diff options
context:
space:
mode:
authorLudvig Gunne Lindström <ludviggunnelindstrom@gmail.com>2026-07-17 11:42:57 +0200
committerLudvig Gunne Lindström <ludviggunnelindstrom@gmail.com>2026-11-08 14:07:53 +0100
commit98b3c66ebc79597f5b54fff132eaafbebf581248 (patch)
treef999ec466ae3ac635653d1fe0a6a6dd1a2f2c3b0 /include/melisma/ring.h
downloadmelisma-main.tar.gz
Diffstat (limited to 'include/melisma/ring.h')
-rw-r--r--include/melisma/ring.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/melisma/ring.h b/include/melisma/ring.h
new file mode 100644
index 0000000..d69e993
--- /dev/null
+++ b/include/melisma/ring.h
@@ -0,0 +1,40 @@
+/*
+ * melisma - extensible and scriptable audio engine
+ * Copyright (C) 2026 Ludvig Gunne Lindström
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef RING_H
+#define RING_H
+
+#include <stdint.h>
+#include <stdatomic.h>
+
+typedef struct ml_ring ml_ring;
+
+ml_ring *ml_ring_init(size_t len);
+void ml_ring_free(ml_ring *r);
+int ml_ring_empty(ml_ring *r);
+int ml_ring_has_space(ml_ring *r, size_t len);
+int ml_ring_put(ml_ring *r, uint8_t c);
+int ml_ring_get(ml_ring *r, uint8_t *c);
+size_t ml_ring_write(ml_ring *r, const void *ptr, size_t len);
+size_t ml_ring_read(ml_ring *r, void *ptr, size_t len);
+void ml_ring_put_blocking(ml_ring *r, uint8_t c);
+uint8_t ml_ring_get_blocking(ml_ring *r);
+void ml_ring_write_blocking(ml_ring *r, const void *ptr, size_t len);
+void ml_ring_read_blocking(ml_ring *r, void *ptr, size_t len);
+
+#endif