#include <audio_decoder.h>
Definition at line 45 of file audio_decoder.h.
◆ AudioDecoder()
esphome::audio::AudioDecoder::AudioDecoder |
( |
size_t |
input_buffer_size, |
|
|
size_t |
output_buffer_size |
|
) |
| |
Allocates the input and output transfer buffers.
- 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 15 of file audio_decoder.cpp.
◆ ~AudioDecoder()
esphome::audio::AudioDecoder::~AudioDecoder |
( |
| ) |
|
Deallocates the MP3 decoder (the flac and wav decoders are deallocated automatically)
Definition at line 20 of file audio_decoder.cpp.
◆ add_sink() [1/2]
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 36 of file audio_decoder.cpp.
◆ add_sink() [2/2]
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 45 of file audio_decoder.cpp.
◆ add_source()
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 28 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 92 of file audio_decoder.cpp.
◆ decode_flac_()
◆ decode_mp3_()
◆ 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 92 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 96 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 100 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 54 of file audio_decoder.cpp.
◆ accumulated_frames_written_
uint32_t esphome::audio::AudioDecoder::accumulated_frames_written_ {0} |
|
protected |
◆ audio_file_type_
◆ audio_stream_info_
◆ 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_transfer_buffer_
◆ mp3_decoder_
esp_audio_libs::helix_decoder::HMP3Decoder esphome::audio::AudioDecoder::mp3_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: