Skip to content

Commit

Permalink
Add endpoint::get_name() and an enumerate example
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Sep 22, 2015
1 parent 8f11173 commit ec48453
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ fn main() {
println!("Endpoints: ");
for (endpoint_index, endpoint) in endpoints.enumerate() {
println!("{}. Endpoint \"{}\" Audio formats: ", endpoint_index + 1, endpoint.get_name());

let formats = endpoint.get_supported_formats_list().unwrap();
for (format_index, format) in formats.enumerate() {
println!("{}.{}. {:?}", endpoint_index+1, format_index+1, format);
println!("{}.{}. {:?}", endpoint_index + 1, format_index + 1, format);
}
}
}
5 changes: 5 additions & 0 deletions src/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ impl Endpoint {

Ok(Some(format).into_iter())
}

#[inline]
pub fn get_name(&self) -> String {
"unknown".to_owned() // TODO:
}
}

pub struct Voice {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ impl Endpoint {
{
Ok(SupportedFormatsIterator(try!(self.0.get_supported_formats_list())))
}

/// Returns the name of the endpoint.
#[inline]
pub fn get_name(&self) -> String {
self.0.get_name()
}
}

/// Number of channels.
Expand Down
5 changes: 5 additions & 0 deletions src/null/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ impl Endpoint {
{
unreachable!()
}

#[inline]
pub fn get_name(&self) -> String {
"null".to_owned()
}
}

pub struct SupportedFormatsIterator;
Expand Down
5 changes: 5 additions & 0 deletions src/wasapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ unsafe impl Send for Endpoint {}
unsafe impl Sync for Endpoint {}

impl Endpoint {
#[inline]
pub fn get_name(&self) -> String {
"unknown".to_owned() // TODO:
}

#[inline]
fn from_immdevice(device: *mut winapi::IMMDevice) -> Endpoint {
Endpoint {
Expand Down

0 comments on commit ec48453

Please sign in to comment.