From 63db9380f84cb3eb35d2de430b0783afa5773e85 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 4 Sep 2022 00:39:24 -0500 Subject: implement callbacks --- src/channel.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/channel.h') diff --git a/src/channel.h b/src/channel.h index 5be42a2..61a1c7d 100644 --- a/src/channel.h +++ b/src/channel.h @@ -7,6 +7,9 @@ #include +typedef void (*channel_callback_t)(int channel, void *userdata); + + struct channel_shared_t { volatile pint active; /* boolean */ volatile pint paused; /* boolean */ @@ -14,6 +17,7 @@ struct channel_shared_t { volatile pint pan_left; /* -255-255 */ volatile pint pan_right; /* -255-255 */ volatile pint loops; + volatile pint trigger_callback; }; @@ -26,6 +30,9 @@ struct channel_t { PMutex *sound_mutex; struct mossrose_sound_t sound; size_t pos; + + channel_callback_t callback; + void *userdata; }; @@ -35,7 +42,10 @@ void channel_pause(struct channel_t *chan); void channel_resume(struct channel_t *chan); void channel_set_volume(struct channel_t *chan, float volume); void channel_set_pan(struct channel_t *chan, float pan_left, float pan_right); +void channel_set_callback(struct channel_t *chan, channel_callback_t callback, void *userdata); +void channel_poll_callbacks(struct channel_t *chan, int index); int channel_sound_load(struct channel_t *chan, struct mossrose_sound_t *sound, bool force, int loops); +void channel_update_shared(struct channel_t *chan); void channel_get_next_sample(float *left, float *right, struct channel_t *chan); -- cgit v1.2.1