arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
USBAudioDeviceTinyUSB Class Reference

USBAudioDeviceBase subclass for RP2040 / Adafruit TinyUSB. More...

#include <USBAudioDeviceTinyUSB.h>

Inheritance diagram for USBAudioDeviceTinyUSB:
USBAudioDeviceBase AudioStream VolumeSupport BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 USBAudioDeviceTinyUSB ()
 Default construcotr using default config.
 
 USBAudioDeviceTinyUSB (USBAudioConfig cfg)
 Constructor with config.
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
uint16_t audioPacketSize () const
 One isochronous USB packet size in bytes (same formula as the descriptor builder).
 
int available () override
 Bytes of received audio waiting in the RX buffer.
 
int availableForWrite () override
 Bytes of free space in the TX buffer.
 
bool begin ()
 (Re-)start the USB audio device with the current config.
 
bool begin (const USBAudioConfig &cfg)
 Apply a config and start the USB audio device.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
USBAudioConfig defaultConfig (RxTxMode mode=RXTX_MODE)
 Returns a default configuration pre-filled for the requested direction (RX_MODE, TX_MODE, or RXTX_MODE). Use TX if you write and rx if you want to read audio data. RXTX is for full duplex.
 
void end ()
 Stop audio streaming and clear FIFOs. Does not disconnect USB.
 
virtual void flush () override
 
uint8_t getAudioCount () const
 Returns the number of audio functions (always 1).
 
usbd_class_driver_t constgetClassDriver (uint8_t *count)
 Get the USB device class driver for TinyUSB integration.
 
uint16_t getDescriptor (uint8_t *desc)
 Returns the audio-function descriptor block for use in tud_descriptor_configuration_cb().
 
uint16_t getInterfaceDescriptor (uint8_t, uint8_t *buf, uint16_t bufsize) override
 
uint32_t getRxTotalBytes () const
 Total bytes received from host via OUT endpoint.
 
uint32_t getRxXferCount () const
 Number of times audiod_xfer_cb fired for the OUT endpoint.
 
uint8_t getTxBytesPerSample () const
 TX bytes per sample parsed from the descriptor.
 
uint8_t getTxChannels () const
 TX channel count parsed from the descriptor.
 
uint32_t getTxFifoReadTotal () const
 
uint16_t getTxFrameBytesLast () const
 
uint8_t getTxInterval () const
 TX isochronous interval (bInterval) parsed from the descriptor.
 
uint32_t getTxSampleRate () const
 TX sample rate parsed from the descriptor (must be non-zero for flow control).
 
uint32_t getTxXferCount () const
 Number of times audiod_xfer_cb fired for the IN endpoint.
 
uint32_t getTxXferredLast () const
 
bool isEpInEnabled () const
 Returns true if the IN endpoint is enabled.
 
bool isEpInFlowControlEnabled () const
 Returns true if IN endpoint flow control is enabled. When on, the per-frame isochronous packet size is varied so non-integer sample-per- frame rates (e.g. 44100 Hz) are delivered at the exact average rate.
 
bool isEpOutEnabled () const
 Returns true if the OUT endpoint is enabled.
 
bool isFeedbackEpEnabled () const
 Returns true if the feedback endpoint is enabled. Only meaningful in pure RX (OUT-only) mode: with an IN endpoint present the host uses the TX stream as implicit feedback instead.
 
bool isFifoMutexEnabled () const
 Returns true if FIFO mutex is enabled.
 
bool isInterruptEpEnabled () const
 Returns true if the interrupt endpoint is enabled.
 
bool isMute (uint8_t channel=0) const
 Returns the current mute state for the given channel.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
bool isStreamingActive () const
 Returns true if either IN or OUT streaming endpoint is open.
 
bool isStreamingActiveRx () const
 Returns true if the host has opened the OUT (playback) stream.
 
bool isStreamingActiveTx () const
 Returns true if the host has opened the IN (capture) stream.
 
bool isTxXferArmed () const
 True if the initial isochronous IN transfer was armed successfully.
 
bool mounted () const
 Returns true if the device is mounted by the USB host.
 
uint8_t numInterfaces () const
 Total number of USB interfaces claimed by the audio function (1 AC + 1 or 2 AS), for use in the bNumInterfaces field of the configuration descriptor.
 
 operator bool () override
 Returns true when begin() has been called and the USB host has mounted the device.
 
size_t readBytes (uint8_t *buffer, size_t bufsize)
 Receive audio data from the host (host → device, speaker/playback).
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioFeedbackFormatCorrectionCallback (std::function< bool(USBAudioDeviceBase *, uint8_t)> cb)
 Register a callback for audio feedback format correction events.
 
void setAudioFeedbackParamsCallback (std::function< void(USBAudioDeviceBase *, uint8_t, uint8_t, audio_feedback_params_t *)> cb)
 Register a callback for audio feedback parameter events.
 
void setAudioInfo (AudioInfo info) override
 Change the sample rate and notify the host.
 
void setFbDoneCallback (std::function< void(USBAudioDeviceBase *, uint8_t)> cb)
 Register a callback for feedback done events.
 
void setGetReqEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)> cb)
 Register a callback for GET requests on an endpoint.
 
void setGetReqItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)> cb)
 Register a callback for GET requests on the interface.
 
void setIntDoneCallback (std::function< void(USBAudioDeviceBase *, uint8_t)> cb)
 Register a callback for interrupt done events.
 
void setItfCloseEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)> cb)
 Register a callback for interface close endpoint events.
 
bool setMute (bool m, uint8_t channel=0)
 Set the mute state for a channel and notify the host.
 
void setMuteCallback (std::function< void(bool, uint8_t)> cb)
 Register a callback invoked when the host (or device) changes the mute state.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setReqEntityCallback (std::function< bool(USBAudioDeviceBase *, uint8_t)> cb)
 Register a callback for entity requests.
 
void setReqEntityCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)> cb)
 Register a callback for entity set requests.
 
void setReqEpCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)> cb)
 Register a callback for endpoint set requests.
 
void setReqItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)> cb)
 Register a callback for interface set requests.
 
void setRxDoneCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *, uint16_t)> cb)
 Register a callback for RX done events.
 
void setSampleRateCallback (std::function< void(uint32_t)> cb)
 Register a callback invoked when the host (or device) changes the sample rate.
 
void setStreamingStateCallback (std::function< void(bool, bool)> cb)
 Register a callback invoked when the streaming state changes. Fires when the host opens or closes a streaming interface (SET_INTERFACE alt=1 / alt=0).
 
void setTudAudioSetItfCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)> cb)
 Register a callback for interface set requests.
 
void setTxDoneCallback (std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *)> cb)
 Register a callback for TX done events.
 
bool setVolume (float vol, uint8_t channel)
 Set the volume for a channel and notify the host.
 
bool setVolume (float volume) override
 sets the volume for the master channel (channel 0)
 
void setVolumeCallback (std::function< void(float, uint8_t)> cb)
 Register a callback invoked when the host (or device) changes the volume.
 
void setWriteBufferSize (int size)
 
float volume () override
 gets the volume for the master channel (channel 0)
 
float volume (uint8_t channel)
 Returns the current volume for the given channel.
 
size_t write (const uint8_t *data, size_t len)
 Send audio data to the host (device → host, microphone/capture). Silently discards data when the host has not opened the capture device (alt=0) so StreamCopy doesn't report write errors before recording.
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Static Public Member Functions

static USBAudioDeviceBaseactiveInstance ()
 Returns the most-recently-constructed instance (base or subclass).
 

Protected Member Functions

bool activateEndpoint (uint8_t rhport, tusb_desc_endpoint_t const *desc_ep, uint8_t dir=TUSB_DIR_IN)
 
void alloc_mutex ()
 
bool audiod_calc_tx_packet_sz (audiod_function_t *audio)
 
bool audiod_control_complete (uint8_t rhport, tusb_control_request_t const *p_request)
 
bool audiod_control_request (uint8_t rhport, tusb_control_request_t const *p_request)
 
bool audiod_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
 
bool audiod_deinit (void)
 
bool audiod_fb_send (audiod_function_t *audio)
 
bool audiod_get_AS_interface_index (uint8_t itf, audiod_function_t *audio, uint8_t *idxItf, uint8_t const **pp_desc_int)
 
bool audiod_get_AS_interface_index_global (uint8_t itf, uint8_t *func_id, uint8_t *idxItf, uint8_t const **pp_desc_int)
 
bool audiod_get_interface (uint8_t rhport, tusb_control_request_t const *p_request)
 
void audiod_init (void)
 
uint16_t audiod_open (uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
 
void audiod_parse_flow_control_params (audiod_function_t *audio, uint8_t const *p_desc)
 
void audiod_reset (uint8_t rhport)
 
bool audiod_set_fb_params_freq (audiod_function_t *audio, uint32_t sample_freq, uint32_t mclk_freq)
 
bool audiod_set_interface (uint8_t rhport, tusb_control_request_t const *p_request)
 
TU_ATTR_FAST_FUNC void audiod_sof_isr (uint8_t rhport, uint32_t frame_count)
 
uint16_t audiod_tx_packet_size_fc (audiod_function_t *audio)
 
bool audiod_verify_entity_exists (uint8_t itf, uint8_t entityID, uint8_t *func_id)
 
bool audiod_verify_ep_exists (uint8_t ep, uint8_t *func_id)
 
bool audiod_verify_itf_exists (uint8_t itf, uint8_t *func_id)
 
bool audiod_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
 TODO refactor control request handling to separate function and reduce nesting.
 
bool beginUSB () override
 Override in platform subclasses to register descriptors and start the USB host-controller stack (e.g. USB.begin() on ESP32). Called at the end of begin(cfg, info). The base no-op is correct for RP2040 where TinyUSB is started by the system before setup().
 
BaseBuffer< uint8_t > & bufferRx () override
 Returns the RX audio buffer (NBuffer block pool).
 
BaseBuffer< uint8_t > & bufferTx () override
 Returns the TX audio buffer (NBuffer block pool).
 
void closeEpIn (uint8_t rhport, audiod_function_t *audio, uint8_t itf, tusb_control_request_t const *p_request)
 
void closeEpOut (uint8_t rhport, audiod_function_t *audio, uint8_t itf, tusb_control_request_t const *p_request)
 
bool configChanged (const USBAudioConfig &n)
 
uint16_t fifoSize () const
 
uint16_t getCtrlBufSz (uint8_t fn) const
 
uint16_t getDescLen (uint8_t fn) const
 
uint16_t getEpInSwBufSz (uint8_t fn) const
 
uint16_t getEpOutSwBufSz (uint8_t fn) const
 
float getVolumeExt (uint8_t channel) const
 Returns the effective volume for a per-channel index (1-based). Combines master volume (index 0) with per-channel volume and mute.
 
bool handleClockSourceGet (uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *cb)
 
bool handleEndpointRequest (uint8_t rhport, tusb_control_request_t const *p_request)
 
bool handleEntityRequest (uint8_t rhport, tusb_control_request_t const *p_request, uint8_t entityID)
 
bool handleFeatureUnitGet (uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *cb)
 
bool handleInterfaceRequest (uint8_t rhport, tusb_control_request_t const *p_request)
 
bool isFeatureUnit (uint8_t id) const
 Returns true if the given entity ID is a Feature Unit (FU1 or FU2).
 
bool isUseLinearBufferRx () const
 
bool isUseLinearBufferTx () const
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void notifyStreamingState ()
 
bool openEndpointsForAltSetting (uint8_t rhport, audiod_function_t *audio, uint8_t func_id, uint8_t itf, uint8_t alt)
 
void openEpFeedback (audiod_function_t *audio, tusb_desc_endpoint_t const *desc_ep)
 
void openEpIn (uint8_t rhport, audiod_function_t *audio, uint8_t itf, tusb_desc_endpoint_t const *desc_ep, uint8_t const *p_desc_for_params)
 
void openEpOut (uint8_t rhport, audiod_function_t *audio, uint8_t itf, tusb_desc_endpoint_t const *desc_ep)
 
uint16_t packetSize () const
 
template<typename T >
void processVolume (T *data, size_t sample_count)
 
void processVolume (uint8_t *data, size_t len)
 Process audio data for volume control.
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
void resizeBuffers () override
 Resize buffers as block pools: block size = one USB frame at the current sample rate, block count = fifo_packets.
 
void sendInterruptNotification (uint8_t ctrlSel, uint8_t channel, uint8_t entityID)
 Send a UAC2 status/change notification via the AC interrupt EP.
 
void serviceTinyUSB ()
 Process pending USB events on platforms where the application drives the stack (RP2040). No-op on ESP32 where a dedicated FreeRTOS task calls tud_task() continuously.
 
void setConfig (const USBAudioConfig &cfg)
 Set the USB audio configuration (use begin(cfg) instead).
 
void setSampleRate (uint32_t rate)
 Device-initiated sample rate change.
 
void setupDescrBuffer ()
 
void setupFeedback (audiod_function_t *audio, uint8_t func_id, uint8_t alt)
 
void tud_audio_feedback_interval_isr (uint8_t func_id, uint32_t, uint8_t frame_shift)
 
uint16_t tud_audio_n_available (uint8_t func_id)
 
uint16_t tud_audio_n_read (uint8_t func_id, void *buffer, uint16_t bufsize)
 
uint16_t tud_audio_n_write (uint8_t func_id, const void *data, uint16_t len)
 

Static Protected Member Functions

static int16_t floatToUac2 (float vol)
 Convert linear volume (0.0–1.0) to UAC2 int16 (1/256 dB). Linear mapping: 0.0 → -100 dB (min), 1.0 → 0 dB (max).
 
static constexpr size_t getResetSize ()
 
static bool isValidBitsPerSample (uint8_t bps)
 
static float uac2ToFloat (int16_t v)
 Convert UAC2 int16 (1/256 dB) to linear volume (0.0–1.0). Linear mapping within the -100..0 dB range reported by GET_RANGE.
 

Protected Attributes

int _timeout = 10
 
USBAudioConfig active_config_
 
std::vector< audiod_function_t > audiod_fct_
 
RingBuffer< uint8_tbuffer_rx_ {0}
 
RingBuffer< uint8_tbuffer_tx_ {0}
 
USBAudioConfig config_
 
std::vector< uint16_tctrl_buf_sz_
 
std::vector< uint16_tdesc_len_
 
USBAudio2DescriptorBuilder descr_builder {config_}
 
std::vector< uint16_tep_in_sw_buf_sz_
 
std::vector< osal_mutex_def_tep_out_ff_mutex_rd_
 
std::vector< uint16_tep_out_sw_buf_sz_
 
std::function< void(USBAudioDeviceBase *, uint8_t func_id)> fb_done_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *)> get_req_ep_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *)> get_req_itf_cb_
 
AudioInfo info
 
std::function< void(USBAudioDeviceBase *, uint8_t rhport)> int_done_cb_
 
uint8_t int_notify_buf_ [6] = {}
 
bool is_active_ = false
 
bool is_notify_active = true
 
bool is_started_ = false
 
std::vector< boolmute_
 
std::function< void(bool, uint8_t)> mute_cb_
 
Vector< AudioInfoSupport * > notify_vector
 
std::function< bool(USBAudioDeviceBase *, uint8_t func_id)> req_entity_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, audiod_function_t *, uint16_t xferred_bytes)> rx_done_cb_
 
volatile uint32_t rx_total_bytes_ = 0
 
std::function< void(uint32_t)> sample_rate_cb_
 
std::function< void(bool, bool)> streaming_state_cb_
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
std::function< bool(USBAudioDeviceBase *, uint8_t func_id)> tud_audio_feedback_format_correction_cb_
 
std::function< void(USBAudioDeviceBase *, uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t *feedback_param)> tud_audio_feedback_params_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *p_request)> tud_audio_set_itf_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *p_request)> tud_audio_set_itf_close_EP_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)> tud_audio_set_req_entity_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)> tud_audio_set_req_ep_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)> tud_audio_set_req_itf_cb_
 
std::function< bool(USBAudioDeviceBase *, uint8_t rhport, audiod_function_t *)> tx_done_cb_
 
volatile uint32_t tx_fifo_read_total_ = 0
 
volatile uint16_t tx_frame_bytes_last_ = 0
 
bool tx_xfer_armed_ = false
 
volatile uint32_t tx_xferred_last_ = 0
 
std::vector< floatvolume_
 
std::function< void(float, uint8_t)> volume_cb_
 
float volume_value = 1.0f
 
int write_buffer_size = MAX_SINGLE_CHARS
 
volatile uint32_t xfer_cb_rx_count_ = 0
 
volatile uint32_t xfer_cb_tx_count_ = 0
 

Static Protected Attributes

static constexpr int16_t kVolumeMinDb256 = -25600
 Convert AudioTools volume (0.0–1.0) to UAC2 int16 (1/256 dB). 0.0 maps to 0x8000 (silence), 1.0 maps to 0 (0 dB).
 
static USBAudioDeviceBases_active_ = nullptr
 

Detailed Description

USBAudioDeviceBase subclass for RP2040 / Adafruit TinyUSB.

Adafruit TinyUSB provides non-weak definitions of tud_descriptor_device_cb, tud_descriptor_configuration_cb, and tud_descriptor_string_cb in Adafruit_USBD_Device.cpp. We must NOT redefine them. Instead this class inherits from Adafruit_USBD_Interface and registers itself via TinyUSBDevice.addInterface(*this). Adafruit's callback then calls getInterfaceDescriptor() to include our UAC2 audio function block inside the overall configuration descriptor.

Device identity (VID/PID, strings) is set through TinyUSBDevice.* before TinyUSBDevice.begin() is called in beginUSB().

Board settings (arduino-pico + Adafruit TinyUSB)

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ USBAudioDeviceTinyUSB() [1/2]

Default construcotr using default config.

◆ USBAudioDeviceTinyUSB() [2/2]

Constructor with config.

Member Function Documentation

◆ activateEndpoint()

bool activateEndpoint ( uint8_t  rhport,
tusb_desc_endpoint_t const desc_ep,
uint8_t  dir = TUSB_DIR_IN 
)
inlineprotectedinherited

◆ activeInstance()

static USBAudioDeviceBase & activeInstance ( )
inlinestaticinherited

Returns the most-recently-constructed instance (base or subclass).

Set in the constructor via s_active_, so usbd_app_driver_get_cb() and the static process() trampoline can reach the right object without a singleton.

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ alloc_mutex()

void alloc_mutex ( )
inlineprotectedinherited

◆ audiod_calc_tx_packet_sz()

bool audiod_calc_tx_packet_sz ( audiod_function_t *  audio)
inlineprotectedinherited

◆ audiod_control_complete()

bool audiod_control_complete ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ audiod_control_request()

bool audiod_control_request ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ audiod_control_xfer_cb()

bool audiod_control_xfer_cb ( uint8_t  rhport,
uint8_t  stage,
tusb_control_request_t const request 
)
inlineprotectedinherited

◆ audiod_deinit()

bool audiod_deinit ( void  )
inlineprotectedinherited

◆ audiod_fb_send()

bool audiod_fb_send ( audiod_function_t *  audio)
inlineprotectedinherited

◆ audiod_get_AS_interface_index()

bool audiod_get_AS_interface_index ( uint8_t  itf,
audiod_function_t *  audio,
uint8_t idxItf,
uint8_t const **  pp_desc_int 
)
inlineprotectedinherited

◆ audiod_get_AS_interface_index_global()

bool audiod_get_AS_interface_index_global ( uint8_t  itf,
uint8_t func_id,
uint8_t idxItf,
uint8_t const **  pp_desc_int 
)
inlineprotectedinherited

◆ audiod_get_interface()

bool audiod_get_interface ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ audiod_init()

void audiod_init ( void  )
inlineprotectedinherited

◆ audiod_open()

uint16_t audiod_open ( uint8_t  rhport,
tusb_desc_interface_t const itf_desc,
uint16_t  max_len 
)
inlineprotectedinherited

◆ audiod_parse_flow_control_params()

void audiod_parse_flow_control_params ( audiod_function_t *  audio,
uint8_t const p_desc 
)
inlineprotectedinherited

◆ audiod_reset()

void audiod_reset ( uint8_t  rhport)
inlineprotectedinherited

◆ audiod_set_fb_params_freq()

bool audiod_set_fb_params_freq ( audiod_function_t *  audio,
uint32_t  sample_freq,
uint32_t  mclk_freq 
)
inlineprotectedinherited

◆ audiod_set_interface()

bool audiod_set_interface ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ audiod_sof_isr()

TU_ATTR_FAST_FUNC void audiod_sof_isr ( uint8_t  rhport,
uint32_t  frame_count 
)
inlineprotectedinherited

◆ audiod_tx_packet_size_fc()

uint16_t audiod_tx_packet_size_fc ( audiod_function_t *  audio)
inlineprotectedinherited

◆ audiod_verify_entity_exists()

bool audiod_verify_entity_exists ( uint8_t  itf,
uint8_t  entityID,
uint8_t func_id 
)
inlineprotectedinherited

◆ audiod_verify_ep_exists()

bool audiod_verify_ep_exists ( uint8_t  ep,
uint8_t func_id 
)
inlineprotectedinherited

◆ audiod_verify_itf_exists()

bool audiod_verify_itf_exists ( uint8_t  itf,
uint8_t func_id 
)
inlineprotectedinherited

◆ audiod_xfer_cb()

bool audiod_xfer_cb ( uint8_t  rhport,
uint8_t  ep_addr,
xfer_result_t  result,
uint32_t  xferred_bytes 
)
inlineprotectedinherited

TODO refactor control request handling to separate function and reduce nesting.

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ audioPacketSize()

uint16_t audioPacketSize ( ) const
inlineinherited

One isochronous USB packet size in bytes (same formula as the descriptor builder).

◆ available()

int available ( )
inlineoverridevirtualinherited

Bytes of received audio waiting in the RX buffer.

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtualinherited

Bytes of free space in the TX buffer.

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlinevirtualinherited

(Re-)start the USB audio device with the current config.

Safe to call more than once: descriptor building, FIFO allocation, and USB stack startup only run on the first call. Subsequent calls just push the current volume/mute/sample-rate state to the host.

Returns
true on success.

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( const USBAudioConfig cfg)
inlineinherited

Apply a config and start the USB audio device.

Before the first begin() all fields may be changed freely. Once started, only the sample rate can change at runtime (via setSampleRate()); descriptor-level fields like channels, bit depth, and endpoint addresses are fixed by the USB enumeration.

Parameters
cfgAudio configuration.
Returns
true on success.

◆ beginUSB()

bool beginUSB ( )
inlineoverrideprotectedvirtual

Override in platform subclasses to register descriptors and start the USB host-controller stack (e.g. USB.begin() on ESP32). Called at the end of begin(cfg, info). The base no-op is correct for RP2040 where TinyUSB is started by the system before setup().

Implements USBAudioDeviceBase.

◆ bufferRx()

BaseBuffer< uint8_t > & bufferRx ( )
inlineoverrideprotectedvirtual

Returns the RX audio buffer (NBuffer block pool).

Implements USBAudioDeviceBase.

◆ bufferTx()

BaseBuffer< uint8_t > & bufferTx ( )
inlineoverrideprotectedvirtual

Returns the TX audio buffer (NBuffer block pool).

Implements USBAudioDeviceBase.

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ closeEpIn()

void closeEpIn ( uint8_t  rhport,
audiod_function_t *  audio,
uint8_t  itf,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ closeEpOut()

void closeEpOut ( uint8_t  rhport,
audiod_function_t *  audio,
uint8_t  itf,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ configChanged()

bool configChanged ( const USBAudioConfig n)
inlineprotectedinherited

◆ defaultConfig()

USBAudioConfig defaultConfig ( RxTxMode  mode = RXTX_MODE)
inlineinherited

Returns a default configuration pre-filled for the requested direction (RX_MODE, TX_MODE, or RXTX_MODE). Use TX if you write and rx if you want to read audio data. RXTX is for full duplex.

Parameters
modeAudio direction.

◆ end()

void end ( )
inlinevirtualinherited

Stop audio streaming and clear FIFOs. Does not disconnect USB.

Reimplemented from BaseStream.

◆ fifoSize()

uint16_t fifoSize ( ) const
inlineprotectedinherited

◆ floatToUac2()

static int16_t floatToUac2 ( float  vol)
inlinestaticprotectedinherited

Convert linear volume (0.0–1.0) to UAC2 int16 (1/256 dB). Linear mapping: 0.0 → -100 dB (min), 1.0 → 0 dB (max).

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ getAudioCount()

uint8_t getAudioCount ( ) const
inlineinherited

Returns the number of audio functions (always 1).

◆ getClassDriver()

usbd_class_driver_t const * getClassDriver ( uint8_t count)
inlineinherited

Get the USB device class driver for TinyUSB integration.

Parameters
countPointer to store the number of drivers (always 1).
Returns
Pointer to the class driver structure.

◆ getCtrlBufSz()

uint16_t getCtrlBufSz ( uint8_t  fn) const
inlineprotectedinherited

◆ getDescLen()

uint16_t getDescLen ( uint8_t  fn) const
inlineprotectedinherited

◆ getDescriptor()

uint16_t getDescriptor ( uint8_t desc)
inlineinherited

Returns the audio-function descriptor block for use in tud_descriptor_configuration_cb().

Call begin() first so that the config is known. The returned pointer points to an internal static buffer that is valid for the lifetime of the program; copy it into your configuration descriptor buffer.

Parameters
[out]lenTotal byte count of the returned block.
Returns
Pointer to the audio function descriptor bytes.

◆ getEpInSwBufSz()

uint16_t getEpInSwBufSz ( uint8_t  fn) const
inlineprotectedinherited

◆ getEpOutSwBufSz()

uint16_t getEpOutSwBufSz ( uint8_t  fn) const
inlineprotectedinherited

◆ getInterfaceDescriptor()

uint16_t getInterfaceDescriptor ( uint8_t  ,
uint8_t buf,
uint16_t  bufsize 
)
inlineoverride

Called by Adafruit's addInterface() to build our UAC2 descriptor block into the shared configuration descriptor buffer.

When buf is non-NULL, allocate interface and endpoint numbers from TinyUSBDevice so they are unique across all registered interfaces. When buf is NULL, return the descriptor length for sizing only. The itfnum_deprecated parameter is ignored — Adafruit now manages interface numbering internally via allocInterface().

◆ getResetSize()

static constexpr size_t getResetSize ( )
inlinestaticconstexprprotectedinherited

◆ getRxTotalBytes()

uint32_t getRxTotalBytes ( ) const
inlineinherited

Total bytes received from host via OUT endpoint.

◆ getRxXferCount()

uint32_t getRxXferCount ( ) const
inlineinherited

Number of times audiod_xfer_cb fired for the OUT endpoint.

◆ getTxBytesPerSample()

uint8_t getTxBytesPerSample ( ) const
inlineinherited

TX bytes per sample parsed from the descriptor.

◆ getTxChannels()

uint8_t getTxChannels ( ) const
inlineinherited

TX channel count parsed from the descriptor.

◆ getTxFifoReadTotal()

uint32_t getTxFifoReadTotal ( ) const
inlineinherited

Total bytes read from ep_in_ff by xfer_cb (should grow at ~176KB/s for 44100Hz stereo 16-bit).

◆ getTxFrameBytesLast()

uint16_t getTxFrameBytesLast ( ) const
inlineinherited

Last frame_bytes computed by flow control (should be ~176-180 for 44100Hz).

◆ getTxInterval()

uint8_t getTxInterval ( ) const
inlineinherited

TX isochronous interval (bInterval) parsed from the descriptor.

◆ getTxSampleRate()

uint32_t getTxSampleRate ( ) const
inlineinherited

TX sample rate parsed from the descriptor (must be non-zero for flow control).

◆ getTxXferCount()

uint32_t getTxXferCount ( ) const
inlineinherited

Number of times audiod_xfer_cb fired for the IN endpoint.

◆ getTxXferredLast()

uint32_t getTxXferredLast ( ) const
inlineinherited

xferred_bytes from the previous completed transfer (what the DCD actually sent).

◆ getVolumeExt()

float getVolumeExt ( uint8_t  channel) const
inlineprotectedinherited

Returns the effective volume for a per-channel index (1-based). Combines master volume (index 0) with per-channel volume and mute.

◆ handleClockSourceGet()

bool handleClockSourceGet ( uint8_t  rhport,
tusb_control_request_t const p_request,
uint8_t cb 
)
inlineprotectedinherited

◆ handleEndpointRequest()

bool handleEndpointRequest ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ handleEntityRequest()

bool handleEntityRequest ( uint8_t  rhport,
tusb_control_request_t const p_request,
uint8_t  entityID 
)
inlineprotectedinherited

◆ handleFeatureUnitGet()

bool handleFeatureUnitGet ( uint8_t  rhport,
tusb_control_request_t const p_request,
uint8_t cb 
)
inlineprotectedinherited

◆ handleInterfaceRequest()

bool handleInterfaceRequest ( uint8_t  rhport,
tusb_control_request_t const p_request 
)
inlineprotectedinherited

◆ isEpInEnabled()

bool isEpInEnabled ( ) const
inlineinherited

Returns true if the IN endpoint is enabled.

◆ isEpInFlowControlEnabled()

bool isEpInFlowControlEnabled ( ) const
inlineinherited

Returns true if IN endpoint flow control is enabled. When on, the per-frame isochronous packet size is varied so non-integer sample-per- frame rates (e.g. 44100 Hz) are delivered at the exact average rate.

◆ isEpOutEnabled()

bool isEpOutEnabled ( ) const
inlineinherited

Returns true if the OUT endpoint is enabled.

◆ isFeatureUnit()

bool isFeatureUnit ( uint8_t  id) const
inlineprotectedinherited

Returns true if the given entity ID is a Feature Unit (FU1 or FU2).

◆ isFeedbackEpEnabled()

bool isFeedbackEpEnabled ( ) const
inlineinherited

Returns true if the feedback endpoint is enabled. Only meaningful in pure RX (OUT-only) mode: with an IN endpoint present the host uses the TX stream as implicit feedback instead.

◆ isFifoMutexEnabled()

bool isFifoMutexEnabled ( ) const
inlineinherited

Returns true if FIFO mutex is enabled.

◆ isInterruptEpEnabled()

bool isInterruptEpEnabled ( ) const
inlineinherited

Returns true if the interrupt endpoint is enabled.

◆ isMute()

bool isMute ( uint8_t  channel = 0) const
inlineinherited

Returns the current mute state for the given channel.

Parameters
channel0 = master, 1..N = per-channel.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isStreamingActive()

bool isStreamingActive ( ) const
inlineinherited

Returns true if either IN or OUT streaming endpoint is open.

◆ isStreamingActiveRx()

bool isStreamingActiveRx ( ) const
inlineinherited

Returns true if the host has opened the OUT (playback) stream.

◆ isStreamingActiveTx()

bool isStreamingActiveTx ( ) const
inlineinherited

Returns true if the host has opened the IN (capture) stream.

◆ isTxXferArmed()

bool isTxXferArmed ( ) const
inlineinherited

True if the initial isochronous IN transfer was armed successfully.

◆ isUseLinearBufferRx()

bool isUseLinearBufferRx ( ) const
inlineprotectedinherited

◆ isUseLinearBufferTx()

bool isUseLinearBufferTx ( ) const
inlineprotectedinherited

◆ isValidBitsPerSample()

static bool isValidBitsPerSample ( uint8_t  bps)
inlinestaticprotectedinherited

◆ mounted()

bool mounted ( ) const
inlineinherited

Returns true if the device is mounted by the USB host.

◆ not_supported()

virtual int not_supported ( int  out,
const char msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ notifyStreamingState()

void notifyStreamingState ( )
inlineprotectedinherited

◆ numInterfaces()

uint8_t numInterfaces ( ) const
inlineinherited

Total number of USB interfaces claimed by the audio function (1 AC + 1 or 2 AS), for use in the bNumInterfaces field of the configuration descriptor.

◆ openEndpointsForAltSetting()

bool openEndpointsForAltSetting ( uint8_t  rhport,
audiod_function_t *  audio,
uint8_t  func_id,
uint8_t  itf,
uint8_t  alt 
)
inlineprotectedinherited

◆ openEpFeedback()

void openEpFeedback ( audiod_function_t *  audio,
tusb_desc_endpoint_t const desc_ep 
)
inlineprotectedinherited

◆ openEpIn()

void openEpIn ( uint8_t  rhport,
audiod_function_t *  audio,
uint8_t  itf,
tusb_desc_endpoint_t const desc_ep,
uint8_t const p_desc_for_params 
)
inlineprotectedinherited

◆ openEpOut()

void openEpOut ( uint8_t  rhport,
audiod_function_t *  audio,
uint8_t  itf,
tusb_desc_endpoint_t const desc_ep 
)
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlineoverridevirtualinherited

Returns true when begin() has been called and the USB host has mounted the device.

Reimplemented from AudioStream.

◆ packetSize()

uint16_t packetSize ( ) const
inlineprotectedinherited

◆ processVolume() [1/2]

template<typename T >
void processVolume ( T data,
size_t  sample_count 
)
inlineprotectedinherited

◆ processVolume() [2/2]

void processVolume ( uint8_t data,
size_t  len 
)
inlineprotectedinherited

Process audio data for volume control.

◆ readBytes()

size_t readBytes ( uint8_t buffer,
size_t  bufsize 
)
inlinevirtualinherited

Receive audio data from the host (host → device, speaker/playback).

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ resizeBuffers()

void resizeBuffers ( )
inlineoverrideprotectedvirtual

Resize buffers as block pools: block size = one USB frame at the current sample rate, block count = fifo_packets.

Implements USBAudioDeviceBase.

◆ sendInterruptNotification()

void sendInterruptNotification ( uint8_t  ctrlSel,
uint8_t  channel,
uint8_t  entityID 
)
inlineprotectedinherited

Send a UAC2 status/change notification via the AC interrupt EP.

6-byte message: bInfo(1) bAttribute(1) wValue(2) wIndex(2). The host will re-query the affected control with GET_CUR.

Parameters
ctrlSelControl selector (e.g. AUDIO_FU_CTRL_VOLUME).
channelChannel number (0 = master).
entityIDTarget entity (Feature Unit or Clock Source).

◆ serviceTinyUSB()

void serviceTinyUSB ( )
inlineprotectedinherited

Process pending USB events on platforms where the application drives the stack (RP2040). No-op on ESP32 where a dedicated FreeRTOS task calls tud_task() continuously.

◆ setAudioFeedbackFormatCorrectionCallback()

void setAudioFeedbackFormatCorrectionCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t)>  cb)
inlineinherited

Register a callback for audio feedback format correction events.

Parameters
cbCallback function.

◆ setAudioFeedbackParamsCallback()

void setAudioFeedbackParamsCallback ( std::function< void(USBAudioDeviceBase *, uint8_t, uint8_t, audio_feedback_params_t *)>  cb)
inlineinherited

Register a callback for audio feedback parameter events.

Parameters
cbCallback function.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

Change the sample rate and notify the host.

Reimplemented from AudioStream.

◆ setConfig()

void setConfig ( const USBAudioConfig cfg)
inlineprotectedinherited

Set the USB audio configuration (use begin(cfg) instead).

◆ setFbDoneCallback()

void setFbDoneCallback ( std::function< void(USBAudioDeviceBase *, uint8_t)>  cb)
inlineinherited

Register a callback for feedback done events.

Parameters
cbCallback function.

◆ setGetReqEpCallback()

void setGetReqEpCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)>  cb)
inlineinherited

Register a callback for GET requests on an endpoint.

Parameters
cbCallback function.

◆ setGetReqItfCallback()

void setGetReqItfCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)>  cb)
inlineinherited

Register a callback for GET requests on the interface.

Parameters
cbCallback function.

◆ setIntDoneCallback()

void setIntDoneCallback ( std::function< void(USBAudioDeviceBase *, uint8_t)>  cb)
inlineinherited

Register a callback for interrupt done events.

Parameters
cbCallback function.

◆ setItfCloseEpCallback()

void setItfCloseEpCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)>  cb)
inlineinherited

Register a callback for interface close endpoint events.

Parameters
cbCallback function.

◆ setMute()

bool setMute ( bool  m,
uint8_t  channel = 0 
)
inlineinherited

Set the mute state for a channel and notify the host.

Parameters
mtrue = muted, false = unmuted.
channel0 = master, 1..N = per-channel.
Returns
true if the channel index was valid.

◆ setMuteCallback()

void setMuteCallback ( std::function< void(bool, uint8_t)>  cb)
inlineinherited

Register a callback invoked when the host (or device) changes the mute state.

Parameters
cbCallback receiving (bool muted, uint8_t channel).

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ setReqEntityCallback() [1/2]

void setReqEntityCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t)>  cb)
inlineinherited

Register a callback for entity requests.

Parameters
cbCallback function.

◆ setReqEntityCallback() [2/2]

void setReqEntityCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)>  cb)
inlineinherited

Register a callback for entity set requests.

Parameters
cbCallback function.

◆ setReqEpCallback()

void setReqEpCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)>  cb)
inlineinherited

Register a callback for endpoint set requests.

Parameters
cbCallback function.

◆ setReqItfCallback()

void setReqItfCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *, uint8_t *)>  cb)
inlineinherited

Register a callback for interface set requests.

Parameters
cbCallback function.

◆ setRxDoneCallback()

void setRxDoneCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *, uint16_t)>  cb)
inlineinherited

Register a callback for RX done events.

Parameters
cbCallback function.

◆ setSampleRate()

void setSampleRate ( uint32_t  rate)
inlineprotectedinherited

Device-initiated sample rate change.

Updates the internal config, fires the sample-rate callback, and notifies the host via the AC interrupt endpoint (Clock Source SAM_FREQ CUR). The host will typically re-issue SET_INTERFACE to restart streaming at the new rate.

Parameters
rateNew sample rate in Hz (should be one of the 14 rates advertised in the Clock Source GET_RANGE response).

◆ setSampleRateCallback()

void setSampleRateCallback ( std::function< void(uint32_t)>  cb)
inlineinherited

Register a callback invoked when the host (or device) changes the sample rate.

Parameters
cbCallback receiving the new rate in Hz.

◆ setStreamingStateCallback()

void setStreamingStateCallback ( std::function< void(bool, bool)>  cb)
inlineinherited

Register a callback invoked when the streaming state changes. Fires when the host opens or closes a streaming interface (SET_INTERFACE alt=1 / alt=0).

Parameters
cbCallback receiving (bool active_tx, bool active_rx).

◆ setTudAudioSetItfCallback()

void setTudAudioSetItfCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, tusb_control_request_t const *)>  cb)
inlineinherited

Register a callback for interface set requests.

Parameters
cbCallback function.

◆ setTxDoneCallback()

void setTxDoneCallback ( std::function< bool(USBAudioDeviceBase *, uint8_t, audiod_function_t *)>  cb)
inlineinherited

Register a callback for TX done events.

Parameters
cbCallback function.

◆ setupDescrBuffer()

void setupDescrBuffer ( )
inlineprotected

◆ setupFeedback()

void setupFeedback ( audiod_function_t *  audio,
uint8_t  func_id,
uint8_t  alt 
)
inlineprotectedinherited

◆ setVolume() [1/2]

bool setVolume ( float  vol,
uint8_t  channel 
)
inlineinherited

Set the volume for a channel and notify the host.

Parameters
volVolume as a float 0.0 (silence) to 1.0 (0 dB).
channel0 = master, 1..N = per-channel.
Returns
true if the channel index was valid.

◆ setVolume() [2/2]

bool setVolume ( float  volume)
inlineoverridevirtualinherited

sets the volume for the master channel (channel 0)

Reimplemented from VolumeSupport.

◆ setVolumeCallback()

void setVolumeCallback ( std::function< void(float, uint8_t)>  cb)
inlineinherited

Register a callback invoked when the host (or device) changes the volume.

Parameters
cbCallback receiving (float volume, uint8_t channel).

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ tud_audio_feedback_interval_isr()

void tud_audio_feedback_interval_isr ( uint8_t  func_id,
uint32_t  ,
uint8_t  frame_shift 
)
inlineprotectedinherited

◆ tud_audio_n_available()

uint16_t tud_audio_n_available ( uint8_t  func_id)
inlineprotectedinherited

◆ tud_audio_n_read()

uint16_t tud_audio_n_read ( uint8_t  func_id,
void buffer,
uint16_t  bufsize 
)
inlineprotectedinherited

◆ tud_audio_n_write()

uint16_t tud_audio_n_write ( uint8_t  func_id,
const void data,
uint16_t  len 
)
inlineprotectedinherited

◆ uac2ToFloat()

static float uac2ToFloat ( int16_t  v)
inlinestaticprotectedinherited

Convert UAC2 int16 (1/256 dB) to linear volume (0.0–1.0). Linear mapping within the -100..0 dB range reported by GET_RANGE.

◆ volume() [1/2]

float volume ( )
inlineoverridevirtualinherited

gets the volume for the master channel (channel 0)

Reimplemented from VolumeSupport.

◆ volume() [2/2]

float volume ( uint8_t  channel)
inlineinherited

Returns the current volume for the given channel.

Parameters
channel0 = master, 1..N = per-channel.
Returns
Volume as a float in the range 0.0 (silence) to 1.0 (0 dB).

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  len 
)
inlinevirtualinherited

Send audio data to the host (device → host, microphone/capture). Silently discards data when the host has not opened the capture device (alt=0) so StreamCopy doesn't report write errors before recording.

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ active_config_

USBAudioConfig active_config_
protectedinherited

◆ audiod_fct_

std::vector<audiod_function_t> audiod_fct_
protectedinherited

◆ buffer_rx_

RingBuffer<uint8_t> buffer_rx_ {0}
protected

◆ buffer_tx_

RingBuffer<uint8_t> buffer_tx_ {0}
protected

◆ config_

USBAudioConfig config_
protectedinherited

◆ ctrl_buf_sz_

std::vector<uint16_t> ctrl_buf_sz_
protectedinherited

◆ desc_len_

std::vector<uint16_t> desc_len_
protectedinherited

◆ descr_builder

USBAudio2DescriptorBuilder descr_builder {config_}
protectedinherited

◆ ep_in_sw_buf_sz_

std::vector<uint16_t> ep_in_sw_buf_sz_
protectedinherited

◆ ep_out_ff_mutex_rd_

std::vector<osal_mutex_def_t> ep_out_ff_mutex_rd_
protectedinherited

◆ ep_out_sw_buf_sz_

std::vector<uint16_t> ep_out_sw_buf_sz_
protectedinherited

◆ fb_done_cb_

std::function<void(USBAudioDeviceBase*, uint8_t func_id)> fb_done_cb_
protectedinherited

◆ get_req_ep_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const*)> get_req_ep_cb_
protectedinherited

◆ get_req_itf_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const*)> get_req_itf_cb_
protectedinherited

◆ info

AudioInfo info
protectedinherited

◆ int_done_cb_

std::function<void(USBAudioDeviceBase*, uint8_t rhport)> int_done_cb_
protectedinherited

◆ int_notify_buf_

uint8_t int_notify_buf_[6] = {}
protectedinherited

◆ is_active_

bool is_active_ = false
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_started_

bool is_started_ = false
protectedinherited

◆ kVolumeMinDb256

constexpr int16_t kVolumeMinDb256 = -25600
staticconstexprprotectedinherited

Convert AudioTools volume (0.0–1.0) to UAC2 int16 (1/256 dB). 0.0 maps to 0x8000 (silence), 1.0 maps to 0 (0 dB).

◆ mute_

std::vector<bool> mute_
protectedinherited

◆ mute_cb_

std::function<void(bool, uint8_t)> mute_cb_
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ req_entity_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t func_id)> req_entity_cb_
protectedinherited

◆ rx_done_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, audiod_function_t*, uint16_t xferred_bytes)> rx_done_cb_
protectedinherited

◆ rx_total_bytes_

volatile uint32_t rx_total_bytes_ = 0
protectedinherited

◆ s_active_

USBAudioDeviceBase* s_active_ = nullptr
inlinestaticprotectedinherited

◆ sample_rate_cb_

std::function<void(uint32_t)> sample_rate_cb_
protectedinherited

◆ streaming_state_cb_

std::function<void(bool, bool)> streaming_state_cb_
protectedinherited

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ tud_audio_feedback_format_correction_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t func_id)> tud_audio_feedback_format_correction_cb_
protectedinherited

◆ tud_audio_feedback_params_cb_

std::function<void(USBAudioDeviceBase*, uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t* feedback_param)> tud_audio_feedback_params_cb_
protectedinherited

◆ tud_audio_set_itf_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const* p_request)> tud_audio_set_itf_cb_
protectedinherited

◆ tud_audio_set_itf_close_EP_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const* p_request)> tud_audio_set_itf_close_EP_cb_
protectedinherited

◆ tud_audio_set_req_entity_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const* p_request, uint8_t* pBuff)> tud_audio_set_req_entity_cb_
protectedinherited

◆ tud_audio_set_req_ep_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const* p_request, uint8_t* pBuff)> tud_audio_set_req_ep_cb_
protectedinherited

◆ tud_audio_set_req_itf_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, tusb_control_request_t const* p_request, uint8_t* pBuff)> tud_audio_set_req_itf_cb_
protectedinherited

◆ tx_done_cb_

std::function<bool(USBAudioDeviceBase*, uint8_t rhport, audiod_function_t*)> tx_done_cb_
protectedinherited

◆ tx_fifo_read_total_

volatile uint32_t tx_fifo_read_total_ = 0
protectedinherited

◆ tx_frame_bytes_last_

volatile uint16_t tx_frame_bytes_last_ = 0
protectedinherited

◆ tx_xfer_armed_

bool tx_xfer_armed_ = false
protectedinherited

◆ tx_xferred_last_

volatile uint32_t tx_xferred_last_ = 0
protectedinherited

◆ volume_

std::vector<float> volume_
protectedinherited

◆ volume_cb_

std::function<void(float, uint8_t)> volume_cb_
protectedinherited

◆ volume_value

float volume_value = 1.0f
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

◆ xfer_cb_rx_count_

volatile uint32_t xfer_cb_rx_count_ = 0
protectedinherited

◆ xfer_cb_tx_count_

volatile uint32_t xfer_cb_tx_count_ = 0
protectedinherited

The documentation for this class was generated from the following file: