1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-22 18:48:14 +00:00

[speaker, resampler, mixer] Make volume and mute getters virtual (#8391)

This commit is contained in:
Kevin Ahrendt 2025-03-12 14:34:38 -05:00 committed by Keith Burzinski
parent a2b123a29a
commit bf65b73569
No known key found for this signature in database
GPG Key ID: 802564C5F0EEFFBE
4 changed files with 10 additions and 2 deletions

View File

@ -177,11 +177,15 @@ void SourceSpeaker::set_mute_state(bool mute_state) {
this->parent_->get_output_speaker()->set_mute_state(mute_state);
}
bool SourceSpeaker::get_mute_state() { return this->parent_->get_output_speaker()->get_mute_state(); }
void SourceSpeaker::set_volume(float volume) {
this->volume_ = volume;
this->parent_->get_output_speaker()->set_volume(volume);
}
float SourceSpeaker::get_volume() { return this->parent_->get_output_speaker()->get_volume(); }
size_t SourceSpeaker::process_data_from_source(TickType_t ticks_to_wait) {
if (!this->transfer_buffer_.use_count()) {
return 0;

View File

@ -53,9 +53,11 @@ class SourceSpeaker : public speaker::Speaker, public Component {
/// @brief Mute state changes are passed to the parent's output speaker
void set_mute_state(bool mute_state) override;
bool get_mute_state() override;
/// @brief Volume state changes are passed to the parent's output speaker
void set_volume(float volume) override;
float get_volume() override;
void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; }
bool get_pause_state() const override { return this->pause_state_; }

View File

@ -34,9 +34,11 @@ class ResamplerSpeaker : public Component, public speaker::Speaker {
/// @brief Mute state changes are passed to the parent's output speaker
void set_mute_state(bool mute_state) override;
bool get_mute_state() override { return this->output_speaker_->get_mute_state(); }
/// @brief Volume state changes are passed to the parent's output speaker
void set_volume(float volume) override;
float get_volume() override { return this->output_speaker_->get_volume(); }
void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; }
void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }

View File

@ -76,7 +76,7 @@ class Speaker {
}
#endif
};
float get_volume() { return this->volume_; }
virtual float get_volume() { return this->volume_; }
virtual void set_mute_state(bool mute_state) {
this->mute_state_ = mute_state;
@ -90,7 +90,7 @@ class Speaker {
}
#endif
}
bool get_mute_state() { return this->mute_state_; }
virtual bool get_mute_state() { return this->mute_state_; }
#ifdef USE_AUDIO_DAC
void set_audio_dac(audio_dac::AudioDac *audio_dac) { this->audio_dac_ = audio_dac; }