From e5c04b5c447b9a7822e5382f42d3eb6d45d996ca Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Thu, 1 Aug 2024 04:23:14 +0200 Subject: [PATCH] Compile errors in IDF --- CMakeLists.txt | 4 ++-- src/AudioAnalog/AnalogDriverESP32V1.h | 8 ++++---- src/AudioI2S/I2SESP32V1.h | 4 ++-- src/AudioTools/AudioStreams.h | 2 +- src/AudioTools/BaseConverter.h | 10 ++++++++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce7fcb143..8f9e72aab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,12 @@ if (DEFINED ESP_PLATFORM) # idf component idf_component_register( - SRC_DIRS src + # SRC_DIRS src INCLUDE_DIRS src REQUIRES bt esp_common freertos hal log nvs_flash driver ) - target_compile_options(${COMPONENT_LIB} PUBLIC -DESP32_CMAKE=1 -Wno-error -Wno-format -fpermissive) + target_compile_options(${COMPONENT_LIB} INTERFACE -DESP32_CMAKE=1 -Wno-error -Wno-format -fpermissive) else() diff --git a/src/AudioAnalog/AnalogDriverESP32V1.h b/src/AudioAnalog/AnalogDriverESP32V1.h index 2ad662643..5c143d669 100644 --- a/src/AudioAnalog/AnalogDriverESP32V1.h +++ b/src/AudioAnalog/AnalogDriverESP32V1.h @@ -276,7 +276,7 @@ protected: // LOGI("adc_continuous_read request:%d samples %d bytes requested", samples_requested, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t))); if (adc_continuous_read(self->adc_handle, (uint8_t *)result_data, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t)), &bytes_read, (uint32_t)self->cfg.timeout) == ESP_OK) { samples_read = bytes_read / sizeof(adc_digi_output_data_t); - LOGD("adc_continuous_read -> %u bytes / %d samples of %d bytes requested", (unsigned)bytes_read, samples_read, (uint32_t)(samples_requested * sizeof(adc_digi_output_data_t))); + LOGD("adc_continuous_read -> %u bytes / %d samples of %d bytes requested", (unsigned)bytes_read, samples_read, (int)(samples_requested * sizeof(adc_digi_output_data_t))); // Parse and store data in FIFO buffers for (int i = 0; i < samples_read; i++) { @@ -297,10 +297,10 @@ protected: if (self->fifo_buffers[idx]->push(data)) { LOGD("Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data); } else { - LOGE("Sample %d, FIFO buffer is full, ch %u, d %u", i, idx, chan_num, data); + LOGE("Sample %d, FIFO buffer is full, ch %u, d %u", i, (unsigned)chan_num, data); } } else { - LOGE("Sample %d, ch %u not found in configuration, d: %u", i, chan_num, data); + LOGE("Sample %d, ch %u not found in configuration, d: %u", i, (unsigned)chan_num, data); for (int k = 0; k < self->cfg.channels; ++k) { LOGE("Available config ch: %u", self->cfg.adc_channels[k]); } @@ -349,7 +349,7 @@ protected: if (self->fifo_buffers[idx]->push(data)) { LOGD("Top Off Sample %d, FIFO %d, ch %u, d %u", i, idx, chan_num, data); } else { - LOGE("Top Off Sample %d, FIFO buffer is full, ch %u, d %u", i, idx, chan_num, data); + LOGE("Top Off Sample %d, FIFO buffer is full, ch %u, d %u", i, chan_num, data); } } else { LOGE("Top Off Sample %d, ch %u not found in configuration, d %u", i, chan_num, data); diff --git a/src/AudioI2S/I2SESP32V1.h b/src/AudioI2S/I2SESP32V1.h index 86bd9d3f9..68b00444b 100644 --- a/src/AudioI2S/I2SESP32V1.h +++ b/src/AudioI2S/I2SESP32V1.h @@ -178,8 +178,8 @@ class I2SDriverESP32V1 { case I2SChannelSelect::Right: result.slot_mask = I2S_STD_SLOT_RIGHT; break; - case I2SChannelSelect::Stereo: - LOGW("Invalid channel_format: %d", cfg.channel_format); + default: + LOGW("Invalid channel_format: %d", (int)cfg.channel_format); break; } } diff --git a/src/AudioTools/AudioStreams.h b/src/AudioTools/AudioStreams.h index a48e47402..cf14220f8 100644 --- a/src/AudioTools/AudioStreams.h +++ b/src/AudioTools/AudioStreams.h @@ -1649,7 +1649,7 @@ public: if (p_out!=nullptr){ result = p_out->write(data, len); } - return len; + return result; } size_t readBytes(uint8_t *data, size_t len){ diff --git a/src/AudioTools/BaseConverter.h b/src/AudioTools/BaseConverter.h index 58b3cd88c..e5e718e52 100644 --- a/src/AudioTools/BaseConverter.h +++ b/src/AudioTools/BaseConverter.h @@ -859,7 +859,10 @@ class ChannelDiffT : public BaseConverter { T *p_source = (T *)src; for (int i = 0; i < sample_count; i++) { - *p_result++ = *p_source++ - *p_source++; + // *p_result++ = *p_source++ - *p_source++; + auto tmp = *p_source++; + tmp -= *p_source++; + *p_result++ = tmp; } return sizeof(T) * sample_count; @@ -936,7 +939,10 @@ class ChannelAvgT : public BaseConverter { T *p_source = (T *)src; for (int i = 0; i < sample_count; i++) { - *p_result++ = (*p_source++ + *p_source++) / 2; // Average the pair of channels + // *p_result++ = (*p_source++ + *p_source++) / 2; // Average the pair of channels + auto tmp = *p_source++; + tmp += *p_source++; + *p_result++ = tmp / 2; } LOGD("channel average %d samples, %d bytes", sample_count, size);