Skip to content

Commit

Permalink
Merge pull request #70 from Polochon-street/cleanup-repo
Browse files Browse the repository at this point in the history
Cleanup deps
  • Loading branch information
Polochon-street authored Dec 28, 2023
2 parents bf35f64 + dc35921 commit ed2dd72
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 120 deletions.
53 changes: 7 additions & 46 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ serde = ["dep:serde"]
# Until https://github.com/aubio/aubio/issues/336 is somehow solved
# Hopefully we'll be able to use the official aubio-rs at some point.
bliss-audio-aubio-rs = "0.2.1"
crossbeam = "0.8.2"
ffmpeg-next = "6.1.0"
ffmpeg-sys-next = { version = "6.1.0", default-features = false }
log = "0.4.17"
# `rayon` is used only by `par_mapv_inplace` in chroma.rs.
# TODO: is the speed gain that substantial?
ndarray = { version = "0.15.6", features = ["rayon"] }
num_cpus = "1.15.0"
ndarray-stats = "0.5.1"
noisy_float = "0.2.0"
ripemd = "0.1.3"
adler32 = "1.0.2"
rustfft = "6.1.0"
thiserror = "1.0.40"
strum = "0.24.1"
Expand Down
6 changes: 3 additions & 3 deletions src/cue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ impl BlissCueFile {
let mut songs = Vec::new();
for (index, tuple) in (self.tracks[..]).windows(2).enumerate() {
let (current_track, next_track) = (tuple[0].to_owned(), tuple[1].to_owned());
if let Some((_, start_current)) = current_track.indices.get(0) {
if let Some((_, end_current)) = next_track.indices.get(0) {
if let Some((_, start_current)) = current_track.indices.first() {
if let Some((_, end_current)) = next_track.indices.first() {
let start_current = (start_current.as_secs_f32() * SAMPLE_RATE as f32) as usize;
let end_current = (end_current.as_secs_f32() * SAMPLE_RATE as f32) as usize;
let duration = Duration::from_secs_f32(
Expand All @@ -176,7 +176,7 @@ impl BlissCueFile {
}
// Take care of the last track, since the windows iterator doesn't.
if let Some(last_track) = self.tracks.last() {
if let Some((_, start_current)) = last_track.indices.get(0) {
if let Some((_, start_current)) = last_track.indices.first() {
let start_current = (start_current.as_secs_f32() * SAMPLE_RATE as f32) as usize;
let duration = Duration::from_secs_f32(
(self.sample_array.len() - start_current) as f32 / SAMPLE_RATE as f32,
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ mod temporal;
mod timbral;
mod utils;

extern crate crossbeam;
extern crate num_cpus;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
Expand Down Expand Up @@ -155,7 +153,7 @@ pub type BlissResult<T> = Result<T, BlissError>;
pub fn analyze_paths<P: Into<PathBuf>, F: IntoIterator<Item = P>>(
paths: F,
) -> mpsc::IntoIter<(PathBuf, BlissResult<Song>)> {
let cores = NonZeroUsize::new(num_cpus::get()).unwrap();
let cores = thread::available_parallelism().unwrap_or(NonZeroUsize::new(1).unwrap());
analyze_paths_with_cores(paths, cores)
}

Expand Down Expand Up @@ -203,7 +201,7 @@ pub fn analyze_paths_with_cores<P: Into<PathBuf>, F: IntoIterator<Item = P>>(
paths: F,
number_cores: NonZeroUsize,
) -> mpsc::IntoIter<(PathBuf, BlissResult<Song>)> {
let mut cores = NonZeroUsize::new(num_cpus::get()).unwrap();
let mut cores = thread::available_parallelism().unwrap_or(NonZeroUsize::new(1).unwrap());
if cores > number_cores {
cores = number_cores;
}
Expand Down
13 changes: 9 additions & 4 deletions src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;

use crate::Song;
use crate::FEATURES_VERSION;
Expand Down Expand Up @@ -277,8 +278,9 @@ impl BaseConfig {
}
};

let number_cores =
number_cores.unwrap_or_else(|| NonZeroUsize::new(num_cpus::get()).unwrap());
let number_cores = number_cores.unwrap_or_else(|| {
thread::available_parallelism().unwrap_or(NonZeroUsize::new(1).unwrap())
});

Ok(Self {
config_path,
Expand Down Expand Up @@ -3010,7 +3012,7 @@ mod test {
library.config.base_config().config_path.display(),
library.config.base_config().database_path.display(),
FEATURES_VERSION,
num_cpus::get(),
thread::available_parallelism().unwrap_or(NonZeroUsize::new(1).unwrap()),
)
);
}
Expand Down Expand Up @@ -3183,7 +3185,10 @@ mod test {
ignore_wav_files: true,
};

assert_eq!(config.get_number_cores().get(), num_cpus::get());
assert_eq!(
config.get_number_cores().get(),
usize::from(thread::available_parallelism().unwrap_or(NonZeroUsize::new(1).unwrap())),
);

let base_config =
BaseConfig::new(Some(config_file), Some(database_file), Some(nzus(1))).unwrap();
Expand Down
Loading

0 comments on commit ed2dd72

Please sign in to comment.