Update dependencies

This commit is contained in:
Paul Lietar 2016-01-12 23:29:31 +00:00
parent 3c29d744a9
commit 7401fde7fc
6 changed files with 46 additions and 87 deletions

51
Cargo.lock generated
View file

@ -7,23 +7,23 @@ dependencies = [
"dns-sd 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "dns-sd 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"eventual 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "eventual 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"json_macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "json_macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"librespot-protocol 0.1.0", "librespot-protocol 0.1.0",
"num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
"portaudio 0.1.2 (git+https://github.com/mvdnes/portaudio-rs)", "portaudio 0.2.0 (git+https://github.com/mvdnes/portaudio-rs)",
"protobuf 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf_macros 0.1.1 (git+https://github.com/plietar/rust-protobuf-macros.git)", "protobuf_macros 0.1.2 (git+https://github.com/plietar/rust-protobuf-macros.git)",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)", "shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)",
"tempfile 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny_http 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tiny_http 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"vergen 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vorbis 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "vorbis 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -59,6 +59,11 @@ name = "bitflags"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "blastfig"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "0.4.2" version = "0.4.2"
@ -69,7 +74,7 @@ name = "chrono"
version = "0.2.17" version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -169,7 +174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "json_macros" name = "json_macros"
version = "0.2.6" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
@ -237,10 +242,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "num" name = "num"
version = "0.1.29" version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -261,8 +266,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "portaudio" name = "portaudio"
version = "0.1.2" version = "0.2.0"
source = "git+https://github.com/mvdnes/portaudio-rs#f49d9e1652f88083b9ea0fe021cca6ee3f57fa32" source = "git+https://github.com/mvdnes/portaudio-rs#6a5d4ffaa9a2564d79391b6994ea69358bfe6b22"
dependencies = [ dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -272,7 +277,7 @@ dependencies = [
[[package]] [[package]]
name = "portaudio_sys" name = "portaudio_sys"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/mvdnes/portaudio-rs#f49d9e1652f88083b9ea0fe021cca6ee3f57fa32" source = "git+https://github.com/mvdnes/portaudio-rs#6a5d4ffaa9a2564d79391b6994ea69358bfe6b22"
dependencies = [ dependencies = [
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -296,12 +301,12 @@ dependencies = [
[[package]] [[package]]
name = "protobuf_macros" name = "protobuf_macros"
version = "0.1.1" version = "0.1.2"
source = "git+https://github.com/plietar/rust-protobuf-macros.git#ade4282d3570304e967e5ab7a677d97cfd8586e0" source = "git+https://github.com/plietar/rust-protobuf-macros.git#aede2228ead6aa4da28cbc300440aaecefe0ad86"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.3.12" version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -327,7 +332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -365,12 +370,12 @@ dependencies = [
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "1.1.3" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -430,16 +435,16 @@ name = "uuid"
version = "0.1.18" version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "vergen" name = "vergen"
version = "0.0.16" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "blastfig 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -20,19 +20,19 @@ bit-set = "~0.2.0"
byteorder = "~0.4.2" byteorder = "~0.4.2"
eventual = "~0.1.5" eventual = "~0.1.5"
getopts = "~0.2.14" getopts = "~0.2.14"
json_macros = "~0.2.6" json_macros = "~0.3.0"
lazy_static = "~0.1.15" lazy_static = "~0.1.15"
num = "~0.1.29" num = "~0.1.30"
protobuf = "~1.0.10" protobuf = "~1.0.15"
rand = "~0.3.12" rand = "~0.3.13"
rpassword = "~0.1.0" rpassword = "~0.1.0"
rust-crypto = "~0.2.34" rust-crypto = "~0.2.34"
rustc-serialize = "~0.3.16" rustc-serialize = "~0.3.16"
tempfile = "~2.0.0"
time = "~0.1.34" time = "~0.1.34"
tiny_http = "~0.5.1" tiny_http = "~0.5.1"
tempfile = "~1.1.3"
url = "~0.5.2" url = "~0.5.2"
vorbis = "~0.0.13" vorbis = "~0.0.14"
[dependencies.dns-sd] [dependencies.dns-sd]
version = "~0.1.1" version = "~0.1.1"
@ -46,7 +46,7 @@ git = "https://github.com/plietar/rust-shannon.git"
git = "https://github.com/mvdnes/portaudio-rs" git = "https://github.com/mvdnes/portaudio-rs"
[build-dependencies] [build-dependencies]
vergen = "~0.0.16" vergen = "~0.1.0"
[features] [features]
default = ["dns-sd"] default = ["dns-sd"]

View file

@ -1,6 +1,6 @@
extern crate vergen; extern crate vergen;
fn main() { fn main() {
vergen::vergen(vergen::SHORT_SHA); vergen::vergen(vergen::SHORT_SHA).unwrap();
} }

View file

@ -7,9 +7,9 @@ use std::thread;
use std::fs; use std::fs;
use std::io::{self, Read, Write, Seek, SeekFrom}; use std::io::{self, Read, Write, Seek, SeekFrom};
use std::path::PathBuf; use std::path::PathBuf;
use tempfile::TempFile; use tempfile::NamedTempFile;
use util::{FileId, IgnoreExt, ZeroFile, mkdir_existing}; use util::{FileId, IgnoreExt, mkdir_existing};
use session::Session; use session::Session;
use stream::StreamEvent; use stream::StreamEvent;
@ -21,7 +21,7 @@ pub enum AudioFile {
} }
pub struct AudioFileLoading { pub struct AudioFileLoading {
read_file: TempFile, read_file: fs::File,
position: u64, position: u64,
seek: mpsc::Sender<u64>, seek: mpsc::Sender<u64>,
@ -39,10 +39,6 @@ struct AudioFileShared {
impl AudioFileLoading { impl AudioFileLoading {
fn new(session: &Session, file_id: FileId) -> AudioFileLoading { fn new(session: &Session, file_id: FileId) -> AudioFileLoading {
let mut files_iter = TempFile::shared(2).unwrap().into_iter();
let read_file = files_iter.next().unwrap();
let mut write_file = files_iter.next().unwrap();
let size = session.stream(file_id, 0, 1) let size = session.stream(file_id, 0, 1)
.into_iter() .into_iter()
.filter_map(|event| { .filter_map(|event| {
@ -58,6 +54,7 @@ impl AudioFileLoading {
let chunk_count = (size + CHUNK_SIZE - 1) / CHUNK_SIZE; let chunk_count = (size + CHUNK_SIZE - 1) / CHUNK_SIZE;
let shared = Arc::new(AudioFileShared { let shared = Arc::new(AudioFileShared {
file_id: file_id, file_id: file_id,
size: size, size: size,
@ -66,7 +63,9 @@ impl AudioFileLoading {
bitmap: Mutex::new(BitSet::with_capacity(chunk_count)), bitmap: Mutex::new(BitSet::with_capacity(chunk_count)),
}); });
io::copy(&mut ZeroFile::new(size as u64), &mut write_file).unwrap(); let write_file = NamedTempFile::new().unwrap();
write_file.set_len(size as u64).unwrap();
let read_file = write_file.reopen().unwrap();
let (seek_tx, seek_rx) = mpsc::channel(); let (seek_tx, seek_rx) = mpsc::channel();
@ -88,7 +87,7 @@ impl AudioFileLoading {
fn fetch(session: &Session, fn fetch(session: &Session,
shared: Arc<AudioFileShared>, shared: Arc<AudioFileShared>,
mut write_file: TempFile, mut write_file: NamedTempFile,
seek_rx: mpsc::Receiver<u64>) { seek_rx: mpsc::Receiver<u64>) {
let mut index = 0; let mut index = 0;
@ -119,7 +118,7 @@ impl AudioFileLoading {
fn fetch_chunk(session: &Session, fn fetch_chunk(session: &Session,
shared: &Arc<AudioFileShared>, shared: &Arc<AudioFileShared>,
write_file: &mut TempFile, write_file: &mut NamedTempFile,
index: usize) { index: usize) {
let rx = session.stream(shared.file_id, let rx = session.stream(shared.file_id,
@ -151,7 +150,7 @@ impl AudioFileLoading {
shared.cond.notify_all(); shared.cond.notify_all();
} }
fn store(session: &Session, shared: &AudioFileShared, write_file: &mut TempFile) { fn store(session: &Session, shared: &AudioFileShared, write_file: &mut NamedTempFile) {
write_file.seek(SeekFrom::Start(0)).unwrap(); write_file.seek(SeekFrom::Start(0)).unwrap();
mkdir_existing(&AudioFileManager::cache_dir(session, shared.file_id)).unwrap(); mkdir_existing(&AudioFileManager::cache_dir(session, shared.file_id)).unwrap();

View file

@ -10,13 +10,11 @@ mod int128;
mod spotify_id; mod spotify_id;
mod arcvec; mod arcvec;
mod subfile; mod subfile;
mod zerofile;
pub use util::int128::u128; pub use util::int128::u128;
pub use util::spotify_id::{SpotifyId, FileId}; pub use util::spotify_id::{SpotifyId, FileId};
pub use util::arcvec::ArcVec; pub use util::arcvec::ArcVec;
pub use util::subfile::Subfile; pub use util::subfile::Subfile;
pub use util::zerofile::ZeroFile;
#[macro_export] #[macro_export]
macro_rules! eprintln( macro_rules! eprintln(

View file

@ -1,43 +0,0 @@
use std::io;
use std::cmp::{min, max};
pub struct ZeroFile {
position: u64,
size: u64,
}
impl ZeroFile {
pub fn new(size: u64) -> ZeroFile {
ZeroFile {
position: 0,
size: size,
}
}
}
impl io::Seek for ZeroFile {
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
let newpos = match pos {
io::SeekFrom::Start(offset) => offset as i64,
io::SeekFrom::End(offset) => self.size as i64 + offset,
io::SeekFrom::Current(offset) => self.position as i64 + offset,
};
self.position = max(min(newpos, self.size as i64), 0) as u64;
Ok(self.position)
}
}
impl io::Read for ZeroFile {
// TODO optimize with memset or similar
fn read(&mut self, output: &mut [u8]) -> io::Result<usize> {
let len = min(output.len(), (self.size - self.position) as usize);
for b in output {
*b = 0;
}
self.position += len as u64;
Ok(len)
}
}