Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
izderadicka committed Sep 4, 2022
1 parent 4a8edd7 commit ae34d90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/collection/src/audio_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ pub trait MediaInfo<'a>: Sized {
}

pub fn extract_description(file_path: impl AsRef<Path> + std::fmt::Debug) -> Option<String> {
libavformat::Info::from_file(file_path.as_ref(), None::<&str>)
get_audio_properties_uni(file_path.as_ref())
.map_err(|e| error!("Error {} when extracting metadata from {:?}", e, file_path))
.ok()
.and_then(|m| m.description())
}

pub fn extract_cover(file_path: impl AsRef<Path> + std::fmt::Debug) -> Option<Vec<u8>> {
libavformat::Info::from_file(file_path.as_ref(), None::<&str>)
get_audio_properties_uni(file_path.as_ref())
.map_err(|e| error!("Error {} when extracting metadata from {:?}", e, file_path))
.ok()
.and_then(|m| m.cover())
Expand Down Expand Up @@ -408,6 +408,14 @@ pub fn get_audio_properties(
libavformat::Info::from_file(audio_file_path, alternate_encoding)
}

pub fn get_audio_properties_uni(audio_file_path: &Path) -> Result<impl MediaInfo> {
#[cfg(not(feature = "tags-encoding"))]
return libavformat::Info::from_file(audio_file_path);

#[cfg(feature = "tags-encoding")]
return libavformat::Info::from_file(audio_file_path, None::<&str>);
}

pub fn init_media_lib() {
libavformat::init()
}
Expand Down

0 comments on commit ae34d90

Please sign in to comment.