From 46c9146f342fdbda98e1be9dfcf1d1b94ec97648 Mon Sep 17 00:00:00 2001 From: bnnm Date: Mon, 15 Mar 2021 22:48:43 +0100 Subject: [PATCH] Fix Ogg looping with wrong granules properly [Aristear Remain (PC)] --- src/coding/ogg_vorbis_decoder.c | 4 ++-- src/meta/ogg_vorbis.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coding/ogg_vorbis_decoder.c b/src/coding/ogg_vorbis_decoder.c index 43d29254..5f8a43d6 100644 --- a/src/coding/ogg_vorbis_decoder.c +++ b/src/coding/ogg_vorbis_decoder.c @@ -201,8 +201,8 @@ void decode_ogg_vorbis(ogg_vorbis_codec_data* data, sample_t* outbuf, int32_t sa pcm_convert_float_to_16(channels, outbuf, start, rc, pcm_channels, data->disable_reordering); - outbuf += rc * channels; - samples_done += rc; + outbuf += (rc - start) * channels; + samples_done += (rc - start); #if 0 // alt decoding diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index 01063380..a7ea89a4 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -545,7 +545,7 @@ VGMSTREAM* init_vgmstream_ogg_vorbis_callbacks(STREAMFILE* sf, ov_callbacks* cal loop_flag = (loop_start >= 0); } else if (strstr(comment,"COMMENT=- loopTime ") == comment) { /* Aristear Remain (PC) */ - loop_start = atol(strrchr(comment,' ')+1) * sample_rate / 1000.0f; /* ms to samples */ + loop_start = atol(strrchr(comment,' ')+1) / 1000.0f * sample_rate; /* ms to samples */ loop_flag = (loop_start >= 0); /* files have all page granule positions -1 except a few close to loop. This throws off