refactor: clean up unused imports and commented code in audio, jellyfin, main, and tui modules

This commit is contained in:
Mercurio 2025-06-21 23:36:55 +02:00
parent 5d42526121
commit 34292649c3
4 changed files with 7 additions and 17 deletions

View file

@ -4,8 +4,8 @@ use cpal::{Device, Stream, StreamConfig, SampleFormat, SampleRate};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use symphonia::core::audio::Signal;
use symphonia::core::codecs::{Decoder, DecoderOptions};
use symphonia::core::formats::{FormatOptions, FormatReader};
use symphonia::core::codecs::{DecoderOptions};
use symphonia::core::formats::{FormatOptions};
use symphonia::core::io::MediaSourceStream;
use symphonia::core::meta::MetadataOptions;
use symphonia::core::probe::Hint;
@ -22,7 +22,6 @@ pub struct AsioPlayer {
volume: f32,
}
// Shared audio buffer for streaming
struct StreamBuffer {
samples: Vec<f32>,
position: usize,
@ -75,7 +74,6 @@ impl AsioPlayer {
}
self.forced_sample_rate = Some(sample_rate);
//info!("Forced sample rate set to {} Hz", sample_rate);
Ok(())
}
@ -93,10 +91,8 @@ impl AsioPlayer {
// Download and decode the audio
let (samples, original_sample_rate, channels, duration_ms) = self.download_and_decode(url).await?;
// Set up ASIO stream with proper sample rate
self.setup_stream(samples, original_sample_rate, channels)?;
// Store duration
self.duration_ms = Some(duration_ms);
// Start playing
@ -201,7 +197,7 @@ impl AsioPlayer {
self.start_time = Some(Instant::now() - Duration::from_secs_f32(elapsed_secs));
}
if let Some(stream) = &self.stream {
if let Some(_stream) = &self.stream {
if buffer.paused {
self.paused_position = Some(position);
}
@ -353,7 +349,7 @@ impl AsioPlayer {
}
}
}
Err(e) => {
Err(_e) => {
//debug!("Decode error: {}", e);
break;
}

View file

@ -144,9 +144,7 @@ impl JellyfinClient {
self.config.is_authenticated()
}
pub fn logout(&mut self) -> Result<()> {
self.config.clear_auth()
}
}
impl LibraryItem {

View file

@ -1,6 +1,5 @@
use anyhow::Result;
use tracing::info;
use cpal::traits::{HostTrait, DeviceTrait};
use std::io::Write;
mod jellyfin;
@ -15,17 +14,14 @@ async fn main() -> Result<()> {
info!("Starting Jellyfin ASIO Client");
// Load config
let mut config = config::Config::load()?;
// Create Jellyfin client
let mut jellyfin = jellyfin::JellyfinClient::new(config.clone());
// Check if we need to authenticate
if !jellyfin.is_authenticated() {
println!("No saved session found. Please log in.");
// Get server URL if not set
if config.server_url.is_empty() {
print!("Enter Jellyfin server URL (e.g., https://jellyfin.example.com): ");
std::io::stdout().flush()?;

View file

@ -2,7 +2,7 @@ use anyhow::Result;
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
use crossterm::terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen};
use crossterm::ExecutableCommand;
use ratatui::backend::{Backend, CrosstermBackend};
use ratatui::backend::{CrosstermBackend};
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::style::{Color, Modifier, Style};
use ratatui::text::{Line, Span, Text};
@ -12,7 +12,7 @@ use std::io::{self, Stdout};
use std::sync::mpsc::{channel, Receiver, Sender};
use std::time::{Duration, Instant};
use std::thread;
use::tracing::{debug, info};
use::tracing::{debug};
use crate::jellyfin::{JellyfinClient, LibraryItem};
use crate::player::{Player, PlayerCommand, PlaybackState};