Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

An abstraction over cpal::Device, represents a physical output device

Implementations§

Source§

impl Device

Source

pub fn play_default_output( player: &mut impl SamplesPlayerTrait, ) -> Result<(), PlayError>

Plays the samples on the default device of the default host

Source

pub fn create_stream<T: Sample>( &self, metadata: &impl AudioMetadataTrait, samples: Arc<Mutex<Samples<T>>>, ) -> Result<Stream, PlayError>

Creates a stream that will play the metadata based on the metadata given

Source

pub fn play<T: Sample>( self, player: &mut impl SamplesPlayerTrait, ) -> Result<(), PlayError>

Plays the samples in the SamplesPlayer on this device

Source

pub fn default_output() -> Option<Device>

Returns the default output device of the default host. Be aware that there may be none

Source

pub fn list_device_names() -> Vec<String>

Gives the name of all devices on all hosts

Source

pub fn new_from_name(device_name: &str) -> Option<Device>

Creates a new device from its device name

Source§

impl Device

Source

pub fn name(&self) -> Option<String>

Returns the name of the device, if it can find one

Trait Implementations§

Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,