refactor: clean up unused imports and commented code in audio, jellyfin, main, and tui modules
This commit is contained in:
parent
5d42526121
commit
34292649c3
12
src/audio.rs
12
src/audio.rs
|
@ -4,8 +4,8 @@ use cpal::{Device, Stream, StreamConfig, SampleFormat, SampleRate};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use symphonia::core::audio::Signal;
|
use symphonia::core::audio::Signal;
|
||||||
use symphonia::core::codecs::{Decoder, DecoderOptions};
|
use symphonia::core::codecs::{DecoderOptions};
|
||||||
use symphonia::core::formats::{FormatOptions, FormatReader};
|
use symphonia::core::formats::{FormatOptions};
|
||||||
use symphonia::core::io::MediaSourceStream;
|
use symphonia::core::io::MediaSourceStream;
|
||||||
use symphonia::core::meta::MetadataOptions;
|
use symphonia::core::meta::MetadataOptions;
|
||||||
use symphonia::core::probe::Hint;
|
use symphonia::core::probe::Hint;
|
||||||
|
@ -22,7 +22,6 @@ pub struct AsioPlayer {
|
||||||
volume: f32,
|
volume: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared audio buffer for streaming
|
|
||||||
struct StreamBuffer {
|
struct StreamBuffer {
|
||||||
samples: Vec<f32>,
|
samples: Vec<f32>,
|
||||||
position: usize,
|
position: usize,
|
||||||
|
@ -75,7 +74,6 @@ impl AsioPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.forced_sample_rate = Some(sample_rate);
|
self.forced_sample_rate = Some(sample_rate);
|
||||||
//info!("Forced sample rate set to {} Hz", sample_rate);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +91,8 @@ impl AsioPlayer {
|
||||||
// Download and decode the audio
|
// Download and decode the audio
|
||||||
let (samples, original_sample_rate, channels, duration_ms) = self.download_and_decode(url).await?;
|
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)?;
|
self.setup_stream(samples, original_sample_rate, channels)?;
|
||||||
|
|
||||||
// Store duration
|
|
||||||
self.duration_ms = Some(duration_ms);
|
self.duration_ms = Some(duration_ms);
|
||||||
|
|
||||||
// Start playing
|
// Start playing
|
||||||
|
@ -201,7 +197,7 @@ impl AsioPlayer {
|
||||||
self.start_time = Some(Instant::now() - Duration::from_secs_f32(elapsed_secs));
|
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 {
|
if buffer.paused {
|
||||||
self.paused_position = Some(position);
|
self.paused_position = Some(position);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +349,7 @@ impl AsioPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
//debug!("Decode error: {}", e);
|
//debug!("Decode error: {}", e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,9 +144,7 @@ impl JellyfinClient {
|
||||||
self.config.is_authenticated()
|
self.config.is_authenticated()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn logout(&mut self) -> Result<()> {
|
|
||||||
self.config.clear_auth()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LibraryItem {
|
impl LibraryItem {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use cpal::traits::{HostTrait, DeviceTrait};
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
mod jellyfin;
|
mod jellyfin;
|
||||||
|
@ -15,17 +14,14 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
info!("Starting Jellyfin ASIO Client");
|
info!("Starting Jellyfin ASIO Client");
|
||||||
|
|
||||||
// Load config
|
|
||||||
let mut config = config::Config::load()?;
|
let mut config = config::Config::load()?;
|
||||||
|
|
||||||
// Create Jellyfin client
|
// Create Jellyfin client
|
||||||
let mut jellyfin = jellyfin::JellyfinClient::new(config.clone());
|
let mut jellyfin = jellyfin::JellyfinClient::new(config.clone());
|
||||||
|
|
||||||
// Check if we need to authenticate
|
|
||||||
if !jellyfin.is_authenticated() {
|
if !jellyfin.is_authenticated() {
|
||||||
println!("No saved session found. Please log in.");
|
println!("No saved session found. Please log in.");
|
||||||
|
|
||||||
// Get server URL if not set
|
|
||||||
if config.server_url.is_empty() {
|
if config.server_url.is_empty() {
|
||||||
print!("Enter Jellyfin server URL (e.g., https://jellyfin.example.com): ");
|
print!("Enter Jellyfin server URL (e.g., https://jellyfin.example.com): ");
|
||||||
std::io::stdout().flush()?;
|
std::io::stdout().flush()?;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use anyhow::Result;
|
||||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
|
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
|
||||||
use crossterm::terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen};
|
use crossterm::terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen};
|
||||||
use crossterm::ExecutableCommand;
|
use crossterm::ExecutableCommand;
|
||||||
use ratatui::backend::{Backend, CrosstermBackend};
|
use ratatui::backend::{CrosstermBackend};
|
||||||
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
||||||
use ratatui::style::{Color, Modifier, Style};
|
use ratatui::style::{Color, Modifier, Style};
|
||||||
use ratatui::text::{Line, Span, Text};
|
use ratatui::text::{Line, Span, Text};
|
||||||
|
@ -12,7 +12,7 @@ use std::io::{self, Stdout};
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use::tracing::{debug, info};
|
use::tracing::{debug};
|
||||||
|
|
||||||
use crate::jellyfin::{JellyfinClient, LibraryItem};
|
use crate::jellyfin::{JellyfinClient, LibraryItem};
|
||||||
use crate::player::{Player, PlayerCommand, PlaybackState};
|
use crate::player::{Player, PlayerCommand, PlaybackState};
|
||||||
|
|
Loading…
Reference in a new issue