pub struct UacHandler<'d, A: UsbHostAllocator<'d>> {
pub interface_collection: AudioInterfaceCollection,
pub control_channel: A::Pipe<Control, InOut>,
pub output_channel: Option<A::Pipe<Isochronous, Out>>,
pub feedback_channel: Option<A::Pipe<Isochronous, In>>,
/* private fields */
}Expand description
Handler for USB Audio Class (UAC) devices, providing control and streaming functionality.
This struct manages the USB pipes and interface descriptors required to interact with a UAC device, including control, output, and feedback pipes.
Fields§
§interface_collection: AudioInterfaceCollectionCollection of audio interface descriptors parsed from the device configuration.
control_channel: A::Pipe<Control, InOut>Control pipe for sending standard and class-specific requests.
output_channel: Option<A::Pipe<Isochronous, Out>>Output pipe for isochronous audio streaming (if available).
feedback_channel: Option<A::Pipe<Isochronous, In>>Feedback pipe for isochronous feedback endpoint (if available).
Implementations§
Source§impl<'d, A: UsbHostAllocator<'d>> UacHandler<'d, A>
impl<'d, A: UsbHostAllocator<'d>> UacHandler<'d, A>
Sourcepub async fn try_register(
alloc: &A,
enum_info: EnumerationInfo,
) -> Result<Self, RegisterError>
pub async fn try_register( alloc: &A, enum_info: EnumerationInfo, ) -> Result<Self, RegisterError>
Attempts to register a UAC device and allocate necessary pipes.
This method parses the device’s configuration, finds a suitable streaming interface, and allocates output and feedback pipes as needed.
Returns a new UacHandler on success, or a RegisterError if registration fails.
Sourcepub async fn output(&mut self) -> Result<UacOut<'d, A>, RequestError>
pub async fn output(&mut self) -> Result<UacOut<'d, A>, RequestError>
Returns a UacOut object for audio output streaming.
Returns an error if the output or feedback pipe is not allocated or if the interface is unsupported.
Sourcepub fn input_terminal(&self) -> &TerminalDescriptor
pub fn input_terminal(&self) -> &TerminalDescriptor
Returns a reference to the input terminal descriptor associated with this handler.
Sourcepub fn output_interface(&self) -> &AudioStreamingInterface
pub fn output_interface(&self) -> &AudioStreamingInterface
Returns a reference to the output audio streaming interface descriptor.
Sourcepub async fn get_sampling_freq(
&mut self,
terminal_id: u8,
) -> Result<u32, RequestError>
pub async fn get_sampling_freq( &mut self, terminal_id: u8, ) -> Result<u32, RequestError>
Retrieves the current sampling frequency from the specified terminal entity.
Returns the sampling frequency in Hz, or an error if the request fails.
Sourcepub async fn get_supported_language(&mut self) -> Result<u16, RequestError>
pub async fn get_supported_language(&mut self) -> Result<u16, RequestError>
Retrieves the supported language ID from the device.
Returns the language ID as a 16-bit value, or an error if the request fails.
Sourcepub async fn get_string(
&mut self,
index: StringIndex,
lang_id: u16,
) -> Result<String<MAX_STRING_LENGTH>, RequestError>
pub async fn get_string( &mut self, index: StringIndex, lang_id: u16, ) -> Result<String<MAX_STRING_LENGTH>, RequestError>
Retrieves a string descriptor from the device.
§Arguments
index- The string descriptor indexlang_id- The language ID for the string
Returns the string as a UTF-8 encoded string, or an error if the request fails.
Sourcepub async fn get_curr_entity1(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<u8, RequestError>
pub async fn get_curr_entity1( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<u8, RequestError>
Retrieves a 1-byte current value from a UAC entity.
§Arguments
control_selector- The control selector (e.g., volume, mute)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns the current value as a u8, or an error if the request fails.
Sourcepub async fn get_curr_entity2(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<u16, RequestError>
pub async fn get_curr_entity2( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<u16, RequestError>
Retrieves a 2-byte current value from a UAC entity.
§Arguments
control_selector- The control selector (e.g., volume, mute)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns the current value as a u16, or an error if the request fails.
Sourcepub async fn get_curr_entity3(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<u32, RequestError>
pub async fn get_curr_entity3( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<u32, RequestError>
Retrieves a 4-byte current value from a UAC entity.
§Arguments
control_selector- The control selector (e.g., sampling frequency)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns the current value as a u32, or an error if the request fails.
Sourcepub async fn get_range_entity1(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<Layout1ParameterBlock, RequestError>
pub async fn get_range_entity1( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<Layout1ParameterBlock, RequestError>
Retrieves the range of supported 1-byte values from a UAC entity.
§Arguments
control_selector- The control selector (e.g., volume, mute)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns a Layout1ParameterBlock containing the supported ranges, or an error if the request fails.
Sourcepub async fn get_range_entity2(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<Layout2ParameterBlock, RequestError>
pub async fn get_range_entity2( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<Layout2ParameterBlock, RequestError>
Retrieves the range of supported 2-byte values from a UAC entity.
§Arguments
control_selector- The control selector (e.g., volume, mute)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns a Layout2ParameterBlock containing the supported ranges, or an error if the request fails.
Sourcepub async fn get_range_entity3(
&mut self,
control_selector: u16,
channel: u8,
entity: u8,
interface: u8,
) -> Result<Layout3ParameterBlock, RequestError>
pub async fn get_range_entity3( &mut self, control_selector: u16, channel: u8, entity: u8, interface: u8, ) -> Result<Layout3ParameterBlock, RequestError>
Retrieves the range of supported 4-byte values from a UAC entity.
§Arguments
control_selector- The control selector (e.g., sampling frequency)channel- The channel number (0 for master control)entity- The entity IDinterface- The interface number
Returns a Layout3ParameterBlock containing the supported ranges, or an error if the request fails.