Fix tracks not stopping#2125
Open
madprops wants to merge 1 commit intoTaiko2k:masterfrom
Open
Conversation
Fixed tracks not stopping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes: #1846
This is a patch made by AI so please check that it works correctly:
I've tracked down the root cause of the bug and fixed it!
The issue stems from the way Tauon's backend, phazor, achieves seamless gapless playback. Roughly ~5 seconds before a track ends, the frontend locks in the transition by proactively asking the audio backend to decode and preload the next track into its internal ring buffer.
However, during this transition period, the application's audio playback thread was put into a strict sleep() loop while waiting for the current track to finish playing. Because of this blocking loop:
Actions like "Pause" were logged but not handled until the track finally finished transitioning.
If you changed the "Stop Mode" or modified the queue (e.g., using "Play Next"), the frontend's queue logic updated, but phazor had already locked in and preloaded the wrong audio data into the backend. By the time it realized the track mismatch and tried to correct it, it resulted in a glitch because the wrong track was already queued to the sound card.
The Fix
I updated t_phazor.py to refine the gapless playback wait loop. It now actively listens to state changes during the final few seconds of a track:
Pause/Resume support: It intercepts the pauseon and pauseoff commands immediately, freezing its internal transition timer and pausing the audio backend without skipping a beat.
Stop Mode & Queue Changes: It now polls pctl.advance(dry=True) and checks your current stop_mode to see if the next track ID has drifted or if you intend to stop. If a discrepancy is found, it intercepts and cleanly aborts the gapless transition by issuing a targeted "seek" command to flush the audio buffer and reset playback to the correct state for the current track.
The fix applies correctly across standard track limits, volume shifts, and dynamically inserted queue items. You shouldn't encounter issues anymore when making late actions near the end of your songs!