From f460fec5367dd51219c5953e089d954d7f03a6e9 Mon Sep 17 00:00:00 2001 From: e Date: Sat, 20 Jan 2024 20:58:32 -0300 Subject: [PATCH 1/2] stb_vorbis: fix interleaved appends silence at end --- src/stb_vorbis.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stb_vorbis.h b/src/stb_vorbis.h index 8686bdf..22110fc 100644 --- a/src/stb_vorbis.h +++ b/src/stb_vorbis.h @@ -5637,6 +5637,7 @@ int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float int len = num_floats / channels; int n=0; int z = f->channels; + unsigned int lgs=stb_vorbis_stream_length_in_samples(f); if (z > channels) z = channels; while (n < len) { int i,j; @@ -5656,6 +5657,11 @@ int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float break; } f->current_playback_loc += n; + if(f->current_playback_loc > lgs) { + int r = n - (f->current_playback_loc - lgs); + f->current_playback_loc = lgs; + return r; + } return n; } From 833218ad55c429cd8faebb259773e193e55d169c Mon Sep 17 00:00:00 2001 From: e Date: Thu, 7 Mar 2024 09:07:36 -0300 Subject: [PATCH 2/2] stb_vorbis: ensure stream length in samples is valid --- src/stb_vorbis.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stb_vorbis.h b/src/stb_vorbis.h index 22110fc..c68544a 100644 --- a/src/stb_vorbis.h +++ b/src/stb_vorbis.h @@ -5657,7 +5657,7 @@ int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float break; } f->current_playback_loc += n; - if(f->current_playback_loc > lgs) { + if(f->current_playback_loc > lgs && lgs > 0 && lgs != SAMPLE_unknown) { int r = n - (f->current_playback_loc - lgs); f->current_playback_loc = lgs; return r;