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