mirror of
https://github.com/esphome/esphome.git
synced 2025-03-23 19:18:17 +00:00
[speaker, resampler, mixer] Make volume and mute getters virtual (#8391)
This commit is contained in:
parent
a2b123a29a
commit
bf65b73569
@ -177,11 +177,15 @@ void SourceSpeaker::set_mute_state(bool mute_state) {
|
|||||||
this->parent_->get_output_speaker()->set_mute_state(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) {
|
void SourceSpeaker::set_volume(float volume) {
|
||||||
this->volume_ = volume;
|
this->volume_ = volume;
|
||||||
this->parent_->get_output_speaker()->set_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) {
|
size_t SourceSpeaker::process_data_from_source(TickType_t ticks_to_wait) {
|
||||||
if (!this->transfer_buffer_.use_count()) {
|
if (!this->transfer_buffer_.use_count()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -53,9 +53,11 @@ class SourceSpeaker : public speaker::Speaker, public Component {
|
|||||||
|
|
||||||
/// @brief Mute state changes are passed to the parent's output speaker
|
/// @brief Mute state changes are passed to the parent's output speaker
|
||||||
void set_mute_state(bool mute_state) override;
|
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
|
/// @brief Volume state changes are passed to the parent's output speaker
|
||||||
void set_volume(float volume) override;
|
void set_volume(float volume) override;
|
||||||
|
float get_volume() override;
|
||||||
|
|
||||||
void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; }
|
void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; }
|
||||||
bool get_pause_state() const override { return this->pause_state_; }
|
bool get_pause_state() const override { return this->pause_state_; }
|
||||||
|
@ -34,9 +34,11 @@ class ResamplerSpeaker : public Component, public speaker::Speaker {
|
|||||||
|
|
||||||
/// @brief Mute state changes are passed to the parent's output speaker
|
/// @brief Mute state changes are passed to the parent's output speaker
|
||||||
void set_mute_state(bool mute_state) override;
|
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
|
/// @brief Volume state changes are passed to the parent's output speaker
|
||||||
void set_volume(float volume) override;
|
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_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; }
|
void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }
|
||||||
|
@ -76,7 +76,7 @@ class Speaker {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
float get_volume() { return this->volume_; }
|
virtual float get_volume() { return this->volume_; }
|
||||||
|
|
||||||
virtual void set_mute_state(bool mute_state) {
|
virtual void set_mute_state(bool mute_state) {
|
||||||
this->mute_state_ = mute_state;
|
this->mute_state_ = mute_state;
|
||||||
@ -90,7 +90,7 @@ class Speaker {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
bool get_mute_state() { return this->mute_state_; }
|
virtual bool get_mute_state() { return this->mute_state_; }
|
||||||
|
|
||||||
#ifdef USE_AUDIO_DAC
|
#ifdef USE_AUDIO_DAC
|
||||||
void set_audio_dac(audio_dac::AudioDac *audio_dac) { this->audio_dac_ = audio_dac; }
|
void set_audio_dac(audio_dac::AudioDac *audio_dac) { this->audio_dac_ = audio_dac; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user