Skip to content

Conversation

Sackzement
Copy link
Contributor

Removing a redundant assignment

src/SDL_mixer.c:2104:32: style: Variable 'track->fade_frames' is reassigned a value before the old one has been used. [redundantAssignment]
            track->fade_frames = fadeOut;
                               ^

Introduced in commit:
icculus/SDL_remixer@76ec5d3#diff-66d27914364c2b11bd71a896ac07aca5d1b4cbb91cf4c61aa4ef2b1c093b583cL1131

@@ -1131,12 +1153,15 @@ bool Mix_PlayOnce(Mix_Audio *audio)
 static void HaltTrack(Mix_Track *track, Sint64 fadeOut)
 {
     LockTrack(track);
-    if (fadeOut <= 0) {  // stop immediately.
-        TrackFinished(track);
-    } else {
-        track->fade_frames = fadeOut;
-        track->fade_start_frame = track->position;
-        track->fade_direction = -1;
+    if (track->state != MIX_STATE_STOPPED) {
+        if (fadeOut <= 0) {  // stop immediately.
+            TrackFinished(track);
+        } else {
+            track->total_fade_frames = fadeOut;
+            track->fade_frames = track->total_fade_frames;
+            track->fade_frames = fadeOut;
+            track->fade_direction = -1;
+        }
     }
     UnlockTrack(track);
 }

@sezero sezero requested a review from icculus August 26, 2025 17:34
@sezero sezero merged commit f769879 into libsdl-org:main Aug 29, 2025
5 checks passed
@Sackzement Sackzement deleted the redundant_assign branch August 29, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants