Skip to content

Fix tracks not stopping#2125

Open
madprops wants to merge 1 commit intoTaiko2k:masterfrom
madprops:master
Open

Fix tracks not stopping#2125
madprops wants to merge 1 commit intoTaiko2k:masterfrom
madprops:master

Conversation

@madprops
Copy link
Copy Markdown

@madprops madprops commented May 4, 2026

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!

Fixed tracks not stopping.
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.

Stop after current and queue issues

1 participant