#include <audio_decoder.h>
|
| | AudioDecoder (size_t input_buffer_size, size_t output_buffer_size) |
| | Allocates the output transfer buffer and stores the input buffer size for later use by add_source()
|
| |
| | ~AudioDecoder () |
| | Deallocates the MP3 decoder (the flac, opus, and wav decoders are deallocated automatically)
|
| |
| esp_err_t | add_source (std::weak_ptr< RingBuffer > &input_ring_buffer) |
| | Adds a source ring buffer for raw file data.
|
| |
| esp_err_t | add_sink (std::weak_ptr< RingBuffer > &output_ring_buffer) |
| | Adds a sink ring buffer for decoded audio.
|
| |
| esp_err_t | add_sink (speaker::Speaker *speaker) |
| | Adds a sink speaker for decoded audio.
|
| |
| esp_err_t | add_source (const uint8_t *data_pointer, size_t length) |
| | Adds a const data pointer as the source for raw file data.
|
| |
| esp_err_t | add_sink (AudioSinkCallback *callback) |
| | Adds a callback as the sink for decoded audio.
|
| |
| esp_err_t | start (AudioFileType audio_file_type) |
| | Sets up decoding the file.
|
| |
| AudioDecoderState | decode (bool stop_gracefully) |
| | Decodes audio from the ring buffer source and writes to the sink.
|
| |
| const optional< audio::AudioStreamInfo > & | get_audio_stream_info () const |
| | Gets the audio stream information, if it has been decoded from the files header.
|
| |
| uint32_t | get_playback_ms () const |
| | Returns the duration of audio (in milliseconds) decoded and sent to the sink.
|
| |
| void | set_pause_output_state (bool pause_state) |
| | Pauses sending resampled audio to the sink.
|
| |
Definition at line 50 of file audio_decoder.h.
◆ AudioDecoder()
| esphome::audio::AudioDecoder::AudioDecoder |
( |
size_t | input_buffer_size, |
|
|
size_t | output_buffer_size ) |
Allocates the output transfer buffer and stores the input buffer size for later use by add_source()
- Parameters
-
| input_buffer_size | Size of the input transfer buffer in bytes. |
| output_buffer_size | Size of the output transfer buffer in bytes. |
Definition at line 18 of file audio_decoder.cpp.
◆ ~AudioDecoder()
| esphome::audio::AudioDecoder::~AudioDecoder |
( |
| ) |
|
Deallocates the MP3 decoder (the flac, opus, and wav decoders are deallocated automatically)
Definition at line 23 of file audio_decoder.cpp.
◆ add_sink() [1/3]
Adds a callback as the sink for decoded audio.
- Parameters
-
- Returns
- ESP_OK if successful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 66 of file audio_decoder.cpp.
◆ add_sink() [2/3]
Adds a sink speaker for decoded audio.
- Parameters
-
| speaker | pointer to speaker component |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 57 of file audio_decoder.cpp.
◆ add_sink() [3/3]
| esp_err_t esphome::audio::AudioDecoder::add_sink |
( |
std::weak_ptr< RingBuffer > & | output_ring_buffer | ) |
|
Adds a sink ring buffer for decoded audio.
Takes ownership of the ring buffer in a shared_ptr.
- Parameters
-
| output_ring_buffer | weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 48 of file audio_decoder.cpp.
◆ add_source() [1/2]
| esp_err_t esphome::audio::AudioDecoder::add_source |
( |
const uint8_t * | data_pointer, |
|
|
size_t | length ) |
Adds a const data pointer as the source for raw file data.
Does not allocate a transfer buffer.
- Parameters
-
| data_pointer | Pointer to the const audio data (e.g., stored in flash memory) |
| length | Size of the data in bytes |
- Returns
- ESP_OK
Definition at line 41 of file audio_decoder.cpp.
◆ add_source() [2/2]
| esp_err_t esphome::audio::AudioDecoder::add_source |
( |
std::weak_ptr< RingBuffer > & | input_ring_buffer | ) |
|
Adds a source ring buffer for raw file data.
Takes ownership of the ring buffer in a shared_ptr.
- Parameters
-
| input_ring_buffer | weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 31 of file audio_decoder.cpp.
◆ decode()
Decodes audio from the ring buffer source and writes to the sink.
- Parameters
-
| stop_gracefully | If true, it indicates the file source is finished. The decoder will decode all the reamining data and then finish. |
- Returns
- AudioDecoderState
Definition at line 135 of file audio_decoder.cpp.
◆ decode_flac_()
◆ decode_mp3_()
◆ decode_opus_()
◆ decode_wav_()
◆ get_audio_stream_info()
Gets the audio stream information, if it has been decoded from the files header.
- Returns
- optional<AudioStreamInfo> with the audio information. If not available yet, returns no value.
Definition at line 108 of file audio_decoder.h.
◆ get_playback_ms()
| uint32_t esphome::audio::AudioDecoder::get_playback_ms |
( |
| ) |
const |
|
inline |
Returns the duration of audio (in milliseconds) decoded and sent to the sink.
- Returns
- Duration of decoded audio in milliseconds
Definition at line 112 of file audio_decoder.h.
◆ set_pause_output_state()
| void esphome::audio::AudioDecoder::set_pause_output_state |
( |
bool | pause_state | ) |
|
|
inline |
Pauses sending resampled audio to the sink.
If paused, it will continue to process internal buffers.
- Parameters
-
| pause_state | If true, audio data is not sent to the sink. |
Definition at line 116 of file audio_decoder.h.
◆ start()
| esp_err_t esphome::audio::AudioDecoder::start |
( |
AudioFileType | audio_file_type | ) |
|
Sets up decoding the file.
- Parameters
-
| audio_file_type | AudioFileType of the file |
- Returns
- ESP_OK if successful, ESP_ERR_NO_MEM if the transfer buffers fail to allocate, or ESP_ERR_NOT_SUPPORTED if the format isn't supported.
Definition at line 74 of file audio_decoder.cpp.
◆ accumulated_frames_written_
| uint32_t esphome::audio::AudioDecoder::accumulated_frames_written_ {0} |
|
protected |
◆ audio_file_type_
◆ audio_stream_info_
◆ decoder_buffers_internally_
| bool esphome::audio::AudioDecoder::decoder_buffers_internally_ {false} |
|
protected |
◆ end_of_file_
| bool esphome::audio::AudioDecoder::end_of_file_ {false} |
|
protected |
◆ flac_decoder_
| std::unique_ptr<esp_audio_libs::flac::FLACDecoder> esphome::audio::AudioDecoder::flac_decoder_ |
|
protected |
◆ free_buffer_required_
| size_t esphome::audio::AudioDecoder::free_buffer_required_ {0} |
|
protected |
◆ input_buffer_
◆ input_buffer_size_
| size_t esphome::audio::AudioDecoder::input_buffer_size_ {0} |
|
protected |
◆ mp3_decoder_
| esp_audio_libs::helix_decoder::HMP3Decoder esphome::audio::AudioDecoder::mp3_decoder_ |
|
protected |
◆ opus_decoder_
| std::unique_ptr<micro_opus::OggOpusDecoder> esphome::audio::AudioDecoder::opus_decoder_ |
|
protected |
◆ output_transfer_buffer_
◆ pause_output_
| bool esphome::audio::AudioDecoder::pause_output_ {false} |
|
protected |
◆ playback_ms_
| uint32_t esphome::audio::AudioDecoder::playback_ms_ {0} |
|
protected |
◆ potentially_failed_count_
| uint32_t esphome::audio::AudioDecoder::potentially_failed_count_ {0} |
|
protected |
◆ wav_bytes_left_
| size_t esphome::audio::AudioDecoder::wav_bytes_left_ {0} |
|
protected |
◆ wav_decoder_
| std::unique_ptr<esp_audio_libs::wav_decoder::WAVDecoder> esphome::audio::AudioDecoder::wav_decoder_ |
|
protected |
◆ wav_has_known_end_
| bool esphome::audio::AudioDecoder::wav_has_known_end_ {false} |
|
protected |
The documentation for this class was generated from the following files: