embassy-usb-host

Crates

git

Versions

default

Flavors

Module uac

Module uac 

Source
Expand description

USB Audio Class (UAC) handler module.

This module provides functionality for interacting with USB Audio Class devices, including device registration, control requests, and audio streaming.

§Overview

The UAC handler supports:

  • Device enumeration and interface discovery
  • Control requests for audio parameters (volume, mute, sampling frequency, etc.)
  • Isochronous audio streaming with feedback
  • String descriptor retrieval
  • Range queries for supported parameter values

See the UAC specification for more details.

§Usage

// Register a UAC device
let handler = UacHandler::try_register(&bus, enum_info).await?;

// Get current sampling frequency
let freq = handler.get_sampling_freq(terminal_id).await?;

// Start audio output stream. The callback is called repeatedly whenever the buffer is ready to be filled.
let mut output = handler.output()?;
output.output_stream(|buffer| {
    // Fill buffer with audio data
}).await?;

Modules§

codes
USB Audio Device Class constants from UAC2 specification Based on USB Device Class Definition for Audio Devices, Release 2.0 (May 31, 2006)
descriptors
USB Audio Class (UAC) descriptor parsing and management.

Structs§

Layout1ParameterBlock
Parameter block for range queries with 1-byte values.
Layout2ParameterBlock
Parameter block for range queries with 2-byte values.
Layout3ParameterBlock
Parameter block for range queries with 4-byte values.
Range1
Represents a range of 1-byte (u8) values.
Range2
Represents a range of 2-byte (u16) values.
Range4
Represents a range of 4-byte (u32) values.
UacHandler
Handler for USB Audio Class (UAC) devices, providing control and streaming functionality.
UacOut
Represents an output audio stream to a USB Audio Class (UAC) device.

Enums§

RequestError
Errors that can occur during UAC request handling.

Functions§

parse_feedback
Parse USB feedback endpoint response into a floating point number.