1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-06 20:03:46 +01:00

[i2s_audio] Move microphone reads into a task (#8651)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Kevin Ahrendt
2025-04-30 04:50:56 -05:00
committed by GitHub
parent 07ba9fdf8f
commit 20062576a3
8 changed files with 185 additions and 55 deletions

View File

@@ -7,6 +7,9 @@
#include "esphome/components/microphone/microphone.h"
#include "esphome/core/component.h"
#include <freertos/event_groups.h>
#include <freertos/semphr.h>
namespace esphome {
namespace i2s_audio {
@@ -35,11 +38,18 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
#endif
protected:
void start_();
void stop_();
void read_();
bool start_driver_();
void stop_driver_();
size_t read_(uint8_t *buf, size_t len, TickType_t ticks_to_wait);
static void mic_task(void *params);
SemaphoreHandle_t active_listeners_semaphore_{nullptr};
EventGroupHandle_t event_group_{nullptr};
TaskHandle_t task_handle_{nullptr};
#ifdef USE_I2S_LEGACY
int8_t din_pin_{I2S_PIN_NO_CHANGE};
#if SOC_I2S_SUPPORTS_ADC
@@ -51,8 +61,6 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
i2s_chan_handle_t rx_handle_;
#endif
bool pdm_{false};
HighFrequencyLoopRequester high_freq_;
};
} // namespace i2s_audio