Rename the methods of the backend as well (#164)

This commit is contained in:
tomaka 2017-10-12 11:54:09 +02:00 committed by GitHub
parent 84f0acbd65
commit 4b019243c2
9 changed files with 23 additions and 23 deletions

View File

@ -119,6 +119,6 @@ impl Iterator for EndpointsIterator {
} }
#[inline] #[inline]
pub fn get_default_endpoint() -> Option<Endpoint> { pub fn default_endpoint() -> Option<Endpoint> {
Some(Endpoint("default".to_owned())) Some(Endpoint("default".to_owned()))
} }

View File

@ -1,7 +1,7 @@
extern crate alsa_sys as alsa; extern crate alsa_sys as alsa;
extern crate libc; extern crate libc;
pub use self::enumerate::{EndpointsIterator, get_default_endpoint}; pub use self::enumerate::{EndpointsIterator, default_endpoint};
use ChannelPosition; use ChannelPosition;
use CreationError; use CreationError;
@ -72,7 +72,7 @@ impl Drop for Trigger {
pub struct Endpoint(String); pub struct Endpoint(String);
impl Endpoint { impl Endpoint {
pub fn get_supported_formats_list( pub fn supported_formats(
&self) &self)
-> Result<SupportedFormatsIterator, FormatsEnumerationError> { -> Result<SupportedFormatsIterator, FormatsEnumerationError> {
unsafe { unsafe {
@ -250,7 +250,7 @@ impl Endpoint {
} }
#[inline] #[inline]
pub fn get_name(&self) -> String { pub fn name(&self) -> String {
self.0.clone() self.0.clone()
} }
} }
@ -762,7 +762,7 @@ impl Drop for VoiceInner {
impl<T> Buffer<T> { impl<T> Buffer<T> {
#[inline] #[inline]
pub fn get_buffer(&mut self) -> &mut [T] { pub fn buffer(&mut self) -> &mut [T] {
&mut self.buffer &mut self.buffer
} }

View File

@ -29,7 +29,7 @@ impl Iterator for EndpointsIterator {
} }
} }
pub fn get_default_endpoint() -> Option<Endpoint> { pub fn default_endpoint() -> Option<Endpoint> {
Some(Endpoint) Some(Endpoint)
} }

View File

@ -24,13 +24,13 @@ use self::coreaudio::audio_unit::render_callback::{self, data};
mod enumerate; mod enumerate;
pub use self::enumerate::{EndpointsIterator, SupportedFormatsIterator, get_default_endpoint}; pub use self::enumerate::{EndpointsIterator, SupportedFormatsIterator, default_endpoint};
#[derive(Clone, PartialEq, Eq)] #[derive(Clone, PartialEq, Eq)]
pub struct Endpoint; pub struct Endpoint;
impl Endpoint { impl Endpoint {
pub fn get_supported_formats_list( pub fn supported_formats(
&self) &self)
-> Result<SupportedFormatsIterator, FormatsEnumerationError> { -> Result<SupportedFormatsIterator, FormatsEnumerationError> {
Ok( Ok(
@ -44,7 +44,7 @@ impl Endpoint {
) )
} }
pub fn get_name(&self) -> String { pub fn name(&self) -> String {
"Default AudioUnit Endpoint".to_string() "Default AudioUnit Endpoint".to_string()
} }
} }
@ -73,7 +73,7 @@ impl<T> Buffer<T>
where T: Sample where T: Sample
{ {
#[inline] #[inline]
pub fn get_buffer(&mut self) -> &mut [T] { pub fn buffer(&mut self) -> &mut [T] {
&mut self.buffer[..] &mut self.buffer[..]
} }

View File

@ -135,7 +135,7 @@ pub fn get_endpoints_list() -> EndpointsIterator {
/// Return the default endpoint, or `None` if no device is available. /// Return the default endpoint, or `None` if no device is available.
#[inline] #[inline]
pub fn default_endpoint() -> Option<Endpoint> { pub fn default_endpoint() -> Option<Endpoint> {
cpal_impl::get_default_endpoint().map(Endpoint) cpal_impl::default_endpoint().map(Endpoint)
} }
/// Deprecated. Use `default_endpoint()` instead. /// Deprecated. Use `default_endpoint()` instead.
@ -153,7 +153,7 @@ impl Endpoint {
/// Returns an iterator that produces the list of formats that are supported by the backend. /// Returns an iterator that produces the list of formats that are supported by the backend.
#[inline] #[inline]
pub fn supported_formats(&self) -> Result<SupportedFormatsIterator, FormatsEnumerationError> { pub fn supported_formats(&self) -> Result<SupportedFormatsIterator, FormatsEnumerationError> {
Ok(SupportedFormatsIterator(self.0.get_supported_formats_list()?)) Ok(SupportedFormatsIterator(self.0.supported_formats()?))
} }
/// Deprecated. Use `supported_formats` instead. /// Deprecated. Use `supported_formats` instead.
@ -168,7 +168,7 @@ impl Endpoint {
/// Returns the name of the endpoint. /// Returns the name of the endpoint.
#[inline] #[inline]
pub fn name(&self) -> String { pub fn name(&self) -> String {
self.0.get_name() self.0.name()
} }
/// Deprecated. Use `name()` instead. /// Deprecated. Use `name()` instead.
@ -463,7 +463,7 @@ impl<T> DerefMut for Buffer<T>
{ {
#[inline] #[inline]
fn deref_mut(&mut self) -> &mut [T] { fn deref_mut(&mut self) -> &mut [T] {
self.target.as_mut().unwrap().get_buffer() self.target.as_mut().unwrap().buffer()
} }
} }

View File

@ -36,7 +36,7 @@ impl Iterator for EndpointsIterator {
} }
#[inline] #[inline]
pub fn get_default_endpoint() -> Option<Endpoint> { pub fn default_endpoint() -> Option<Endpoint> {
None None
} }
@ -45,14 +45,14 @@ pub struct Endpoint;
impl Endpoint { impl Endpoint {
#[inline] #[inline]
pub fn get_supported_formats_list( pub fn supported_formats(
&self) &self)
-> Result<SupportedFormatsIterator, FormatsEnumerationError> { -> Result<SupportedFormatsIterator, FormatsEnumerationError> {
unreachable!() unreachable!()
} }
#[inline] #[inline]
pub fn get_name(&self) -> String { pub fn name(&self) -> String {
"null".to_owned() "null".to_owned()
} }
} }
@ -103,7 +103,7 @@ pub struct Buffer<T> {
impl<T> Buffer<T> { impl<T> Buffer<T> {
#[inline] #[inline]
pub fn get_buffer(&mut self) -> &mut [T] { pub fn buffer(&mut self) -> &mut [T] {
unreachable!() unreachable!()
} }

View File

@ -118,7 +118,7 @@ impl Iterator for EndpointsIterator {
} }
} }
pub fn get_default_endpoint() -> Option<Endpoint> { pub fn default_endpoint() -> Option<Endpoint> {
unsafe { unsafe {
let mut device = mem::uninitialized(); let mut device = mem::uninitialized();
let hres = (*ENUMERATOR.0) let hres = (*ENUMERATOR.0)

View File

@ -16,7 +16,7 @@ use FormatsEnumerationError;
use SampleFormat; use SampleFormat;
use SamplesRate; use SamplesRate;
pub use self::enumerate::{EndpointsIterator, get_default_endpoint}; pub use self::enumerate::{EndpointsIterator, default_endpoint};
pub use self::voice::{Buffer, EventLoop, SamplesStream, Voice}; pub use self::voice::{Buffer, EventLoop, SamplesStream, Voice};
pub use std::option::IntoIter as OptionIntoIter; pub use std::option::IntoIter as OptionIntoIter;
@ -60,7 +60,7 @@ unsafe impl Sync for Endpoint {
impl Endpoint { impl Endpoint {
// TODO: this function returns a GUID of the endpoin // TODO: this function returns a GUID of the endpoin
// instead it should use the property store and return the friendly name // instead it should use the property store and return the friendly name
pub fn get_name(&self) -> String { pub fn name(&self) -> String {
unsafe { unsafe {
let mut name_ptr = mem::uninitialized(); let mut name_ptr = mem::uninitialized();
// can only fail if wrong params or out of memory // can only fail if wrong params or out of memory
@ -125,7 +125,7 @@ impl Endpoint {
Ok(client) Ok(client)
} }
pub fn get_supported_formats_list( pub fn supported_formats(
&self) &self)
-> Result<SupportedFormatsIterator, FormatsEnumerationError> { -> Result<SupportedFormatsIterator, FormatsEnumerationError> {
// We always create voices in shared mode, therefore all samples go through an audio // We always create voices in shared mode, therefore all samples go through an audio

View File

@ -469,7 +469,7 @@ unsafe impl<T> Send for Buffer<T> {
impl<T> Buffer<T> { impl<T> Buffer<T> {
#[inline] #[inline]
pub fn get_buffer(&mut self) -> &mut [T] { pub fn buffer(&mut self) -> &mut [T] {
unsafe { slice::from_raw_parts_mut(self.buffer_data, self.buffer_len) } unsafe { slice::from_raw_parts_mut(self.buffer_data, self.buffer_len) }
} }