Move audio backends into seperate crate

This commit is contained in:
Sasha Hilton 2018-02-09 02:05:50 +01:00
parent bd59ded224
commit 1fb65354b0
16 changed files with 112 additions and 45 deletions

47
Cargo.lock generated
View file

@ -310,24 +310,19 @@ dependencies = [
name = "librespot" name = "librespot"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"alsa 0.0.1 (git+https://github.com/plietar/rust-alsa)",
"base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-sd 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
"jack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"libpulse-sys 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"librespot-audio 0.1.0", "librespot-audio 0.1.0",
"librespot-core 0.1.0", "librespot-core 0.1.0",
"librespot-discovery 0.1.0",
"librespot-metadata 0.1.0", "librespot-metadata 0.1.0",
"librespot-playback 0.1.0",
"librespot-protocol 0.1.0", "librespot-protocol 0.1.0",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mdns 0.2.0 (git+https://github.com/plietar/rust-mdns)",
"num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"portaudio-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf_macros 0.6.0 (git+https://github.com/plietar/rust-protobuf-macros)", "protobuf_macros 0.6.0 (git+https://github.com/plietar/rust-protobuf-macros)",
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
@ -392,6 +387,28 @@ dependencies = [
"vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "librespot-discovery"
version = "0.1.0"
dependencies = [
"base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-sd 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
"librespot-core 0.1.0",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mdns 0.2.0 (git+https://github.com/plietar/rust-mdns)",
"num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (git+https://github.com/awmath/rust-crypto.git?branch=avx2)",
"serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "librespot-metadata" name = "librespot-metadata"
version = "0.1.0" version = "0.1.0"
@ -404,6 +421,22 @@ dependencies = [
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "librespot-playback"
version = "0.1.0"
dependencies = [
"alsa 0.0.1 (git+https://github.com/plietar/rust-alsa)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"jack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"libpulse-sys 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"librespot-audio 0.1.0",
"librespot-core 0.1.0",
"librespot-metadata 0.1.0",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"portaudio-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "librespot-protocol" name = "librespot-protocol"
version = "0.1.0" version = "0.1.0"

View file

@ -28,6 +28,8 @@ path = "core"
path = "discovery" path = "discovery"
[dependencies.librespot-metadata] [dependencies.librespot-metadata]
path = "metadata" path = "metadata"
[dependencies.librespot-playback]
path = "playback"
[dependencies.librespot-protocol] [dependencies.librespot-protocol]
path = "protocol" path = "protocol"
@ -51,29 +53,23 @@ tokio-io = "0.1"
tokio-signal = "0.1.2" tokio-signal = "0.1.2"
url = "1.3" url = "1.3"
alsa = { git = "https://github.com/plietar/rust-alsa", optional = true }
portaudio-rs = { version = "0.3.0", optional = true }
libpulse-sys = { version = "0.0.0", optional = true }
jack = { version = "0.5.3", optional = true }
libc = { version = "0.2", optional = true }
[build-dependencies] [build-dependencies]
rand = "0.3.13" rand = "0.3.13"
vergen = "0.1.0" vergen = "0.1.0"
protobuf_macros = { git = "https://github.com/plietar/rust-protobuf-macros", features = ["with-syntex"] } protobuf_macros = { git = "https://github.com/plietar/rust-protobuf-macros", features = ["with-syntex"] }
[features] [features]
alsa-backend = ["alsa"] alsa-backend = ["librespot-playback/alsa"]
portaudio-backend = ["portaudio-rs"] portaudio-backend = ["librespot-playback/portaudio-rs"]
pulseaudio-backend = ["libpulse-sys", "libc"] pulseaudio-backend = ["librespot-playback/libpulse-sys", "librespot-playback/libc"]
jackaudio-backend = ["jack"] jackaudio-backend = ["librespot-playback/jack"]
with-tremor = ["librespot-audio/with-tremor"] with-tremor = ["librespot-audio/with-tremor"]
with-vorbis = ["librespot-audio/with-vorbis"] with-vorbis = ["librespot-audio/with-vorbis"]
with-dns-sd = ["librespot-discovery/dns-sd"] with-dns-sd = ["librespot-discovery/with-dns-sd"]
default = ["portaudio-backend"] default = ["librespot-playback/portaudio-backend"]
[package.metadata.deb] [package.metadata.deb]
maintainer = "librespot-org" maintainer = "librespot-org"

29
playback/Cargo.toml Normal file
View file

@ -0,0 +1,29 @@
[package]
name = "librespot-playback"
version = "0.1.0"
authors = ["Sasha Hilton <sashahilton00@gmail.com>"]
[dependencies.librespot-audio]
path = "../audio"
[dependencies.librespot-core]
path = "../core"
[dependencies.librespot-metadata]
path = "../metadata"
[dependencies]
futures = "0.1.8"
log = "0.3.5"
alsa = { git = "https://github.com/plietar/rust-alsa", optional = true }
portaudio-rs = { version = "0.3.0", optional = true }
libpulse-sys = { version = "0.0.0", optional = true }
jack = { version = "0.5.3", optional = true }
libc = { version = "0.2", optional = true }
[features]
alsa-backend = ["alsa"]
portaudio-backend = ["portaudio-rs"]
pulseaudio-backend = ["libpulse-sys", "libc"]
jackaudio-backend = ["jack"]
default = ["portaudio-backend"]

26
playback/src/lib.rs Normal file
View file

@ -0,0 +1,26 @@
#[macro_use] extern crate log;
extern crate futures;
#[cfg(feature = "alsa-backend")]
extern crate alsa;
#[cfg(feature = "portaudio-rs")]
extern crate portaudio_rs;
#[cfg(feature = "libpulse-sys")]
extern crate libpulse_sys;
#[cfg(feature = "jackaudio-backend")]
extern crate jack;
#[cfg(feature = "libc")]
extern crate libc;
extern crate librespot_audio as audio;
extern crate librespot_core as core;
extern crate librespot_metadata as metadata;
pub mod audio_backend;
pub mod mixer;
pub mod player;

View file

@ -17,26 +17,9 @@ extern crate url;
pub extern crate librespot_audio as audio; pub extern crate librespot_audio as audio;
pub extern crate librespot_core as core; pub extern crate librespot_core as core;
pub extern crate librespot_discovery as discovery; pub extern crate librespot_discovery as discovery;
pub extern crate librespot_playback as playback;
pub extern crate librespot_protocol as protocol; pub extern crate librespot_protocol as protocol;
pub extern crate librespot_metadata as metadata; pub extern crate librespot_metadata as metadata;
#[cfg(feature = "alsa-backend")]
extern crate alsa;
#[cfg(feature = "portaudio-rs")]
extern crate portaudio_rs;
#[cfg(feature = "libpulse-sys")]
extern crate libpulse_sys;
#[cfg(feature = "jackaudio-backend")]
extern crate jack;
#[cfg(feature = "libc")]
extern crate libc;
pub mod audio_backend;
pub mod mixer;
pub mod player;
include!(concat!(env!("OUT_DIR"), "/lib.rs")); include!(concat!(env!("OUT_DIR"), "/lib.rs"));

View file

@ -24,10 +24,10 @@ use librespot::core::config::{Bitrate, DeviceType, PlayerConfig, SessionConfig,
use librespot::core::session::Session; use librespot::core::session::Session;
use librespot::core::version; use librespot::core::version;
use librespot::audio_backend::{self, Sink, BACKENDS}; use librespot::playback::audio_backend::{self, Sink, BACKENDS};
use librespot::discovery::discovery::{discovery, DiscoveryStream}; use librespot::discovery::discovery::{discovery, DiscoveryStream};
use librespot::mixer::{self, Mixer}; use librespot::playback::mixer::{self, Mixer};
use librespot::player::Player; use librespot::playback::player::Player;
use librespot::spirc::{Spirc, SpircTask}; use librespot::spirc::{Spirc, SpircTask};
fn usage(program: &str, opts: &getopts::Options) -> String { fn usage(program: &str, opts: &getopts::Options) -> String {

View file

@ -12,8 +12,8 @@ use core::version;
use protocol; use protocol;
use protocol::spirc::{PlayStatus, State, MessageType, Frame, DeviceState}; use protocol::spirc::{PlayStatus, State, MessageType, Frame, DeviceState};
use mixer::Mixer; use playback::mixer::Mixer;
use player::Player; use playback::player::Player;
use std; use std;
use rand; use rand;