diff options
author | sanine <sanine.not@pm.me> | 2022-09-03 21:32:25 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-09-03 21:32:25 -0500 |
commit | 2cf000fb7cbe653c2e96e0b3b8f3c1425401d3fc (patch) | |
tree | e172ef67b253d1eaa0fb22186b5901edd4de793a /src/channel.c | |
parent | a416cfb6881b8ff99c29ba87c1d940d6143e44b1 (diff) |
add looping
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/channel.c b/src/channel.c index 1d0b63b..8615265 100644 --- a/src/channel.c +++ b/src/channel.c @@ -25,7 +25,12 @@ void channel_init(struct channel_t *chan) void channel_reset(struct channel_t *chan) { - p_atomic_int_set(&(chan->shared.active), false); + chan->pos = 0; + int loops = channel_atomic_get(chan->shared.loops); + if (loops) { + if (p_atomic_int_dec_and_test(&(chan->shared.loops))) + channel_atomic_set(chan->shared.active, false); + } } @@ -63,7 +68,7 @@ void channel_set_pan(struct channel_t *chan, float pan_left, float pan_right) } -int channel_sound_load(struct channel_t *chan, struct mossrose_sound_t *sound, bool force) +int channel_sound_load(struct channel_t *chan, struct mossrose_sound_t *sound, bool force, int loops) { if (!force && channel_atomic_get(chan->shared.active)) /* active, fail! */ @@ -74,6 +79,7 @@ int channel_sound_load(struct channel_t *chan, struct mossrose_sound_t *sound, b chan->pos = 0; p_atomic_int_set(&(chan->shared.paused), false); + p_atomic_int_set(&(chan->shared.loops), loops); if (!force) { /* overwrite channel settings */ |