Create new librespot-audio crate

This commit is contained in:
Paul Lietar 2017-08-03 20:37:04 +01:00
parent 2846d3acfd
commit ec8f80df75
9 changed files with 64 additions and 14 deletions

16
Cargo.lock generated
View file

@ -253,6 +253,7 @@ dependencies = [
"hyper 0.11.0-a.0 (git+https://github.com/hyperium/hyper)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libpulse-sys 0.0.0 (git+https://github.com/astro/libpulse-sys)",
"librespot-audio 0.1.0",
"librespot-core 0.1.0",
"librespot-metadata 0.1.0",
"librespot-protocol 0.1.0",
@ -283,6 +284,21 @@ dependencies = [
"vorbis 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "librespot-audio"
version = "0.1.0"
dependencies = [
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"librespot-core 0.1.0",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-bigint 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (git+https://github.com/awmath/rust-crypto.git?branch=avx2)",
"tempfile 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "librespot-core"
version = "0.1.0"

View file

@ -20,6 +20,8 @@ name = "librespot"
path = "src/main.rs"
doc = false
[dependencies.librespot-audio]
path = "audio"
[dependencies.librespot-core]
path = "core"
[dependencies.librespot-metadata]

17
audio/Cargo.toml Normal file
View file

@ -0,0 +1,17 @@
[package]
name = "librespot-audio"
version = "0.1.0"
authors = ["Paul Lietar <paul@lietar.net>"]
[dependencies]
bit-set = "0.4.0"
byteorder = "1.0"
rust-crypto = { git = "https://github.com/awmath/rust-crypto.git", branch = "avx2" }
futures = "0.1.8"
log = "0.3.5"
num-bigint = "0.1.35"
num-traits = "0.1.36"
tempfile = "2.1"
[dependencies.librespot-core]
path = "../core"

View file

@ -3,7 +3,6 @@ use byteorder::{ByteOrder, BigEndian, WriteBytesExt};
use futures::Stream;
use futures::sync::{oneshot, mpsc};
use futures::{Poll, Async, Future};
use futures::future::{self, FutureResult};
use std::cmp::min;
use std::fs;
use std::io::{self, Read, Write, Seek, SeekFrom};
@ -22,7 +21,7 @@ pub enum AudioFile {
}
pub enum AudioFileOpen {
Cached(FutureResult<fs::File, ChannelError>),
Cached(Option<fs::File>),
Streaming(AudioFileOpenStreaming),
}
@ -97,8 +96,8 @@ impl Future for AudioFileOpen {
let file = try_ready!(open.poll());
Ok(Async::Ready(AudioFile::Streaming(file)))
}
AudioFileOpen::Cached(ref mut open) => {
let file = try_ready!(open.poll());
AudioFileOpen::Cached(ref mut file) => {
let file = file.take().unwrap();
Ok(Async::Ready(AudioFile::Cached(file)))
}
}
@ -129,7 +128,7 @@ impl AudioFile {
if let Some(file) = cache.as_ref().and_then(|cache| cache.file(file_id)) {
debug!("File {} already in cache", file_id);
return AudioFileOpen::Cached(future::ok(file));
return AudioFileOpen::Cached(Some(file));
}
debug!("Downloading file {}", file_id);
@ -247,7 +246,7 @@ impl AudioFileFetch {
let complete_tx = self.complete_tx.take().unwrap();
output.seek(SeekFrom::Start(0)).unwrap();
complete_tx.complete(output);
let _ = complete_tx.send(output);
}
}

17
audio/src/lib.rs Normal file
View file

@ -0,0 +1,17 @@
#[macro_use] extern crate log;
#[macro_use] extern crate futures;
extern crate bit_set;
extern crate byteorder;
extern crate crypto;
extern crate num_traits;
extern crate num_bigint;
extern crate tempfile;
extern crate librespot_core as core;
mod fetch;
mod decrypt;
pub use fetch::{AudioFile, AudioFileOpen};
pub use decrypt::AudioDecrypt;

View file

@ -1,11 +1,11 @@
pub extern crate librespot_core as core;
pub extern crate librespot_protocol as protocol;
extern crate byteorder;
extern crate futures;
extern crate linear_map;
extern crate protobuf;
extern crate librespot_core as core;
extern crate librespot_protocol as protocol;
pub mod cover;
use futures::{Future, BoxFuture};

View file

@ -5,7 +5,6 @@
// TODO: many items from tokio-core::io have been deprecated in favour of tokio-io
#![allow(deprecated)]
#[macro_use] extern crate futures;
#[macro_use] extern crate log;
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
@ -14,6 +13,7 @@ extern crate base64;
extern crate bit_set;
extern crate byteorder;
extern crate crypto;
extern crate futures;
extern crate getopts;
extern crate hyper;
extern crate linear_map;
@ -32,6 +32,7 @@ extern crate tokio_proto;
extern crate url;
extern crate uuid;
pub extern crate librespot_audio as audio;
pub extern crate librespot_core as core;
pub extern crate librespot_protocol as protocol;
pub extern crate librespot_metadata as metadata;
@ -51,8 +52,6 @@ extern crate portaudio_rs;
extern crate libpulse_sys;
pub mod audio_backend;
pub mod audio_decrypt;
pub mod audio_file;
pub mod discovery;
pub mod keymaster;
pub mod mixer;

View file

@ -13,8 +13,8 @@ use core::session::Session;
use core::util::{self, SpotifyId, Subfile};
use audio_backend::Sink;
use audio_decrypt::AudioDecrypt;
use audio_file::AudioFile;
use audio::AudioDecrypt;
use audio::AudioFile;
use metadata::{FileFormat, Track, Metadata};
use mixer::AudioFilter;