Fix most warnings

This commit is contained in:
Pierre Krieger 2016-10-04 16:36:11 +02:00
parent 7f8d237a80
commit 1eae866da4
4 changed files with 22 additions and 29 deletions

View file

@ -1,6 +1,8 @@
extern crate rodio;
use std::io::BufReader;
use std::thread;
use std::time::Duration;
fn main() {
let endpoint = rodio::get_default_endpoint().unwrap();
@ -9,20 +11,20 @@ fn main() {
let mut beep1 = rodio::play_once(&endpoint, BufReader::new(file)).unwrap();
beep1.set_volume(0.2);
std::thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));
let file = std::fs::File::open("examples/beep2.wav").unwrap();
rodio::play_once(&endpoint, BufReader::new(file)).unwrap().detach();
std::thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));
let file = std::fs::File::open("examples/beep3.ogg").unwrap();
let beep3 = rodio::play_once(&endpoint, file).unwrap();
std::thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));
drop(beep1);
std::thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));
drop(beep3);
std::thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));
}

View file

@ -1,6 +1,8 @@
extern crate rodio;
use std::io::BufReader;
use std::thread;
use std::time::Duration;
fn main() {
let endpoint = rodio::get_default_endpoint().unwrap();
@ -9,5 +11,5 @@ fn main() {
let file = std::fs::File::open("examples/music.ogg").unwrap();
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
std::thread::sleep_ms(60000);
thread::sleep(Duration::from_millis(60000));
}

View file

@ -1,15 +1,11 @@
use std::cmp;
use std::mem;
use std::collections::HashMap;
use std::thread::{self, Builder, Thread};
use std::time::Duration;
use std::thread::Builder;
use std::sync::mpsc::{self, Sender, Receiver};
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::sync::Mutex;
use futures::Future;
use futures::stream::Stream;
use futures::task;
use futures::task::Executor;
@ -20,18 +16,12 @@ use cpal::Format;
use cpal::UnknownTypeBuffer;
use cpal::EventLoop;
use cpal::Voice;
use cpal::SamplesStream;
use cpal::Endpoint;
use conversions::Sample;
use source::Source;
use source::UniformSourceIterator;
/// Duration of a loop of the engine in milliseconds.
const FIXED_STEP_MS: u32 = 17;
/// Duration of a loop of the engine in nanoseconds.
const FIXED_STEP_NS: u64 = FIXED_STEP_MS as u64 * 1000000;
/// The internal engine of this library.
///
/// Each `Engine` owns a thread that runs in the background and plays the audio.
@ -53,14 +43,15 @@ impl Engine {
pub fn new() -> Engine {
let events_loop = Arc::new(EventLoop::new());
// we ignore errors when creating the background thread
// the user won't get any audio, but that's better than a panic
let thread = {
let events_loop = events_loop.clone();
Builder::new().name("rodio audio processing".to_string())
.spawn(move || events_loop.run())
.ok().map(|jg| jg.thread().clone())
};
// We ignore errors when creating the background thread.
// The user won't get any audio, but that's better than a panic.
Builder::new()
.name("rodio audio processing".to_string())
.spawn({
let events_loop = events_loop.clone();
move || events_loop.run()
})
.ok().map(|jg| jg.thread().clone());
Engine {
events_loop: events_loop,
@ -110,7 +101,7 @@ impl Engine {
let epv = end_point_voices.clone();
let mut sounds = Arc::new(Mutex::new(Vec::new()));
let sounds = Arc::new(Mutex::new(Vec::new()));
future_to_exec = Some(stream.for_each(move |mut buffer| -> Result<_, ()> {
let mut sounds = sounds.lock().unwrap();
@ -217,7 +208,7 @@ impl Handle {
/// Changes the volume of the sound played by this sink.
#[inline]
pub fn set_volume(&self, value: f32) {
pub fn set_volume(&self, _value: f32) {
// FIXME:
}

View file

@ -64,8 +64,6 @@ pub use decoder::Decoder;
pub use source::Source;
use std::io::{Read, Seek};
use std::time::Duration;
use std::thread;
mod conversions;
mod engine;