pub struct AudioClass<'a, B: UsbBus> { /* private fields */ }Expand description
USB Audio Class 1.0 device class.
Supports one streaming input (microphone / line-in) and/or one streaming
output (speaker / headphones). Built via AudioClassBuilder.
The host activates a stream by selecting alternate setting 1
(via SET_INTERFACE), and deactivates it by selecting alternate setting 0.
Implementations§
Source§impl<'a, B: UsbBus> AudioClass<'a, B>
impl<'a, B: UsbBus> AudioClass<'a, B>
Sourcepub fn read(&self, buf: &mut [u8]) -> UsbResult<usize>
pub fn read(&self, buf: &mut [u8]) -> UsbResult<usize>
Read audio data from the host (output / speaker stream).
Returns the number of bytes read into buf, or
UsbError::WouldBlock when no isochronous packet is available.
Also returns UsbError::InvalidState if the stream is not
configured or not active (alt setting 0).
Sourcepub fn write(&self, buf: &[u8]) -> UsbResult<usize>
pub fn write(&self, buf: &[u8]) -> UsbResult<usize>
Write audio data to the host (input / microphone stream).
Returns the number of bytes written, or UsbError::WouldBlock
when the previous packet has not yet been sent. Also returns
UsbError::InvalidState if the stream is not configured or
not active (alt setting 0).
Sourcepub fn input_alt_setting(&self) -> Option<u8>
pub fn input_alt_setting(&self) -> Option<u8>
Current alternate setting of the input (microphone) stream.
Returns None if no input stream was configured.
Sourcepub fn output_alt_setting(&self) -> Option<u8>
pub fn output_alt_setting(&self) -> Option<u8>
Current alternate setting of the output (speaker) stream.
Returns None if no output stream was configured.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
true when the device has been fully configured by the host.
Sourcepub fn output_active(&self) -> bool
pub fn output_active(&self) -> bool
true when the output (speaker) stream is active (alt setting ≠ 0).
Sourcepub fn input_active(&self) -> bool
pub fn input_active(&self) -> bool
true when the input (microphone) stream is active (alt setting ≠ 0).
Trait Implementations§
Source§impl<B: UsbBus> UsbClass<B> for AudioClass<'_, B>
impl<B: UsbBus> UsbClass<B> for AudioClass<'_, B>
Source§fn configuration_descriptors(
&self,
w: &mut DescriptorWriter<'_>,
) -> UsbResult<()>
fn configuration_descriptors( &self, w: &mut DescriptorWriter<'_>, ) -> UsbResult<()>
Source§fn control_in(&mut self, xfer: ControlIn<'_, B>)
fn control_in(&mut self, xfer: ControlIn<'_, B>)
Source§fn control_out(&mut self, xfer: ControlOut<'_, B>)
fn control_out(&mut self, xfer: ControlOut<'_, B>)
Source§fn deconfigure(&mut self)
fn deconfigure(&mut self)
Source§fn alt_setting(&mut self, iface: InterfaceNumber) -> Option<u8>
fn alt_setting(&mut self, iface: InterfaceNumber) -> Option<u8>
interface, or None.Source§fn set_alt_setting(&mut self, iface: InterfaceNumber, alt: u8) -> bool
fn set_alt_setting(&mut self, iface: InterfaceNumber, alt: u8) -> bool
interface. Return true if handled.Source§fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
fn string(&self, index: StringIndex, lang_id: u16) -> Option<&str>
StringIndex, or None.Source§fn endpoint_out(&mut self, addr: EndpointAddress)
fn endpoint_out(&mut self, addr: EndpointAddress)
addr received an OUT packet.Source§fn endpoint_in_complete(&mut self, addr: EndpointAddress)
fn endpoint_in_complete(&mut self, addr: EndpointAddress)
addr completed an IN transfer.Source§fn endpoint_setup(&mut self, addr: EndpointAddress)
fn endpoint_setup(&mut self, addr: EndpointAddress)
addr received a SETUP packet (non-EP0 control).Source§fn poll(&mut self)
fn poll(&mut self)
UsbDevice::poll.