From 3bd25b2067b385a0c527a5cd39d065ea07cb5171 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Mon, 8 Jul 2024 09:57:04 +0300 Subject: [PATCH] handling of end of .ogg file --- src/audio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/audio.c b/src/audio.c index 85848fb..4c65621 100644 --- a/src/audio.c +++ b/src/audio.c @@ -180,6 +180,16 @@ static void audio_sample_and_mixin_channel(struct audio_channel *channel, (int16_t *)buffer, n_frames); + /* handle end of file */ + if (samples_per_channel == 0) { + if (channel->args.repeat) + /* seek to start and try sampling some more */ + stb_vorbis_seek_start(channel->context.vorbis.handle); + else + /* leave silence */ + break; + } + /* panning and mixing */ #if AUDIO_N_CHANNELS == 2