Skip to content

v0.4.0 — replace a playing player without a gap in the music

Choose a tag to compare

@PortableDiag PortableDiag released this 13 Sep 17:53
· 10 commits to main since this release

You can now swap the player mid-song

./scripts/handover.sh

Starts a second copy alongside the one that is playing, hands the track over, and retires the old one. Measured here: replacement up in 0.5 s while the old one kept playing, and a 34 ms swap — an overlap, not a hole.

This was impossible before, and the reason is worth stating: GApplication is single-instance, so launching Gapless while it is running hands the request to the copy already there and exits. Right for a desktop launcher; it also meant the only way to replace the player was to kill it first and stand in silence until the new one came up.

--new-instance run a second copy instead of deferring to the first
--api-port N listen elsewhere for this run, since the outgoing copy still owns the configured port. Not saved.

The order is deliberate: the replacement is pre-rolled paused at the right position so its pipeline is already built, then it plays as the old one pauses, back to back. A listener notices silence, not a brief doubling.

audio_sink in /api/status

The element autoaudiosink actually chose. This exists because of a real failure the same day: after an in-place update the player reported playing: true with the position climbing and no audio stream attached to the sink at all. Two minutes of silence, and nothing the player exposed could tell that apart from working — the pipeline's own state says PLAYING either way.

POST /api/listen {port}

Moves the API at run time, so a handover's replacement takes the configured port once the old copy is gone.

Fixed

A single wrong type in state.json silently reset every setting. One bad field fails the whole parse, and the loader swallowed the error — volume, resume point, API port, all quietly back to defaults and indistinguishable from the file having been deleted. It now names the file and the reason, and leaves it alone.

cargo test 34/34 · verify.sh 6/6 · verify-resume.sh 4/4 · verify-mpris-modes.sh 4/4 · verify-api.sh 44/44 · verify-input.sh 9/9