We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4904 - logic bug in ogg and opus loop code
Summary: logic bug in ogg and opus loop code
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-18 14:53 UTC by Ozkan Sezer
Modified: 2019-12-18 20:09 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2019-12-18 14:53:31 UTC
There is the following difference between ogg/opus
and flac loop code (second is flac):

     if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
-        ((music->loop_start < music->loop_end) || (music->loop_end == 0)) &&
+        ((music->loop_start < music->loop_end) || (music->loop_end > 0)) &&
          (music->loop_start < full_length) &&
          (music->loop_end <= full_length)) {
         if (music->loop_start < 0) music->loop_start = 0;

The ogg and opus code are from Vitaly Novichkov, the flac version
is from Michael Day (adding them to CC list now.)  Vitaly confirms
that his is incorrect.

I'll be applying the following patch shortly:

diff --git a/src/codecs/music_ogg.c b/src/codecs/music_ogg.c
--- a/src/codecs/music_ogg.c
+++ b/src/codecs/music_ogg.c
@@ -336,7 +336,7 @@ static void *OGG_CreateFromRW(SDL_RWops 
 
     full_length = vorbis.ov_pcm_total(&music->vf, -1);
     if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
-        ((music->loop_start < music->loop_end) || (music->loop_end == 0)) &&
+        ((music->loop_start < music->loop_end) || (music->loop_end > 0)) &&
          (music->loop_start < full_length) &&
          (music->loop_end <= full_length)) {
         if (music->loop_start < 0) music->loop_start = 0;
diff --git a/src/codecs/music_opus.c b/src/codecs/music_opus.c
--- a/src/codecs/music_opus.c
+++ b/src/codecs/music_opus.c
@@ -332,7 +332,7 @@ static void *OPUS_CreateFromRW(SDL_RWops
 
     full_length = opus.op_pcm_total(music->of, -1);
     if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
-        ((music->loop_start < music->loop_end) || (music->loop_end == 0)) &&
+        ((music->loop_start < music->loop_end) || (music->loop_end > 0)) &&
          (music->loop_start < full_length) &&
          (music->loop_end <= full_length)) {
         if (music->loop_start < 0) music->loop_start = 0;
Comment 1 Ozkan Sezer 2019-12-18 14:56:26 UTC
Applied the patch as https://hg.libsdl.org/SDL_mixer/rev/5ad7d1e1ddaa

Closing this.  If you think that there are any mistakes,
please drop a note here.
Comment 2 Michael Day 2019-12-18 20:03:47 UTC
Looks good to me. I think there may be an opportunity to clean this up further after the patch for 4905 is applied.
Comment 3 Ozkan Sezer 2019-12-18 20:09:49 UTC
(In reply to Michael Day from comment #2)
> Looks good to me. I think there may be an opportunity
> to clean this up further

Patches are welcome

>  after the patch for 4905 is applied.

Are you OK'ing #4905? (Didn't see any note from you in there.)