forked from xiaozhi/xiaozhi-esp32
fix: codec unexpectedly closed by timer after open (#1046)
Co-authored-by: Xiaoxia <terrence.huang@tenclass.com>
This commit is contained in:
@@ -152,8 +152,9 @@ void AudioService::Stop() {
|
|||||||
|
|
||||||
bool AudioService::ReadAudioData(std::vector<int16_t>& data, int sample_rate, int samples) {
|
bool AudioService::ReadAudioData(std::vector<int16_t>& data, int sample_rate, int samples) {
|
||||||
if (!codec_->input_enabled()) {
|
if (!codec_->input_enabled()) {
|
||||||
codec_->EnableInput(true);
|
esp_timer_stop(audio_power_timer_);
|
||||||
esp_timer_start_periodic(audio_power_timer_, AUDIO_POWER_CHECK_INTERVAL_MS * 1000);
|
esp_timer_start_periodic(audio_power_timer_, AUDIO_POWER_CHECK_INTERVAL_MS * 1000);
|
||||||
|
codec_->EnableInput(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codec_->input_sample_rate() != sample_rate) {
|
if (codec_->input_sample_rate() != sample_rate) {
|
||||||
@@ -287,8 +288,9 @@ void AudioService::AudioOutputTask() {
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
if (!codec_->output_enabled()) {
|
if (!codec_->output_enabled()) {
|
||||||
codec_->EnableOutput(true);
|
esp_timer_stop(audio_power_timer_);
|
||||||
esp_timer_start_periodic(audio_power_timer_, AUDIO_POWER_CHECK_INTERVAL_MS * 1000);
|
esp_timer_start_periodic(audio_power_timer_, AUDIO_POWER_CHECK_INTERVAL_MS * 1000);
|
||||||
|
codec_->EnableOutput(true);
|
||||||
}
|
}
|
||||||
codec_->OutputData(task->pcm);
|
codec_->OutputData(task->pcm);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user