Compare commits

...
2 Commits
Author SHA1 Message Date
Ansho Rei 8255e39047 fix: show a new track started at the index that was playing
The player reported a track only when the queue index changed, to drop
the repeat stream-start messages playbin posts for one track. Starting
another album at the same index (track 1 after track 1) therefore sent
no event: the app kept the old track on screen, and pause said nothing
was playing, because it had cleared the current track while waiting
for that event.

A stream-start that begins a track the player was asked to start is now
always reported. Only repeats within one track are dropped, and the app
treats every report as a new play, so replaying the current track
resets its position and scrobbles again.
2026-11-04 09:36:04 +01:00
Ansho Rei 8f8004c205 build: bump versions only on local master
A bump amends and tags the last commit, so made on a feature branch it
tags a commit that master may never contain. The targets now refuse any
branch but master, and a detached HEAD.
2026-11-04 09:24:54 +01:00
8 changed files with 72 additions and 19 deletions
+7
View File
@@ -2,6 +2,13 @@
One section per version, newest first. One section per version, newest first.
## v0.2.1 (2026-11-04)
### Bug fixes
- Starting a track from another album at the same position as the one playing, such as track 1 after track 1, now shows the new track and its cover. Pause works straight away instead of saying nothing is playing.
- Replaying the track that is playing counts as a new play: its position resets and the server is told it is playing.
## v0.2.0 (2026-11-04) ## v0.2.0 (2026-11-04)
### Features ### Features
Generated
+1 -1
View File
@@ -4385,7 +4385,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]] [[package]]
name = "remus" name = "remus"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"directories", "directories",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "remus" name = "remus"
version = "0.2.0" version = "0.2.1"
edition = "2024" edition = "2024"
license = "MIT" license = "MIT"
+10 -3
View File
@@ -113,6 +113,8 @@ branding: ## Regenerate the logo SVGs and render the PNGs (needs inkscape)
PACKAGE = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^name *= *"/{print $$2; exit}' Cargo.toml) PACKAGE = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^name *= *"/{print $$2; exit}' Cargo.toml)
CURRENT = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^version *= *"/{print $$2; exit}' Cargo.toml) CURRENT = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^version *= *"/{print $$2; exit}' Cargo.toml)
METAINFO = flatpak/$(FLATPAK_ID).metainfo.xml METAINFO = flatpak/$(FLATPAK_ID).metainfo.xml
# Versions are only made here, so a tag never lands on a commit that is not on it.
BUMP_BRANCH = master
.PHONY: version .PHONY: version
version: ## Print the current version version: ## Print the current version
@@ -128,13 +130,18 @@ minor: bump ## Bump for a feature: amend into the last commit and tag it
major: bump ## Bump for a breaking change, decided by hand major: bump ## Bump for a breaking change, decided by hand
# Folds the bump into the last commit and tags it, as one action, so there is # Folds the bump into the last commit and tags it, as one action, so there is
# never a bump without a tag or a tag without a bump. Refuses anything that # never a bump without a tag or a tag without a bump. Refuses any branch but
# would make rewriting that commit lose work, orphan a tag or need a force push, # BUMP_BRANCH, anything that would make rewriting that commit lose work, orphan
# and a version CHANGELOG.md does not describe yet. # a tag or need a force push, and a version CHANGELOG.md does not describe yet.
.PHONY: bump .PHONY: bump
bump: bump:
@set -e; \ @set -e; \
if [ -z "$(BUMP)" ]; then echo "error: run make patch, make minor or make major" >&2; exit 1; fi; \ if [ -z "$(BUMP)" ]; then echo "error: run make patch, make minor or make major" >&2; exit 1; fi; \
branch=$$(git symbolic-ref --quiet --short HEAD || true); \
if [ "$$branch" != "$(BUMP_BRANCH)" ]; then \
echo "error: versions are only bumped on local $(BUMP_BRANCH), and this is $${branch:-a detached HEAD}. Fast-forward $(BUMP_BRANCH) to this work, switch to it, then bump." >&2; \
exit 1; \
fi; \
if ! git rev-parse -q --verify HEAD >/dev/null 2>&1; then \ if ! git rev-parse -q --verify HEAD >/dev/null 2>&1; then \
echo "error: no commits yet, so there is no commit to fold a version bump into. Commit first." >&2; \ echo "error: no commits yet, so there is no commit to fold a version bump into. Commit first." >&2; \
exit 1; \ exit 1; \
+1
View File
@@ -90,4 +90,5 @@ Every finished ticket bumps the version, so a build on the Deck can be matched t
- `make patch` for a bug fix, `make minor` for a feature, `make major` only when a breaking change has been decided. - `make patch` for a bug fix, `make minor` for a feature, `make major` only when a breaking change has been decided.
- Before bumping, add a `## v<new> (<date>)` entry at the top of `CHANGELOG.md`, with `### Features` and `### Bug fixes` subsections (leave out an empty one), and commit it with the change. `make version` prints the current version. - Before bumping, add a `## v<new> (<date>)` entry at the top of `CHANGELOG.md`, with `### Features` and `### Bug fixes` subsections (leave out an empty one), and commit it with the change. `make version` prints the current version.
- Bump on local `master` only: fast-forward `master` to the finished work, switch to it, then bump. The targets refuse any other branch.
- The bump writes the new version to `Cargo.toml`, `Cargo.lock` and the Flatpak metainfo, amends that into the last commit and tags it `v<new>`. It refuses a dirty tree, a commit that is already tagged or pushed, and a version the changelog has no entry for. - The bump writes the new version to `Cargo.toml`, `Cargo.lock` and the Flatpak metainfo, amends that into the last commit and tags it `v<new>`. It refuses a dirty tree, a commit that is already tagged or pushed, and a version the changelog has no entry for.
@@ -20,6 +20,7 @@
</supports> </supports>
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<releases> <releases>
<release version="0.2.1" date="2026-11-04"/>
<release version="0.2.0" date="2026-11-04"/> <release version="0.2.0" date="2026-11-04"/>
<release version="0.1.0" date="2026-11-04"/> <release version="0.1.0" date="2026-11-04"/>
</releases> </releases>
+2 -3
View File
@@ -1519,10 +1519,9 @@ impl App {
self.ui.set_np_paused(p); self.ui.set_np_paused(p);
} }
PlayerEvent::Track(t) => { PlayerEvent::Track(t) => {
// Reported once per track started, so the same index again is a
// new play: another queue started there, or the track replayed.
let t = t.filter(|&i| i < self.queue.len()); let t = t.filter(|&i| i < self.queue.len());
if t == self.current {
return;
}
self.current = t; self.current = t;
self.position = 0.0; self.position = 0.0;
self.scrobbled = false; self.scrobbled = false;
+47 -9
View File
@@ -182,10 +182,12 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
let Some(bus) = playbin.bus() else { return }; let Some(bus) = playbin.bus() else { return };
let mut last_tick = Instant::now(); let mut last_tick = Instant::now();
let mut duration = 0.0; let mut duration = 0.0;
// playbin can post stream-start more than once for one track. // playbin can post stream-start more than once for one track, so a repeat
// of the last report is dropped. A track that was just started is always
// reported, even at the same index: a new queue, or the same track again.
let mut last_track: Option<Option<usize>> = None; let mut last_track: Option<Option<usize>> = None;
let mut report_track = |t: Option<usize>| { let mut report_track = |t: Option<usize>, started: bool| {
if last_track != Some(t) { if started || last_track != Some(t) {
last_track = Some(t); last_track = Some(t);
emit(PlayerEvent::Track(t)); emit(PlayerEvent::Track(t));
emit(PlayerEvent::Position(0.0)); emit(PlayerEvent::Position(0.0));
@@ -196,15 +198,19 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
use gst::MessageView; use gst::MessageView;
match msg.view() { match msg.view() {
MessageView::StreamStart(_) => { MessageView::StreamStart(_) => {
let current = { let (current, started) = {
let mut q = lock(queue); let mut q = lock(queue);
if let Some(p) = q.pending.take() { let started = match q.pending.take() {
Some(p) => {
q.current = Some(p); q.current = Some(p);
true
} }
q.current None => false,
};
(q.current, started)
}; };
duration = 0.0; duration = 0.0;
report_track(current); report_track(current, started);
} }
MessageView::StateChanged(s) if s.src() == Some(playbin.upcast_ref()) => match s.current() { MessageView::StateChanged(s) if s.src() == Some(playbin.upcast_ref()) => match s.current() {
gst::State::Playing => emit(PlayerEvent::Paused(false)), gst::State::Playing => emit(PlayerEvent::Paused(false)),
@@ -218,7 +224,7 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
q.pending = None; q.pending = None;
} }
let _ = playbin.set_state(gst::State::Ready); let _ = playbin.set_state(gst::State::Ready);
report_track(None); report_track(None, false);
} }
MessageView::Error(err) => { MessageView::Error(err) => {
let detail = err.debug().map(|d| d.to_string()).unwrap_or_default(); let detail = err.debug().map(|d| d.to_string()).unwrap_or_default();
@@ -239,7 +245,7 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
start(playbin, &url); start(playbin, &url);
} else { } else {
let _ = playbin.set_state(gst::State::Ready); let _ = playbin.set_state(gst::State::Ready);
report_track(None); report_track(None, false);
} }
} }
_ => {} _ => {}
@@ -357,4 +363,36 @@ mod tests {
let _ = std::fs::remove_dir_all(&dir); let _ = std::fs::remove_dir_all(&dir);
assert_eq!(tracks, vec![Some(0), Some(1), None]); assert_eq!(tracks, vec![Some(0), Some(1), None]);
} }
#[test]
fn starting_at_the_playing_index_reports_the_track_again() {
// SAFETY: set before any thread reads the environment in this test.
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
let dir = std::env::temp_dir().join(format!("remus-player-restart-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
// Long enough that nothing finishes while the test runs.
let album_a = vec![silent_wav(&dir, "a1.wav", 10.0), silent_wav(&dir, "a2.wav", 10.0)];
let album_b = vec![silent_wav(&dir, "b1.wav", 10.0), silent_wav(&dir, "b2.wav", 10.0)];
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Track(t) = ev {
let _ = tx.send(t);
}
})
.unwrap();
let next = || rx.recv_timeout(Duration::from_secs(3)).ok();
player.play_list(&album_a, 0);
assert_eq!(next(), Some(Some(0)), "first album started");
// Another album, started at the same index as the track playing.
player.play_list(&album_b, 0);
assert_eq!(next(), Some(Some(0)), "second album started at the same index");
// The playing track started again from the queue.
player.play_index(0);
assert_eq!(next(), Some(Some(0)), "the same track restarted");
drop(player);
let _ = std::fs::remove_dir_all(&dir);
}
} }