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>
impl<'d, D: Driver<'d>> Speaker<'d, D>
Sourcepub 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>)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more