From 6e65558ba9bab7ae6d597f69e800ac839c557599 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Thu, 9 Apr 2026 22:38:29 +0200 Subject: [PATCH] :arrow_up: version bump to v0.3.46 - Update Cargo.toml and version.txt to v0.3.46 - Fix production bug in music renderer autoadvance logic: add fallback timeout (20s) to compensate for missed PLAYING events due DB latency - Update Cargo.lock accordingly --- Cargo.lock | 2 +- PMOMusic/Cargo.toml | 2 +- .../src/music_renderer/musicrenderer.rs | 34 ++++++++++++++----- version.txt | 2 +- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef59d884..08e4a773 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "PMOMusic" -version = "0.3.44" +version = "0.3.45" dependencies = [ "axum 0.8.7", "console-subscriber", diff --git a/PMOMusic/Cargo.toml b/PMOMusic/Cargo.toml index 693f6f52..0114ecf7 100644 --- a/PMOMusic/Cargo.toml +++ b/PMOMusic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "PMOMusic" -version = "0.3.45" +version = "0.3.46" edition = "2024" [dependencies] diff --git a/pmocontrol/src/music_renderer/musicrenderer.rs b/pmocontrol/src/music_renderer/musicrenderer.rs index 40376f37..c5490710 100644 --- a/pmocontrol/src/music_renderer/musicrenderer.rs +++ b/pmocontrol/src/music_renderer/musicrenderer.rs @@ -693,14 +693,32 @@ impl MusicRenderer { self.set_playback_source(PlaybackSource::None); self.clear_has_played_flag(); } else if self.is_playing_from_queue() { - // Only auto-advance if we have actually seen a PLAYING state - // since the track was started. This prevents auto-advance on - // transient STOPPED states during track initialization. - if self.check_and_clear_has_played_flag() { - debug!( - renderer = self.info.friendly_name(), - "Renderer stopped after queue-driven playback; advancing" - ); + let has_played = self.check_and_clear_has_played_flag(); + + // ✅ CORRECTION BUG PRODUCTION: Garde fou contre latence DB + // Si la base de données est saturée (mutex >400ms) on rate parfois l'événement PLAYING. + // On autorise l'auto-avance si: + // 1. On a bien vu PLAYING OU + // 2. Le titre a été lancé depuis plus de 20 secondes + let track_start = self.state.lock().unwrap().track_start_time; + let elapsed = track_start + .and_then(|t| t.elapsed().ok()) + .unwrap_or_default(); + let force_advance = elapsed.as_secs() > 20; + + if has_played || force_advance { + if force_advance { + debug!( + renderer = self.info.friendly_name(), + elapsed_sec = elapsed.as_secs(), + "⚠️ On force l'auto-avance: on a raté l'événement PLAYING (latence DB)" + ); + } else { + debug!( + renderer = self.info.friendly_name(), + "Renderer stopped after queue-driven playback; advancing" + ); + } // Use catch_unwind to prevent panics in play_next_from_queue // from poisoning the backend mutex // Also add retry logic for transient errors from renderer diff --git a/version.txt b/version.txt index 5d8b11af..b9c7814c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.45 +0.3.46