ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::usb_audio::USBAudioStream Class Referenceabstract

A speaker or microphone platform that streams through the hub. The hub calls it on the main loop only. More...

#include <usb_audio.h>

Inheritance diagram for esphome::usb_audio::USBAudioStream:
esphome::usb_audio::USBAudioMicrophone esphome::usb_audio::USBAudioSpeaker

Public Member Functions

 USBAudioStream (uint32_t buffer_size)
 
uint32_t get_buffer_size () const
 
virtual audio::AudioStreamInfo get_usb_stream_info ()=0
 The fixed format the hub opens the stream with.
 
virtual void on_stream_state (StreamEvent event)=0
 
virtual bool stream_idle () const =0
 No platform task is inside a read or write call on the device; the hub closes a lost device only then.
 
virtual void on_transfer_taken ()
 Speaker only: the driver tried to take its next transfer from the ring buffer, which it does each time a transfer completes and on each write, and takes it only when the ring buffer holds all of it.
 

Protected Attributes

uint32_t buffer_size_
 

Detailed Description

A speaker or microphone platform that streams through the hub. The hub calls it on the main loop only.

Definition at line 39 of file usb_audio.h.

Constructor & Destructor Documentation

◆ USBAudioStream()

esphome::usb_audio::USBAudioStream::USBAudioStream ( uint32_t buffer_size)
inlineexplicit

Definition at line 41 of file usb_audio.h.

Member Function Documentation

◆ get_buffer_size()

uint32_t esphome::usb_audio::USBAudioStream::get_buffer_size ( ) const
inline

Definition at line 43 of file usb_audio.h.

◆ get_usb_stream_info()

virtual audio::AudioStreamInfo esphome::usb_audio::USBAudioStream::get_usb_stream_info ( )
pure virtual

The fixed format the hub opens the stream with.

Implemented in esphome::usb_audio::USBAudioMicrophone, and esphome::usb_audio::USBAudioSpeaker.

◆ on_stream_state()

virtual void esphome::usb_audio::USBAudioStream::on_stream_state ( StreamEvent event)
pure virtual

◆ on_transfer_taken()

virtual void esphome::usb_audio::USBAudioStream::on_transfer_taken ( )
inlinevirtual

Speaker only: the driver tried to take its next transfer from the ring buffer, which it does each time a transfer completes and on each write, and takes it only when the ring buffer holds all of it.

Called on the USB driver's task or inside a write.

Reimplemented in esphome::usb_audio::USBAudioSpeaker.

Definition at line 52 of file usb_audio.h.

◆ stream_idle()

virtual bool esphome::usb_audio::USBAudioStream::stream_idle ( ) const
pure virtual

No platform task is inside a read or write call on the device; the hub closes a lost device only then.

Implemented in esphome::usb_audio::USBAudioMicrophone, and esphome::usb_audio::USBAudioSpeaker.

Field Documentation

◆ buffer_size_

uint32_t esphome::usb_audio::USBAudioStream::buffer_size_
protected

Definition at line 55 of file usb_audio.h.


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