rename some cargo features
This commit is contained in:
parent
482dc39fce
commit
8b70b2b851
10
Cargo.toml
10
Cargo.toml
|
@ -51,10 +51,10 @@ tempfile = "3"
|
|||
notify = "6"
|
||||
|
||||
[features]
|
||||
default = ["taglib", "flac", "mp3", "ffmpeg_fallback"]
|
||||
default = ["taglib_extractor", "flac_extractor", "mp3_extractor", "ffmpeg_extractor"]
|
||||
|
||||
# Formats
|
||||
taglib = ["dep:taglib"]
|
||||
flac = ["dep:metaflac"]
|
||||
mp3 = ["dep:id3"]
|
||||
ffmpeg_fallback = [] # If to allow using ffmpeg as a fallback tag extractor
|
||||
taglib_extractor = ["dep:taglib"]
|
||||
flac_extractor = ["dep:metaflac"]
|
||||
mp3_extractor = ["dep:id3"]
|
||||
ffmpeg_extractor = [] # If to allow using ffmpeg as a fallback tag extractor
|
|
@ -1,8 +1,8 @@
|
|||
#[cfg(feature = "ffmpeg_fallback")]
|
||||
#[cfg(feature = "ffmpeg_extractor")]
|
||||
pub mod generic_ffmpeg;
|
||||
#[cfg(feature = "flac")]
|
||||
#[cfg(feature = "flac_extractor")]
|
||||
pub mod flac;
|
||||
#[cfg(feature = "taglib")]
|
||||
#[cfg(feature = "taglib_extractor")]
|
||||
pub mod generic_taglib;
|
||||
#[cfg(feature = "mp3")]
|
||||
#[cfg(feature = "mp3_extractor")]
|
||||
pub mod id3;
|
|
@ -7,13 +7,13 @@ use thiserror::Error;
|
|||
|
||||
use crate::types::{AudioFileInfo, File, ReplayGainRawData, Tags};
|
||||
|
||||
#[cfg(feature = "flac")]
|
||||
#[cfg(feature = "flac_extractor")]
|
||||
use self::handlers::flac::new_flac_format_handler;
|
||||
#[cfg(feature = "taglib")]
|
||||
#[cfg(feature = "taglib_extractor")]
|
||||
use self::handlers::generic_taglib::new_taglib_format_handler;
|
||||
#[cfg(feature = "mp3")]
|
||||
#[cfg(feature = "mp3_extractor")]
|
||||
use self::handlers::id3::new_id3_format_handler;
|
||||
#[cfg(feature = "ffmpeg_fallback")]
|
||||
#[cfg(feature = "ffmpeg_extractor")]
|
||||
use self::handlers::generic_ffmpeg::new_generic_ffmpeg_format_handler;
|
||||
|
||||
use super::format_detection::{detect_format, FileFormat};
|
||||
|
@ -49,7 +49,7 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
|||
let format = detect_format(&file.join_path_to())?;
|
||||
let path = file.join_path_to();
|
||||
|
||||
#[cfg(feature = "taglib")]
|
||||
#[cfg(feature = "taglib_extractor")]
|
||||
{
|
||||
match format {
|
||||
FileFormat::OggFLAC
|
||||
|
@ -65,19 +65,19 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mp3")]
|
||||
#[cfg(feature = "mp3_extractor")]
|
||||
if format == FileFormat::MP3 {
|
||||
// Native MP3 support
|
||||
return Ok(Box::new(new_id3_format_handler(&path)?));
|
||||
}
|
||||
|
||||
#[cfg(feature = "flac")]
|
||||
#[cfg(feature = "flac_extractor")]
|
||||
if format == FileFormat::FLAC {
|
||||
// Native FLAC support
|
||||
return Ok(Box::new(new_flac_format_handler(&path)?));
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg_fallback")]
|
||||
#[cfg(feature = "ffmpeg_extractor")]
|
||||
match format {
|
||||
FileFormat::MP3
|
||||
| FileFormat::FLAC
|
||||
|
@ -99,23 +99,23 @@ pub fn get_format_handler(file: &File) -> Result<Box<dyn AudioContainerFormat>,
|
|||
}
|
||||
|
||||
fn is_supported_extension(ext: &str) -> bool {
|
||||
#[cfg(feature = "taglib")]
|
||||
#[cfg(feature = "taglib_extractor")]
|
||||
if matches!(ext, "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(feature = "mp3")]
|
||||
#[cfg(feature = "mp3_extractor")]
|
||||
if ext == "mp3" {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(feature = "flac")]
|
||||
#[cfg(feature = "flac_extractor")]
|
||||
if ext == "flac" {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FFMpeg Fallback
|
||||
#[cfg(feature = "ffmpeg_fallback")]
|
||||
#[cfg(feature = "ffmpeg_extractor")]
|
||||
if matches!(ext, "mp3" | "flac" | "ogg" | "opus" | "wav" | "wv" | "aiff") {
|
||||
return true;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ pub fn is_supported_file(file_path: &Path) -> bool {
|
|||
|
||||
let format = format.unwrap();
|
||||
|
||||
#[cfg(feature = "taglib")]
|
||||
#[cfg(feature = "taglib_extractor")]
|
||||
match format {
|
||||
FileFormat::OggVorbis
|
||||
| FileFormat::OggOpus
|
||||
|
@ -157,17 +157,17 @@ pub fn is_supported_file(file_path: &Path) -> bool {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mp3")]
|
||||
#[cfg(feature = "mp3_extractor")]
|
||||
if format == FileFormat::MP3 {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(feature = "flac")]
|
||||
#[cfg(feature = "flac_extractor")]
|
||||
if format == FileFormat::FLAC {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg_fallback")]
|
||||
#[cfg(feature = "ffmpeg_extractor")]
|
||||
match format {
|
||||
FileFormat::MP3
|
||||
| FileFormat::FLAC
|
||||
|
|
Loading…
Reference in a new issue