Skip to content

Commit 17eb29e

Browse files
attmousclaude
andcommitted
fix: let audio buffer drain on track end instead of clearing it
The decode thread finishes faster than real-time (especially for WAV), so TrackEnded fires while audio is still buffered. Previously, stop_decode() cleared the buffer, cutting off playback. Now when reaching end of tracklist, we let the cpal output thread drain remaining audio naturally. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 308af92 commit 17eb29e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

crates/rustify-core/src/player.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,10 @@ impl CommandLoop {
354354
self.stop_decode();
355355
self.start_decode(uri);
356356
} else {
357-
// End of tracklist
358-
self.stop_decode();
357+
// End of tracklist — let remaining audio drain naturally.
358+
// Don't call stop_decode() which would clear the buffer
359+
// and cut off the last seconds of audio.
360+
self.decode_handle = None;
359361
self.set_state(PlaybackState::Stopped);
360362
*self.shared.current_track.lock().unwrap() = None;
361363
self.shared.time_position_ms.store(0, Ordering::Relaxed);

0 commit comments

Comments
 (0)