ESPHome
2025.2.0
|
#include <mixer_speaker.h>
Public Member Functions | |
void | dump_config () override |
void | setup () override |
void | loop () override |
void | add_source_speaker (SourceSpeaker *source_speaker) |
esp_err_t | start (audio::AudioStreamInfo &stream_info) |
Starts the mixer task. More... | |
void | stop () |
void | set_output_channels (uint8_t output_channels) |
void | set_output_speaker (speaker::Speaker *speaker) |
void | set_queue_mode (bool queue_mode) |
void | set_task_stack_in_psram (bool task_stack_in_psram) |
speaker::Speaker * | get_output_speaker () const |
![]() | |
virtual float | get_setup_priority () const |
priority of setup(). More... | |
float | get_actual_setup_priority () const |
void | set_setup_priority (float priority) |
virtual float | get_loop_priority () const |
priority of loop(). More... | |
void | call () |
virtual void | on_shutdown () |
virtual void | on_safe_shutdown () |
uint32_t | get_component_state () const |
virtual void | mark_failed () |
Mark this component as failed. More... | |
bool | is_failed () const |
bool | is_ready () const |
virtual bool | can_proceed () |
bool | status_has_warning () const |
bool | status_has_error () const |
void | status_set_warning (const char *message="unspecified") |
void | status_set_error (const char *message="unspecified") |
void | status_clear_warning () |
void | status_clear_error () |
void | status_momentary_warning (const std::string &name, uint32_t length=5000) |
void | status_momentary_error (const std::string &name, uint32_t length=5000) |
bool | has_overridden_loop () const |
void | set_component_source (const char *source) |
Set where this component was loaded from for some debug messages. More... | |
const char * | get_component_source () const |
Get the integration where this component was declared as a string. More... | |
Protected Member Functions | |
esp_err_t | start_task_ () |
Starts the mixer task after allocating memory for the task stack. More... | |
esp_err_t | delete_task_ () |
If the task is stopped, it sets the task handle to the nullptr and deallocates its stack. More... | |
![]() | |
virtual void | call_loop () |
virtual void | call_setup () |
virtual void | call_dump_config () |
void | set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f) |
Set an interval function with a unique name. More... | |
void | set_interval (uint32_t interval, std::function< void()> &&f) |
bool | cancel_interval (const std::string &name) |
Cancel an interval function. More... | |
void | set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
Set an retry function with a unique name. More... | |
void | set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
bool | cancel_retry (const std::string &name) |
Cancel a retry function. More... | |
void | set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f) |
Set a timeout function with a unique name. More... | |
void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
bool | cancel_timeout (const std::string &name) |
Cancel a timeout function. More... | |
void | defer (const std::string &name, std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
void | defer (std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
bool | cancel_defer (const std::string &name) |
Cancel a defer callback using the specified name, name must not be empty. More... | |
Static Protected Member Functions | |
static void | copy_frames (const int16_t *input_buffer, audio::AudioStreamInfo input_stream_info, int16_t *output_buffer, audio::AudioStreamInfo output_stream_info, uint32_t frames_to_transfer) |
Copies audio frames from the input buffer to the output buffer taking into account the number of channels in each stream. More... | |
static void | mix_audio_samples (const int16_t *primary_buffer, audio::AudioStreamInfo primary_stream_info, const int16_t *secondary_buffer, audio::AudioStreamInfo secondary_stream_info, int16_t *output_buffer, audio::AudioStreamInfo output_stream_info, uint32_t frames_to_mix) |
Mixes the primary and secondary streams taking into account the number of channels in each stream. More... | |
static void | audio_mixer_task (void *params) |
Protected Attributes | |
EventGroupHandle_t | event_group_ {nullptr} |
std::vector< SourceSpeaker * > | source_speakers_ |
speaker::Speaker * | output_speaker_ {nullptr} |
uint8_t | output_channels_ |
bool | queue_mode_ |
bool | task_stack_in_psram_ {false} |
bool | task_created_ {false} |
TaskHandle_t | task_handle_ {nullptr} |
StaticTask_t | task_stack_ |
StackType_t * | task_stack_buffer_ {nullptr} |
optional< audio::AudioStreamInfo > | audio_stream_info_ |
![]() | |
uint32_t | component_state_ {0x0000} |
State of this component. More... | |
float | setup_priority_override_ {NAN} |
const char * | component_source_ {nullptr} |
Definition at line 120 of file mixer_speaker.h.
|
inline |
Definition at line 126 of file mixer_speaker.h.
|
staticprotected |
Definition at line 463 of file mixer_speaker.cpp.
|
staticprotected |
Copies audio frames from the input buffer to the output buffer taking into account the number of channels in each stream.
If the output stream has more channels, the input samples are duplicated. If the output stream has less channels, the extra channel input samples are dropped.
input_buffer | |
input_stream_info | |
output_buffer | |
output_stream_info | |
frames_to_transfer | number of frames (consisting of a sample for each channel) to copy from the input buffer |
Definition at line 412 of file mixer_speaker.cpp.
|
protected |
If the task is stopped, it sets the task handle to the nullptr and deallocates its stack.
Definition at line 388 of file mixer_speaker.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 287 of file mixer_speaker.cpp.
|
inline |
Definition at line 144 of file mixer_speaker.h.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 302 of file mixer_speaker.cpp.
|
staticprotected |
Mixes the primary and secondary streams taking into account the number of channels in each stream.
Primary and secondary samples are duplicated or dropped as necessary to ensure the output stream has the configured number of channels. Output samples are clamped to the corresponding int16 min or max values if the mixed sample overflows.
primary_buffer | (int16_t *) samples buffer for the primary stream |
primary_stream_info | stream info for the primary stream |
secondary_buffer | (int16_t *) samples buffer for secondary stream |
secondary_stream_info | stream info for the secondary stream |
output_buffer | (int16_t *) buffer for the mixed samples |
output_stream_info | stream info for the output buffer |
frames_to_mix | number of frames in the primary and secondary buffers to mix together |
Definition at line 435 of file mixer_speaker.cpp.
|
inline |
Definition at line 139 of file mixer_speaker.h.
|
inline |
Definition at line 140 of file mixer_speaker.h.
|
inline |
Definition at line 141 of file mixer_speaker.h.
|
inline |
Definition at line 142 of file mixer_speaker.h.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 292 of file mixer_speaker.cpp.
esp_err_t esphome::mixer_speaker::MixerSpeaker::start | ( | audio::AudioStreamInfo & | stream_info | ) |
Starts the mixer task.
Called by a source speaker giving the current audio stream information
stream_info | The calling source speakers audio stream information |
Definition at line 341 of file mixer_speaker.cpp.
|
protected |
Starts the mixer task after allocating memory for the task stack.
Definition at line 361 of file mixer_speaker.cpp.
void esphome::mixer_speaker::MixerSpeaker::stop | ( | ) |
Definition at line 410 of file mixer_speaker.cpp.
|
protected |
Definition at line 201 of file mixer_speaker.h.
|
protected |
Definition at line 186 of file mixer_speaker.h.
|
protected |
Definition at line 191 of file mixer_speaker.h.
|
protected |
Definition at line 189 of file mixer_speaker.h.
|
protected |
Definition at line 192 of file mixer_speaker.h.
|
protected |
Definition at line 188 of file mixer_speaker.h.
|
protected |
Definition at line 195 of file mixer_speaker.h.
|
protected |
Definition at line 197 of file mixer_speaker.h.
|
protected |
Definition at line 198 of file mixer_speaker.h.
|
protected |
Definition at line 199 of file mixer_speaker.h.
|
protected |
Definition at line 193 of file mixer_speaker.h.