arduino-audio-tools
Loading...
Searching...
No Matches
USBAudioHostTinyUSB.h
Go to the documentation of this file.
1#pragma once
5
6namespace audio_tools {
7
31 public:
35 USBAudioHostTinyUSB(Adafruit_USBH_Host& host) : backend_impl_(host) {}
36
39 void setHost(Adafruit_USBH_Host& host) { backend_impl_.setHost(host); }
40
41 BaseBuffer<uint8_t>& bufferTx() override { return buffer_tx_; }
42
43 BaseBuffer<uint8_t>& bufferRx() override { return buffer_rx_; }
44
47 void serviceUSB() override {
49 }
50
51 protected:
55
57
58 void resizeBuffers() override {
59 size_t size = (size_t)audioPacketSize() * config_.fifo_packets;
60 if (isEpOutEnabled()) buffer_tx_.resize(size);
61 if (isEpInEnabled()) buffer_rx_.resize(size);
62 }
63};
64
65} // namespace audio_tools
Shared functionality of all buffers.
Definition Buffers.h:23
Lock-free Single-Producer Single-Consumer ring buffer.
Definition RingBufferSPSC.h:52
bool resize(size_t capacity) override
Resizes the buffer if supported: returns false if not supported.
Definition RingBufferSPSC.h:144
Abstract seam for every raw USB host stack call the UAC host class logic (USBAudioHostBase) needs....
Definition USBAudioHostBackend.h:73
USBAudioHostBackend for the TinyUSB host stack provided by the Adafruit TinyUSB Library (RP2040/RP235...
Definition USBAudioHostBackendTinyUSB.h:51
void setHost(Adafruit_USBH_Host &host)
Defines the Adafruit_USBH_Host (call before begin())
Definition USBAudioHostBackendTinyUSB.h:60
USB Audio Class (UAC1 and UAC2) host: reads PCM audio from an attached USB microphone and/or writes P...
Definition USBAudioHostBase.h:48
void processUSB()
Definition USBAudioHostBase.h:389
uint16_t audioPacketSize() const
Definition USBAudioHostBase.h:226
USB Audio host for the Adafruit TinyUSB host stack: reads audio from an attached USB microphone and/o...
Definition USBAudioHostTinyUSB.h:30
RingBufferSPSC< uint8_t > buffer_tx_
Definition USBAudioHostTinyUSB.h:53
BaseBuffer< uint8_t > & bufferTx() override
Returns the TX audio buffer. Must be overridden by subclasses.
Definition USBAudioHostTinyUSB.h:41
void serviceUSB() override
Process pending USB events. Skipped when a dedicated FreeRTOS task already runs the USB stack (tuh_ta...
Definition USBAudioHostTinyUSB.h:47
USBAudioHostBackend & backend() override
Returns the backend used for all USB host stack calls.
Definition USBAudioHostTinyUSB.h:56
RingBufferSPSC< uint8_t > buffer_rx_
Definition USBAudioHostTinyUSB.h:54
USBAudioHostTinyUSB(USBAudioConfig cfg)
Definition USBAudioHostTinyUSB.h:33
void resizeBuffers() override
Resize the platform audio buffers.
Definition USBAudioHostTinyUSB.h:58
USBAudioHostBackendTinyUSB backend_impl_
Definition USBAudioHostTinyUSB.h:52
USBAudioHostTinyUSB(Adafruit_USBH_Host &host)
Use the Adafruit_USBH_Host which was set up by the sketch.
Definition USBAudioHostTinyUSB.h:35
BaseBuffer< uint8_t > & bufferRx() override
Returns the RX audio buffer. Must be overridden by subclasses.
Definition USBAudioHostTinyUSB.h:43
void setHost(Adafruit_USBH_Host &host)
Definition USBAudioHostTinyUSB.h:39
bool isEpInEnabled() const
Returns true if the IN endpoint is enabled.
Definition USBAudioStreamBase.h:42
USBAudioConfig config_
Definition USBAudioStreamBase.h:235
bool usb_task_active_
Definition USBAudioStreamBase.h:223
bool isEpOutEnabled() const
Returns true if the OUT endpoint is enabled.
Definition USBAudioStreamBase.h:45
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
Definition USBAudioConfig.h:117
uint8_t fifo_packets
Definition USBAudioConfig.h:148