Put lewton behind feature flag

This commit is contained in:
johannesd3 2021-02-10 23:07:59 +01:00 committed by Johannesd3
parent a6ed6857d2
commit 746e6c863e
4 changed files with 29 additions and 13 deletions

1
Cargo.lock generated
View file

@ -1402,6 +1402,7 @@ dependencies = [
"bit-set",
"byteorder",
"bytes",
"cfg-if 1.0.0",
"futures",
"lewton",
"librespot-core",

View file

@ -75,10 +75,11 @@ gstreamer-backend = ["librespot-playback/gstreamer-backend"]
with-tremor = ["librespot-audio/with-tremor"]
with-vorbis = ["librespot-audio/with-vorbis"]
with-lewton = ["librespot-audio/with-lewton"]
# with-dns-sd = ["librespot-connect/with-dns-sd"]
default = ["rodio-backend", "apresolve"]
default = ["rodio-backend", "apresolve", "with-lewton"]
[package.metadata.deb]
maintainer = "librespot-org"

View file

@ -15,18 +15,20 @@ aes-ctr = "0.6"
bit-set = "0.5"
byteorder = "1.4"
bytes = "1.0"
cfg-if = "1"
futures = "0.3"
lewton = "0.10"
ogg = "0.8"
log = "0.4"
num-bigint = "0.3"
num-traits = "0.2"
ogg = "0.8"
pin-project-lite = "0.2.4"
tempfile = "3.1"
lewton = { version = "0.10", optional = true }
librespot-tremor = { version = "0.2.0", optional = true }
vorbis = { version ="0.0.14", optional = true }
[features]
with-lewton = ["lewton"]
with-tremor = ["librespot-tremor"]
with-vorbis = ["vorbis"]

View file

@ -19,11 +19,29 @@ extern crate librespot_core;
mod decrypt;
mod fetch;
#[cfg(not(any(feature = "with-tremor", feature = "with-vorbis")))]
mod lewton_decoder;
#[cfg(any(feature = "with-tremor", feature = "with-vorbis"))]
mod libvorbis_decoder;
use cfg_if::cfg_if;
#[cfg(any(
all(feature = "with-lewton", feature = "with-tremor"),
all(feature = "with-vorbis", feature = "with-tremor"),
all(feature = "with-lewton", feature = "with-vorbis")
))]
compile_error!("Cannot use two decoders at the same time.");
cfg_if! {
if #[cfg(feature = "with-lewton")] {
mod lewton_decoder;
pub use lewton_decoder::{VorbisDecoder, VorbisError};
} else if #[cfg(any(feature = "with-tremor", feature = "with-vorbis"))] {
mod libvorbis_decoder;
pub use crate::libvorbis_decoder::{VorbisDecoder, VorbisError};
} else {
compile_error!("Must choose a vorbis decoder.");
}
}
mod passthrough_decoder;
pub use passthrough_decoder::{PassthroughDecoder, PassthroughError};
mod range_set;
@ -63,12 +81,6 @@ impl AudioPacket {
}
}
#[cfg(not(any(feature = "with-tremor", feature = "with-vorbis")))]
pub use crate::lewton_decoder::{VorbisDecoder, VorbisError};
#[cfg(any(feature = "with-tremor", feature = "with-vorbis"))]
pub use libvorbis_decoder::{VorbisDecoder, VorbisError};
pub use passthrough_decoder::{PassthroughDecoder, PassthroughError};
#[derive(Debug)]
pub enum AudioError {
PassthroughError(PassthroughError),