embassy-usb

Crates

git

Versions

default

Flavors

embassy_usb::class::uac1::speaker

Struct Speaker

Source
pub struct Speaker<'d, D: Driver<'d>> { /* private fields */ }
Expand description

Implementation of the USB audio class 1.0.

Implementations§

Source§

impl<'d, D: Driver<'d>> Speaker<'d, D>

Source

pub fn new( builder: &mut Builder<'d, D>, state: &'d mut State<'d>, max_packet_size: u16, resolution: SampleWidth, sample_rates_hz: &[u32], channels: &'d [Channel], feedback_refresh_period: FeedbackRefresh, ) -> (Stream<'d, D>, Feedback<'d, D>, ControlMonitor<'d>)

Creates a new Speaker device, split into a stream, feedback, and a control change notifier.

The packet size should be chosen, based on the expected transfer size of samples per (micro)frame. For example, a stereo stream at 32 bit resolution and 48 kHz sample rate yields packets of 384 byte for full-speed USB (1 ms frame interval) or 48 byte for high-speed USB (125 us microframe interval). When using feedback, the packet size varies and thus, the max_packet_size should be increased (e.g. to double).

§Arguments
  • builder - The builder for the class.
  • state - The internal state of the class.
  • max_packet_size - The maximum packet size per (micro)frame.
  • resolution - The audio sample resolution.
  • sample_rates_hz - The supported sample rates in Hz.
  • channels - The advertised audio channels (up to 12). Entries must be unique, or this function panics.
  • feedback_refresh_period - The refresh period for the feedback value.

Auto Trait Implementations§

§

impl<'d, D> Freeze for Speaker<'d, D>

§

impl<'d, D> RefUnwindSafe for Speaker<'d, D>
where D: RefUnwindSafe,

§

impl<'d, D> Send for Speaker<'d, D>
where D: Sync,

§

impl<'d, D> Sync for Speaker<'d, D>
where D: Sync,

§

impl<'d, D> Unpin for Speaker<'d, D>

§

impl<'d, D> UnwindSafe for Speaker<'d, D>
where D: RefUnwindSafe,

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<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> 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.