Skip to content

Commit

Permalink
Cleanup (#42)
Browse files Browse the repository at this point in the history
* chore(anni-playback): replace `lazy_static` with `once_cell`

* chore(anni-playback): cleanup unused imports and unsafe impl
  • Loading branch information
snylonue authored Mar 29, 2024
1 parent e767cc3 commit 1033414
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion anni-playback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rangemap = "1.3.0"
arrayvec = "0.7.2"
ebur128 = "0.1.7"
anyhow.workspace = true
lazy_static = "1.4.0"
once_cell.workspace = true
audiopus = { git = "https://github.com/ProjectAnni/audiopus" }
log.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion anni-playback/src/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::{
sync::{atomic::AtomicBool, Arc, RwLock, RwLockReadGuard},
};

use crossbeam::channel::{unbounded, Receiver, Sender};
use crossbeam::channel::unbounded;

use crate::types::*;

Expand Down
4 changes: 1 addition & 3 deletions anni-playback/src/cpal_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl CpalOutputStream {
}
}

fn get_config(spec: SignalSpec) -> anyhow::Result<(Device, StreamConfig)> {
fn get_config(_spec: SignalSpec) -> anyhow::Result<(Device, StreamConfig)> {
let host = cpal::default_host();
let device = host
.default_output_device()
Expand Down Expand Up @@ -283,5 +283,3 @@ impl CpalOutput {
}
}
}

unsafe impl Send for CpalOutput {}
21 changes: 9 additions & 12 deletions anni-playback/src/decoder/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ use std::{
};

use anyhow::{anyhow, Context};
use crossbeam::channel::Receiver;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use symphonia::{
core::{
audio::{AsAudioBufferRef, AudioBuffer},
formats::{FormatOptions, FormatReader, SeekMode, SeekTo},
io::{MediaSource, MediaSourceStream},
io::MediaSourceStream,
meta::MetadataOptions,
probe::Hint,
units::{Time, TimeBase},
Expand All @@ -52,14 +51,12 @@ enum PlaybackState {
Idle,
}

lazy_static! {
static ref CODEC_REGISTRY: CodecRegistry = {
let mut registry = CodecRegistry::new();
register_enabled_codecs(&mut registry);
registry.register_all::<OpusDecoder>();
registry
};
}
static CODEC_REGISTRY: Lazy<CodecRegistry> = Lazy::new(|| {
let mut registry = CodecRegistry::new();
register_enabled_codecs(&mut registry);
registry.register_all::<OpusDecoder>();
registry
});

pub struct Decoder {
thread_killer: Receiver<bool>,
Expand Down Expand Up @@ -193,7 +190,7 @@ impl Decoder {
log::debug!("device changed");
self.controls.pause();
self.cpal_output = None;
}
}
InternalPlayerEvent::Preload(source, buffer_signal) => {
self.preload_playback = None;
self.controls.set_is_file_preloaded(false);
Expand Down

0 comments on commit 1033414

Please sign in to comment.