From 991910aa8b186884dc5f0a93ad8365eb35460258 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 21 Dec 2025 20:59:05 -0500
Subject: [PATCH] MIX_SetTrackLoops: change this to "succeed" on stopped
tracks.
This also removes the restriction on fading-out tracks, as that wasn't
actually necessary (but the track will still fade out, perhaps looping as it
does).
---
include/SDL3_mixer/SDL_mixer.h | 9 +++++----
src/SDL_mixer.c | 10 ++--------
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/include/SDL3_mixer/SDL_mixer.h b/include/SDL3_mixer/SDL_mixer.h
index fce192fb..dfa31d7e 100644
--- a/include/SDL3_mixer/SDL_mixer.h
+++ b/include/SDL3_mixer/SDL_mixer.h
@@ -1347,10 +1347,11 @@ extern SDL_DECLSPEC bool SDLCALL MIX_TrackLooping(MIX_Track *track);
* The new loop count replaces any previous state, even if the track has
* already looped.
*
- * This has no effect on a track that is fading out or stopped, and will
- * return false. Stopped tracks can specify a loop count while starting via
- * MIX_PROP_PLAY_LOOPS_NUMBER. This function alters that count in the middle
- * of playback.
+ * This has no effect on a track that is stopped, or rather, starting a
+ * stopped track later will set a new loop count, replacing this value.
+ * Stopped tracks can specify a loop count while starting via
+ * MIX_PROP_PLAY_LOOPS_NUMBER. This function is intended to alter that count
+ * in the middle of playback.
*
* \param track the track to configure.
* \param num_loops new number of times to loop. Zero to disable looping, -1
diff --git a/src/SDL_mixer.c b/src/SDL_mixer.c
index dba481cb..9d72b538 100644
--- a/src/SDL_mixer.c
+++ b/src/SDL_mixer.c
@@ -1908,15 +1908,9 @@ bool MIX_SetTrackLoops(MIX_Track *track, int num_loops)
num_loops = -1; // keep this value consistent if we're looping infinitely.
}
LockTrack(track);
- if (track->state == MIX_STATE_STOPPED) {
- retval = SDL_SetError("Track is not playing");
- } else if (track->fade_direction < 0) {
- retval = SDL_SetError("Track is fading out");
- } else {
- track->loops_remaining = num_loops;
- retval = true;
- }
+ track->loops_remaining = num_loops;
UnlockTrack(track);
+ retval = true;
}
return retval;
}