From ff699d220f5c1a0ad57a1e392d8a41e196298ef4 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 4 Apr 2026 01:03:45 +0200 Subject: [PATCH] :wrench: Add #[allow(dead_code)] to unused items - Suppress dead code warnings for utility functions, enums and traits not yet used in production - Reorganize imports to follow module conventions (e.g., `DeviceIdentity` moved earlier in openhome_renderer.rs) - Improve formatting of ClientMessage variants for readability These changes prepare codebase groundwork without altering runtime behavior. --- pmoaudio-ext/src/sinks/broadcast_pacing.rs | 1 + pmoaudio-ext/src/sinks/flac_frame_utils.rs | 1 + pmoaudio/src/nodes/flac_file_sink.rs | 2 ++ pmocontrol/src/music_renderer/capabilities.rs | 2 ++ .../src/music_renderer/musicrenderer.rs | 1 + pmocontrol/src/music_renderer/openhome.rs | 5 +++- .../src/music_renderer/openhome_renderer.rs | 9 ++++--- pmocontrol/src/music_renderer/watcher.rs | 1 + pmocontrol/src/queue/interne.rs | 1 + pmocontrol/src/registry.rs | 1 + .../src/upnp_clients/openhome_client.rs | 4 +++ pmoplaylist/src/persistence/mod.rs | 1 + pmowebrenderer/src/messages.rs | 25 +++++++++++++++---- 13 files changed, 44 insertions(+), 10 deletions(-) diff --git a/pmoaudio-ext/src/sinks/broadcast_pacing.rs b/pmoaudio-ext/src/sinks/broadcast_pacing.rs index 073ffc4f..72180f4e 100644 --- a/pmoaudio-ext/src/sinks/broadcast_pacing.rs +++ b/pmoaudio-ext/src/sinks/broadcast_pacing.rs @@ -38,6 +38,7 @@ impl BroadcastPacer { } /// Reset the pacer clock (call when audio timestamp resets to 0). + #[allow(dead_code)] pub fn reset(&mut self) { self.start_time = Instant::now(); trace!("{} broadcaster: pacer reset", self.label); diff --git a/pmoaudio-ext/src/sinks/flac_frame_utils.rs b/pmoaudio-ext/src/sinks/flac_frame_utils.rs index 6c7cf0b6..7698ad32 100644 --- a/pmoaudio-ext/src/sinks/flac_frame_utils.rs +++ b/pmoaudio-ext/src/sinks/flac_frame_utils.rs @@ -296,6 +296,7 @@ pub(crate) fn validate_frame_header_crc(data: &[u8], offset: usize) -> bool { /// keeping the data from the last sync code onward for the next iteration. /// /// We need at least 2 validated sync codes to identify one complete frame. +#[allow(dead_code)] pub(crate) fn find_complete_frames_boundary(data: &[u8]) -> usize { if data.len() < 4 { return 0; diff --git a/pmoaudio/src/nodes/flac_file_sink.rs b/pmoaudio/src/nodes/flac_file_sink.rs index 124b6ad5..204d6bbc 100755 --- a/pmoaudio/src/nodes/flac_file_sink.rs +++ b/pmoaudio/src/nodes/flac_file_sink.rs @@ -32,6 +32,7 @@ use tokio_util::sync::CancellationToken; // ═══════════════════════════════════════════════════════════════════════════ /// Signal retourné par pump_segments indiquant pourquoi l'encodage s'est arrêté. +#[allow(dead_code)] enum StopReason { TrackBoundary(Arc>), EndOfStream, @@ -418,6 +419,7 @@ async fn wait_for_first_audio_chunk_with_metadata( } /// Pompe les segments pour une seule track (s'arrête au TrackBoundary). +#[allow(dead_code)] async fn pump_track_segments( first_segment: Arc, rx: &mut mpsc::Receiver>, diff --git a/pmocontrol/src/music_renderer/capabilities.rs b/pmocontrol/src/music_renderer/capabilities.rs index c93cad36..1f4b049e 100644 --- a/pmocontrol/src/music_renderer/capabilities.rs +++ b/pmocontrol/src/music_renderer/capabilities.rs @@ -17,11 +17,13 @@ pub trait RendererBackend { /// /// These operations combine queue management with transport control, /// allowing navigation (next/previous) and track selection from the queue. +#[allow(dead_code)] pub trait QueueTransportControl { /// Play the next track from the queue. fn play_next(&self) -> Result<(), ControlPointError>; /// Play the previous track from the queue. + #[allow(dead_code)] fn play_previous(&self) -> Result<(), ControlPointError>; /// Play from the queue at the current index (or initialize to 0 if not set). diff --git a/pmocontrol/src/music_renderer/musicrenderer.rs b/pmocontrol/src/music_renderer/musicrenderer.rs index 515e4390..52749b47 100644 --- a/pmocontrol/src/music_renderer/musicrenderer.rs +++ b/pmocontrol/src/music_renderer/musicrenderer.rs @@ -810,6 +810,7 @@ impl MusicRenderer { /// Acquires the backend mutex with a default context message. /// /// Convenience wrapper around `lock_backend_for` for simple cases. + #[allow(dead_code)] fn lock_backend(&self) -> std::sync::MutexGuard<'_, MusicRendererBackend> { self.lock_backend_for("unknown operation") } diff --git a/pmocontrol/src/music_renderer/openhome.rs b/pmocontrol/src/music_renderer/openhome.rs index 000d0cc2..41ce1ab9 100644 --- a/pmocontrol/src/music_renderer/openhome.rs +++ b/pmocontrol/src/music_renderer/openhome.rs @@ -16,6 +16,7 @@ pub enum OhServiceKind { } impl OhServiceKind { + #[allow(dead_code)] pub fn as_str(&self) -> &'static str { match self { OhServiceKind::Playlist => "playlist", @@ -60,10 +61,12 @@ pub fn control_url_for(info: &RendererInfo, kind: OhServiceKind) -> Option Option { endpoint_for(info, kind).map(|endpoint| endpoint.service_type) } +#[allow(dead_code)] pub fn build_playlist_client(info: &RendererInfo) -> Option { let endpoint = endpoint_for(info, OhServiceKind::Playlist)?; Some(OhPlaylistClient::new( @@ -114,8 +117,8 @@ pub fn build_radio_client(info: &RendererInfo) -> Option { mod tests { use super::*; use crate::{ - DeviceId, model::{RendererCapabilities, RendererInfo, RendererProtocol}, + DeviceId, }; fn sample_renderer_info() -> RendererInfo { diff --git a/pmocontrol/src/music_renderer/openhome_renderer.rs b/pmocontrol/src/music_renderer/openhome_renderer.rs index fdef765e..b83ea713 100644 --- a/pmocontrol/src/music_renderer/openhome_renderer.rs +++ b/pmocontrol/src/music_renderer/openhome_renderer.rs @@ -1,25 +1,25 @@ use std::sync::{Arc, Mutex}; use std::time::SystemTime; -use crate::DeviceIdentity; use crate::music_renderer::capabilities::{ PlaybackPosition, PlaybackPositionInfo, PlaybackStatus, QueueTransportControl, RendererBackend, TransportControl, VolumeControl, }; use crate::music_renderer::time_utils::{format_hhmmss_u32, parse_time_flexible}; +use crate::DeviceIdentity; use crate::errors::ControlPointError; use crate::model::{PlaybackState, RendererInfo}; -use crate::music_renderer::RendererFromMediaRendererInfo; use crate::music_renderer::musicrenderer::MusicRendererBackend; use crate::music_renderer::openhome::{ build_info_client, build_playlist_client, build_product_client, build_radio_client, build_time_client, build_volume_client, }; +use crate::music_renderer::RendererFromMediaRendererInfo; use crate::queue::{EnqueueMode, MusicQueue, PlaybackItem, QueueBackend, QueueSnapshot}; use crate::upnp_clients::{ - OPENHOME_PLAYLIST_HEAD_ID, OhInfoClient, OhPlaylistClient, OhProductClient, OhRadioClient, - OhTimeClient, OhVolumeClient, + OhInfoClient, OhPlaylistClient, OhProductClient, OhRadioClient, OhTimeClient, OhVolumeClient, + OPENHOME_PLAYLIST_HEAD_ID, }; use tracing::debug; @@ -500,6 +500,7 @@ impl PlaybackPosition for OpenHomeRenderer { } /// Parse duration from DIDL-Lite metadata XML (OpenHome version) +#[allow(dead_code)] fn parse_didl_duration_openhome(didl: &str) -> Option { // Search for duration attribute in element let res_start = didl.find(" Option { let s = s.trim(); if s.is_empty() { diff --git a/pmocontrol/src/queue/interne.rs b/pmocontrol/src/queue/interne.rs index 2834212a..e3a1b0fa 100644 --- a/pmocontrol/src/queue/interne.rs +++ b/pmocontrol/src/queue/interne.rs @@ -145,6 +145,7 @@ impl InternalQueue { /// Fusionne les métadonnées en protégeant les streams contre la diminution de durée. /// Pour les streams continus, si c'est la même chanson (même titre ET même artiste ET même URI), /// la durée ne peut jamais diminuer. + #[allow(dead_code)] fn merge_metadata_protecting_streams( old_metadata: &Option, new_metadata: &Option, diff --git a/pmocontrol/src/registry.rs b/pmocontrol/src/registry.rs index 1c931863..2e8a086d 100644 --- a/pmocontrol/src/registry.rs +++ b/pmocontrol/src/registry.rs @@ -13,6 +13,7 @@ use crate::{ const DEFAULT_MAX_AGE: u32 = 1800; +#[allow(dead_code)] #[derive(Debug, Clone)] pub struct DeviceItem { music_renderer: Option>, diff --git a/pmocontrol/src/upnp_clients/openhome_client.rs b/pmocontrol/src/upnp_clients/openhome_client.rs index 6d8d0af0..0330de39 100644 --- a/pmocontrol/src/upnp_clients/openhome_client.rs +++ b/pmocontrol/src/upnp_clients/openhome_client.rs @@ -1001,6 +1001,8 @@ pub fn parse_track_metadata_from_didl(xml: &str) -> Option { }) } +/// Extracts the ID from DIDL-Lite XML metadata. +#[allow(dead_code)] pub fn didl_id_from_metadata(xml: &str) -> Option { if xml.trim().is_empty() { return None; @@ -1115,6 +1117,8 @@ fn parse_product_source_list(xml: &str) -> Result> { Ok(sources) } +/// Check if error is an invalid OpenHome entry ID error. +#[allow(dead_code)] fn is_invalid_entry_id_error(err: &ControlPointError) -> bool { let msg = format!("{err}"); msg.contains("Invalid OpenHome Entry Id") || msg.contains("comma-separated IDs") diff --git a/pmoplaylist/src/persistence/mod.rs b/pmoplaylist/src/persistence/mod.rs index 092ee435..bb6ccaaf 100644 --- a/pmoplaylist/src/persistence/mod.rs +++ b/pmoplaylist/src/persistence/mod.rs @@ -333,6 +333,7 @@ impl PersistenceManager { } /// Supprime tous les tracks contenant un cache_pk donné + #[allow(dead_code)] pub async fn remove_by_cache_pk(&self, cache_pk: &str) -> Result<()> { let conn = self.conn.lock().unwrap(); conn.execute("DELETE FROM tracks WHERE cache_pk = ?1", params![cache_pk]) diff --git a/pmowebrenderer/src/messages.rs b/pmowebrenderer/src/messages.rs index b8b07db8..4f1cec2c 100644 --- a/pmowebrenderer/src/messages.rs +++ b/pmowebrenderer/src/messages.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; /// Messages envoyés du Backend → Navigateur #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[allow(dead_code)] pub enum ServerMessage { SessionCreated { token: String, @@ -38,6 +39,7 @@ pub enum ServerMessage { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] +#[allow(dead_code)] pub enum TransportAction { Play, Pause, @@ -60,12 +62,25 @@ pub struct CommandParams { /// Messages envoyés du Navigateur → Backend #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[allow(dead_code)] pub enum ClientMessage { - Init { capabilities: BrowserCapabilities }, - StateUpdate { state: PlaybackState }, - PositionUpdate { position: String, duration: String }, - MetadataUpdate { metadata: TrackMetadata }, - VolumeUpdate { volume: u16, mute: bool }, + Init { + capabilities: BrowserCapabilities, + }, + StateUpdate { + state: PlaybackState, + }, + PositionUpdate { + position: String, + duration: String, + }, + MetadataUpdate { + metadata: TrackMetadata, + }, + VolumeUpdate { + volume: u16, + mute: bool, + }, /// Envoyé quand la piste courante se termine naturellement (gapless). /// Le backend fait avancer current → next dans l'état partagé. TrackEnded,