mirror of
https://github.com/RustAudio/rodio
synced 2024-12-13 13:42:34 +00:00
Add play() and make the decoder public
This commit is contained in:
parent
5ab65b7a31
commit
d3052bc986
2 changed files with 9 additions and 18 deletions
|
@ -7,6 +7,8 @@ mod vorbis;
|
|||
mod wav;
|
||||
|
||||
/// Source of audio samples from decoding a file.
|
||||
///
|
||||
/// Supports WAV and Vorbis.
|
||||
pub struct Decoder<R>(DecoderImpl<R>) where R: Read + Seek;
|
||||
|
||||
enum DecoderImpl<R> where R: Read + Seek {
|
||||
|
|
25
src/lib.rs
25
src/lib.rs
|
@ -11,15 +11,16 @@ extern crate vorbis;
|
|||
pub use cpal::{Endpoint, get_endpoints_list, get_default_endpoint};
|
||||
|
||||
pub use conversions::Sample;
|
||||
pub use decoder::Decoder;
|
||||
pub use source::Source;
|
||||
|
||||
use std::io::{Read, Seek};
|
||||
use std::thread;
|
||||
|
||||
mod conversions;
|
||||
mod decoder;
|
||||
mod engine;
|
||||
|
||||
pub mod decoder;
|
||||
pub mod source;
|
||||
|
||||
lazy_static! {
|
||||
|
@ -75,21 +76,9 @@ pub fn play_once<R>(endpoint: &Endpoint, input: R) -> Handle
|
|||
Handle(ENGINE.play(&endpoint, input))
|
||||
}
|
||||
|
||||
/*pub fn decode<R>() -> DecoderSource where R: Read + Seek + Send + 'static {
|
||||
DecoderSource {
|
||||
|
||||
}
|
||||
/// Plays a sound.
|
||||
pub fn play<S>(endpoint: &Endpoint, source: S) -> Handle where S: Source + Send + 'static,
|
||||
S::Item: Sample, S::Item: Send
|
||||
{
|
||||
Handle(ENGINE.play(&endpoint, source))
|
||||
}
|
||||
|
||||
pub struct Sink {
|
||||
handle: engine::Handle<'static>,
|
||||
}
|
||||
|
||||
impl Sink {
|
||||
/// Plays a source after the current source (if any) has finished playing.
|
||||
#[inline]
|
||||
pub fn play<S>(&mut self, source: S) where S: Source {
|
||||
let source: Box<Source> = Box::new(source);
|
||||
self.handle.add(source);
|
||||
}
|
||||
}*/
|
||||
|
|
Loading…
Reference in a new issue