summaryrefslogtreecommitdiff
path: root/src/mossrose.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-09-04 00:39:24 -0500
committersanine <sanine.not@pm.me>2022-09-04 00:39:24 -0500
commit63db9380f84cb3eb35d2de430b0783afa5773e85 (patch)
treeffc8360c7bc7e670768cbadcf79597c03b9434a2 /src/mossrose.c
parentac48f807cb85423a8063795e3320fedde1ddf5c1 (diff)
implement callbacks
Diffstat (limited to 'src/mossrose.c')
-rw-r--r--src/mossrose.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mossrose.c b/src/mossrose.c
index cd1b98d..2e27c45 100644
--- a/src/mossrose.c
+++ b/src/mossrose.c
@@ -4,6 +4,7 @@
#include <portaudio.h>
#include <mossrose.h>
#include "channel.h"
+#include "sound.h"
struct mossrose_global_t {
@@ -131,8 +132,29 @@ void mossrose_channel_resume(int channel) {
}
+void mossrose_channel_set_callback(int channel, channel_callback_t callback, void *userdata)
+{
+ struct channel_t *chan = mossrose_global.channels + channel;
+ channel_set_callback(chan, callback, userdata);
+}
+
+
+void mossrose_poll_callbacks()
+{
+ for (int i=0; i<mossrose_global.n_channels; i++) {
+ struct channel_t *chan = mossrose_global.channels + i;
+ channel_poll_callbacks(chan, i);
+ }
+}
+
+
int mossrose_terminate()
{
+ for (int i=0; i<mossrose_global.n_channels; i++) {
+ sound_free_audio(&(mossrose_global.channels[i].sound));
+ }
+ free(mossrose_global.channels);
+
Pa_AbortStream(mossrose_global.stream);
Pa_CloseStream(mossrose_global.stream);
Pa_Terminate();