Skip to content

Commit d561bd8

Browse files
committed
Support for IDF logger via USE_IDF_LOGGER
1 parent e6ffae7 commit d561bd8

File tree

11 files changed

+366
-318
lines changed

11 files changed

+366
-318
lines changed

src/AudioConfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ typedef WiFiClient WiFiClientSecure;
5959
#include "AudioTools/CoreAudio/AudioRuntime.h"
6060

6161

62-
6362
// If you don't want to use all the settings from here you can define your own local config settings in AudioConfigLocal.h
6463
#if __has_include("AudioConfigLocal.h")
6564
#include "AudioConfigLocal.h"
@@ -270,6 +269,9 @@ typedef WiFiClient WiFiClientSecure;
270269
# endif
271270
# define USE_SD_SUPPORTS_SPI
272271
//# define USE_ESP32_LOGGER true
272+
# if !defined(ARDUINO)
273+
# define USE_IDF_LOGGER
274+
# endif
273275
#endif
274276

275277
// ----- Regular ESP32 -----

src/AudioLogger.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#pragma once
2-
// added so that we can include the AudioLogger from Arduino w/o calling include "AudioTools.h" first.
3-
#include "AudioTools/CoreAudio/AudioLogger.h"
2+
#include "AudioTools/CoreAudio/AudioLogger.h"

src/AudioTools/AudioCodecs/AudioEncoded.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class EncodedAudioOutput : public ModifyingOutput {
135135

136136
/// Starts the processing - sets the status to active
137137
bool begin() override {
138-
#if USE_AUDIO_LOGGING
138+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
139139
custom_log_level.set();
140140
#endif
141141
TRACED();
@@ -150,7 +150,7 @@ class EncodedAudioOutput : public ModifyingOutput {
150150
LOGW("no decoder or encoder defined");
151151
}
152152
}
153-
#if USE_AUDIO_LOGGING
153+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
154154
custom_log_level.reset();
155155
#endif
156156
return active;
@@ -164,14 +164,14 @@ class EncodedAudioOutput : public ModifyingOutput {
164164

165165
/// Ends the processing
166166
void end() override {
167-
#if USE_AUDIO_LOGGING
167+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
168168
custom_log_level.set();
169169
#endif
170170
TRACEI();
171171
decoder_ptr->end();
172172
encoder_ptr->end();
173173
active = false;
174-
#if USE_AUDIO_LOGGING
174+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
175175
custom_log_level.reset();
176176
#endif
177177
}
@@ -182,7 +182,7 @@ class EncodedAudioOutput : public ModifyingOutput {
182182
//LOGI("write: %d", 0);
183183
return 0;
184184
}
185-
#if USE_AUDIO_LOGGING
185+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
186186
custom_log_level.set();
187187
#endif
188188
LOGD("EncodedAudioOutput::write: %d", (int)len);
@@ -198,7 +198,7 @@ class EncodedAudioOutput : public ModifyingOutput {
198198

199199
size_t result = writer_ptr->write(data, len);
200200
LOGD("EncodedAudioOutput::write: %d -> %d", (int)len, (int)result);
201-
#if USE_AUDIO_LOGGING
201+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
202202
custom_log_level.reset();
203203
#endif
204204
return result;
@@ -218,7 +218,7 @@ class EncodedAudioOutput : public ModifyingOutput {
218218
/// Provides the initialized encoder
219219
AudioEncoder &encoder() { return *encoder_ptr; }
220220

221-
#if USE_AUDIO_LOGGING
221+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
222222
/// Defines the class specific custom log level
223223
void setLogLevel(AudioLogger::LogLevel level) { custom_log_level.set(level); }
224224
#endif
@@ -236,7 +236,7 @@ class EncodedAudioOutput : public ModifyingOutput {
236236
Print *ptr_out = nullptr;
237237
bool active = false;
238238
bool check_available_for_write = false;
239-
#if USE_AUDIO_LOGGING
239+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
240240
CustomLogLevel custom_log_level;
241241
#endif
242242
int frame_size = DEFAULT_BUFFER_SIZE;
@@ -376,7 +376,7 @@ class EncodedAudioStream : public ReformatBaseStream {
376376
float getByteFactor() { return byte_factor; }
377377
void setByteFactor(float factor) {byte_factor = factor;}
378378

379-
#if USE_AUDIO_LOGGING
379+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
380380
/// Defines the class specific custom log level
381381
void setLogLevel(AudioLogger::LogLevel level) { enc_out.setLogLevel(level); }
382382
#endif

src/AudioTools/CoreAudio/AudioHttp/HttpHeader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ class HttpHeader {
100100
LOGD("HttpHeader::put %s %s", key, value);
101101
HttpHeaderLine* hl = headerLine(key);
102102
if (hl == nullptr) {
103-
if (create_new_lines)
103+
if (create_new_lines){
104104
LOGE("HttpHeader::put - did not add HttpHeaderLine for %s", key);
105+
}
105106
return *this;
106107
}
107108

src/AudioTools/CoreAudio/AudioHttp/URLStream.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class URLStream : public AbstractURLStream {
103103
total_read = 0;
104104
active = result == 200;
105105
LOGI("==> http status: %d", result);
106-
#if USE_AUDIO_LOGGING
106+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
107107
custom_log_level.reset();
108108
#endif
109109
return active;
@@ -129,7 +129,7 @@ class URLStream : public AbstractURLStream {
129129
total_read = 0;
130130
active = result == 200;
131131
LOGI("==> http status: %d", result);
132-
#if USE_AUDIO_LOGGING
132+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
133133
custom_log_level.reset();
134134
#endif
135135
return active;
@@ -260,7 +260,7 @@ class URLStream : public AbstractURLStream {
260260
return request.available() > 0;
261261
}
262262

263-
#if USE_AUDIO_LOGGING
263+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
264264
/// Defines the class specific custom log level
265265
void setLogLevel(AudioLogger::LogLevel level) { custom_log_level.set(level); }
266266
#endif
@@ -275,7 +275,7 @@ class URLStream : public AbstractURLStream {
275275

276276
protected:
277277
HttpRequest request;
278-
#if USE_AUDIO_LOGGING
278+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
279279
CustomLogLevel custom_log_level;
280280
#endif
281281
Str url_str;
@@ -305,7 +305,7 @@ class URLStream : public AbstractURLStream {
305305

306306
bool preProcess(const char* urlStr, const char* acceptMime) {
307307
TRACED();
308-
#if USE_AUDIO_LOGGING
308+
#if USE_AUDIO_LOGGING && !defined(USE_IDF_LOGGER)
309309
custom_log_level.set();
310310
#endif
311311
url_str = urlStr;

src/AudioTools/CoreAudio/AudioI2S/I2SConfigESP32V1.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,22 @@ class I2SConfigESP32V1 : public AudioInfo {
9494
// LOGI("buffer_count:%d",buffer_count);
9595
// LOGI("buffer_size:%d",buffer_size);
9696

97-
if (pin_mck!=-1)
97+
if (pin_mck!=-1){
9898
LOGI("pin_mck: %d", pin_mck);
99-
if (pin_bck!=-1)
99+
}
100+
if (pin_bck!=-1){
100101
LOGI("pin_bck: %d", pin_bck);
101-
if (pin_ws!=-1)
102+
}
103+
if (pin_ws!=-1){
102104
LOGI("pin_ws: %d", pin_ws);
103-
if (pin_data!=-1)
105+
}
106+
if (pin_data!=-1){
104107
LOGI("pin_data: %d", pin_data);
108+
}
105109
if (pin_data_rx!=-1){
106110
LOGI("pin_data_rx: %d", pin_data_rx);
107111
}
108112
}
109-
110113
};
111114

112115
using I2SConfig = I2SConfigESP32V1;

src/AudioTools/CoreAudio/AudioIO.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ class TransformationReader {
8787
int read_eff = p_stream->readBytes(buffer.data(), buffer.size());
8888
if (read_eff > 0) {
8989
zero_count = 0; // reset 0 count
90-
if (read_eff != buffer.size())
90+
if (read_eff != buffer.size()){
9191
LOGD("readBytes %d -> %d", buffer.size(), read_eff);
92+
}
9293
int write_eff = p_transform->write(buffer.data(), read_eff);
93-
if (write_eff != read_eff)
94+
if (write_eff != read_eff){
9495
LOGE("write %d -> %d", read_eff, write_eff);
96+
}
9597
} else {
9698
// limit the number of reads which provide 0;
9799
if (++zero_count > MAX_ZERO_READ_COUNT){

0 commit comments

Comments
 (0)