🔧 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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<tokio::sync::RwLock<dyn pmometadata::TrackMetadata>>),
|
||||
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<AudioSegment>,
|
||||
rx: &mut mpsc::Receiver<Arc<AudioSegment>>,
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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<Strin
|
||||
endpoint_for(info, kind).map(|endpoint| endpoint.control_url)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn service_type_for(info: &RendererInfo, kind: OhServiceKind) -> Option<String> {
|
||||
endpoint_for(info, kind).map(|endpoint| endpoint.service_type)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn build_playlist_client(info: &RendererInfo) -> Option<OhPlaylistClient> {
|
||||
let endpoint = endpoint_for(info, OhServiceKind::Playlist)?;
|
||||
Some(OhPlaylistClient::new(
|
||||
@@ -114,8 +117,8 @@ pub fn build_radio_client(info: &RendererInfo) -> Option<OhRadioClient> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
DeviceId,
|
||||
model::{RendererCapabilities, RendererInfo, RendererProtocol},
|
||||
DeviceId,
|
||||
};
|
||||
|
||||
fn sample_renderer_info() -> RendererInfo {
|
||||
|
||||
@@ -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<String> {
|
||||
// Search for duration attribute in <res> element
|
||||
let res_start = didl.find("<res ")?;
|
||||
|
||||
@@ -120,6 +120,7 @@ pub fn playback_position_equal(a: &PlaybackPositionInfo, b: &PlaybackPositionInf
|
||||
/// Parse "HH:MM:SS" style time strings to seconds.
|
||||
///
|
||||
/// Returns None for empty or sentinel values such as "NOT_IMPLEMENTED" or "-:--:--".
|
||||
#[allow(dead_code)]
|
||||
fn parse_hms_to_secs(s: &str) -> Option<u64> {
|
||||
let s = s.trim();
|
||||
if s.is_empty() {
|
||||
|
||||
@@ -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<crate::model::TrackMetadata>,
|
||||
new_metadata: &Option<crate::model::TrackMetadata>,
|
||||
|
||||
@@ -13,6 +13,7 @@ use crate::{
|
||||
|
||||
const DEFAULT_MAX_AGE: u32 = 1800;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DeviceItem {
|
||||
music_renderer: Option<Arc<MusicRenderer>>,
|
||||
|
||||
@@ -1001,6 +1001,8 @@ pub fn parse_track_metadata_from_didl(xml: &str) -> Option<TrackMetadata> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Extracts the ID from DIDL-Lite XML metadata.
|
||||
#[allow(dead_code)]
|
||||
pub fn didl_id_from_metadata(xml: &str) -> Option<String> {
|
||||
if xml.trim().is_empty() {
|
||||
return None;
|
||||
@@ -1115,6 +1117,8 @@ fn parse_product_source_list(xml: &str) -> Result<Vec<OhProductSource>> {
|
||||
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")
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user