Skip to content

Commit b03ccb5

Browse files
committed
Logger: Memory Optimization for AVR
1 parent b0f8c63 commit b03ccb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+541
-515
lines changed

src/AudioAnalog/AnalogAudioESP32.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class AnalogAudioStream : public AudioStreamX {
173173

174174
/// updates the sample rate dynamically
175175
virtual void setAudioInfo(AudioBaseInfo info) {
176-
LOGI(LOG_METHOD);
176+
TRACEI();
177177
if (adc_config.sample_rate != info.sample_rate
178178
|| adc_config.channels != info.channels
179179
|| adc_config.bits_per_sample != info.bits_per_sample) {
@@ -193,7 +193,7 @@ class AnalogAudioStream : public AudioStreamX {
193193

194194
/// starts the DAC
195195
bool begin(AnalogConfig cfg) {
196-
LOGI(LOG_METHOD);
196+
TRACEI();
197197
cfg.logInfo();
198198

199199
if (!is_driver_installed){
@@ -318,7 +318,7 @@ class AnalogAudioStream : public AudioStreamX {
318318

319319
/// writes the data to the I2S interface
320320
virtual size_t write(const uint8_t *src, size_t size_bytes) override {
321-
LOGD(LOG_METHOD);
321+
TRACED();
322322

323323
size_t result = 0;
324324
if (size_bytes>0 && src!=nullptr){
@@ -339,10 +339,10 @@ class AnalogAudioStream : public AudioStreamX {
339339
}
340340

341341
size_t readBytes(uint8_t *dest, size_t size_bytes) override {
342-
LOGD(LOG_METHOD);
342+
TRACED();
343343
size_t result = 0;
344344
if (i2s_read(port_no, dest, size_bytes, &result, portMAX_DELAY)!=ESP_OK){
345-
LOGE(LOG_METHOD);
345+
TRACEE();
346346
}
347347
LOGD( "%s - len: %d -> %d", __func__, size_bytes, result);
348348
return result;
@@ -371,7 +371,7 @@ class AnalogAudioStream : public AudioStreamX {
371371

372372
// The internal DAC only supports 8 bit values - so we need to convert the data
373373
size_t outputStereo(const void *src, size_t size_bytes) {
374-
LOGD(LOG_METHOD);
374+
TRACED();
375375
size_t output_size = 0;
376376
size_t result;
377377
uint16_t *dst = (uint16_t *)src;
@@ -412,7 +412,7 @@ class AnalogAudioStream : public AudioStreamX {
412412

413413
// I2S requires stereo so we convert mono to stereo
414414
size_t outputMono(const void *src, size_t size_bytes) {
415-
LOGD(LOG_METHOD);
415+
TRACED();
416416
size_t output_size = 0;
417417
uint16_t out[2];
418418
size_t resultTotal = 0;

src/AudioCodecs/AudioEncoded.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class EncodedAudioStream : public AudioPrint {
143143
public:
144144
/// Constructor for AudioStream with automatic notification of audio changes
145145
EncodedAudioStream(AudioStream *outputStream, AudioDecoder *decoder) {
146-
LOGD(LOG_METHOD);
146+
TRACED();
147147
ptr_out = outputStream;
148148
decoder_ptr = decoder;
149149
decoder_ptr->setOutputStream(*outputStream);
@@ -154,7 +154,7 @@ class EncodedAudioStream : public AudioPrint {
154154

155155
/// Constructor for AudioPrint with automatic notification of audio changes
156156
EncodedAudioStream(AudioPrint *outputStream, AudioDecoder *decoder) {
157-
LOGD(LOG_METHOD);
157+
TRACED();
158158
ptr_out = outputStream;
159159
decoder_ptr = decoder;
160160
decoder_ptr->setOutputStream(*outputStream);
@@ -171,7 +171,7 @@ class EncodedAudioStream : public AudioPrint {
171171
* @param decoder
172172
*/
173173
EncodedAudioStream(Print &outputStream, AudioDecoder &decoder) {
174-
LOGD(LOG_METHOD);
174+
TRACED();
175175
ptr_out = &outputStream;
176176
decoder_ptr = &decoder;
177177
decoder_ptr->setOutputStream(outputStream);
@@ -186,7 +186,7 @@ class EncodedAudioStream : public AudioPrint {
186186
* @param decoder
187187
*/
188188
EncodedAudioStream(Print *outputStream, AudioDecoder *decoder) {
189-
LOGD(LOG_METHOD);
189+
TRACED();
190190
ptr_out = outputStream;
191191
decoder_ptr = decoder;
192192
decoder_ptr->setOutputStream(*outputStream);
@@ -201,7 +201,7 @@ class EncodedAudioStream : public AudioPrint {
201201
* @param encoder
202202
*/
203203
EncodedAudioStream(Print &outputStream, AudioEncoder &encoder) {
204-
LOGD(LOG_METHOD);
204+
TRACED();
205205
ptr_out = &outputStream;
206206
encoder_ptr = &encoder;
207207
encoder_ptr->setOutputStream(outputStream);
@@ -216,7 +216,7 @@ class EncodedAudioStream : public AudioPrint {
216216
* @param encoder
217217
*/
218218
EncodedAudioStream(Print *outputStream, AudioEncoder *encoder) {
219-
LOGD(LOG_METHOD);
219+
TRACED();
220220
ptr_out = outputStream;
221221
encoder_ptr = encoder;
222222
encoder_ptr->setOutputStream(*outputStream);
@@ -231,7 +231,7 @@ class EncodedAudioStream : public AudioPrint {
231231
*
232232
*/
233233
EncodedAudioStream() {
234-
LOGD(LOG_METHOD);
234+
TRACED();
235235
active = false;
236236
}
237237

@@ -247,7 +247,7 @@ class EncodedAudioStream : public AudioPrint {
247247

248248
/// Define object which need to be notified if the basinfo is changing
249249
void setNotifyAudioChange(AudioBaseInfoDependent &bi) override {
250-
LOGI(LOG_METHOD);
250+
TRACEI();
251251
decoder_ptr->setNotifyAudioChange(bi);
252252
}
253253

@@ -260,15 +260,15 @@ class EncodedAudioStream : public AudioPrint {
260260
}
261261

262262
virtual void setAudioInfo(AudioBaseInfo info) override {
263-
LOGD(LOG_METHOD);
263+
TRACED();
264264
AudioPrint::setAudioInfo(info);
265265
decoder_ptr->setAudioInfo(info);
266266
encoder_ptr->setAudioInfo(info);
267267
}
268268

269269
/// Starts the processing - sets the status to active
270270
void begin(Print *outputStream, AudioEncoder *encoder) {
271-
LOGD(LOG_METHOD);
271+
TRACED();
272272
ptr_out = outputStream;
273273
encoder_ptr = encoder;
274274
encoder_ptr->setOutputStream(*outputStream);
@@ -278,7 +278,7 @@ class EncodedAudioStream : public AudioPrint {
278278

279279
/// Starts the processing - sets the status to active
280280
void begin(Print *outputStream, AudioDecoder *decoder) {
281-
LOGD(LOG_METHOD);
281+
TRACED();
282282
ptr_out = outputStream;
283283
decoder_ptr = decoder;
284284
decoder_ptr->setOutputStream(*outputStream);
@@ -288,7 +288,7 @@ class EncodedAudioStream : public AudioPrint {
288288

289289
/// Starts the processing - sets the status to active
290290
void begin() {
291-
LOGD(LOG_METHOD);
291+
TRACED();
292292
const CodecNOP *nop = CodecNOP::instance();
293293
if (decoder_ptr != nop || encoder_ptr != nop) {
294294
decoder_ptr->begin();
@@ -301,7 +301,7 @@ class EncodedAudioStream : public AudioPrint {
301301

302302
/// Starts the processing - sets the status to active
303303
void begin(AudioBaseInfo info) {
304-
LOGD(LOG_METHOD);
304+
TRACED();
305305
const CodecNOP *nop = CodecNOP::instance();
306306
if (decoder_ptr != nop || encoder_ptr != nop) {
307307
// some decoders need this - e.g. opus
@@ -316,7 +316,7 @@ class EncodedAudioStream : public AudioPrint {
316316
}
317317
/// Ends the processing
318318
void end() {
319-
LOGI(LOG_METHOD);
319+
TRACEI();
320320
decoder_ptr->end();
321321
encoder_ptr->end();
322322
active = false;

src/AudioCodecs/Codec8Bit.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Decoder8Bit : public AudioDecoder {
1818
*/
1919

2020
Decoder8Bit(){
21-
LOGD(LOG_METHOD);
21+
TRACED();
2222
}
2323

2424
/**
@@ -27,7 +27,7 @@ class Decoder8Bit : public AudioDecoder {
2727
* @param out_stream Output Stream to which we write the decoded result
2828
*/
2929
Decoder8Bit(Print &out_stream, bool active=true){
30-
LOGD(LOG_METHOD);
30+
TRACED();
3131
p_print = &out_stream;
3232
this->active = active;
3333
}
@@ -40,7 +40,7 @@ class Decoder8Bit : public AudioDecoder {
4040
*/
4141

4242
Decoder8Bit(Print &out_stream, AudioBaseInfoDependent &bi){
43-
LOGD(LOG_METHOD);
43+
TRACED();
4444
p_print = &out_stream;
4545
}
4646

@@ -58,7 +58,7 @@ class Decoder8Bit : public AudioDecoder {
5858
}
5959

6060
void begin(AudioBaseInfo info) {
61-
LOGD(LOG_METHOD);
61+
TRACED();
6262
cfg = info;
6363
if (bid!=nullptr){
6464
bid->setAudioInfo(cfg);
@@ -67,12 +67,12 @@ class Decoder8Bit : public AudioDecoder {
6767
}
6868

6969
void begin() override {
70-
LOGD(LOG_METHOD);
70+
TRACED();
7171
active = true;
7272
}
7373

7474
void end() override {
75-
LOGD(LOG_METHOD);
75+
TRACED();
7676
active = false;
7777
}
7878

src/AudioCodecs/CodecAACFDK.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ AudioBaseInfoDependent *audioChangeFDK = nullptr;
1919
class AACDecoderFDK : public AudioDecoder {
2020
public:
2121
AACDecoderFDK(){
22-
LOGD(LOG_METHOD);
22+
TRACED();
2323
dec = new aac_fdk::AACDecoderFDK();
2424
}
2525

2626
AACDecoderFDK(Print &out_stream, int output_buffer_size=2048){
27-
LOGD(LOG_METHOD);
27+
TRACED();
2828
dec = new aac_fdk::AACDecoderFDK(out_stream, output_buffer_size);
2929
}
3030

@@ -79,7 +79,7 @@ class AACDecoderFDK : public AudioDecoder {
7979

8080
// release the resources
8181
void end(){
82-
LOGD(LOG_METHOD);
82+
TRACED();
8383
dec->end();
8484
}
8585

@@ -232,7 +232,7 @@ class AACEncoderFDK : public AudioEncoder {
232232

233233
/// Defines the Audio Info
234234
virtual void setAudioInfo(AudioBaseInfo from) {
235-
LOGD(LOG_METHOD);
235+
TRACED();
236236
aac_fdk::AudioInfo info;
237237
info.channels = from.channels;
238238
info.sample_rate = from.sample_rate;
@@ -247,7 +247,7 @@ class AACEncoderFDK : public AudioEncoder {
247247
* @return int
248248
*/
249249
virtual void begin(AudioBaseInfo info) {
250-
LOGD(LOG_METHOD);
250+
TRACED();
251251
enc->begin(info.channels,info.sample_rate, info.bits_per_sample);
252252
}
253253

@@ -260,7 +260,7 @@ class AACEncoderFDK : public AudioEncoder {
260260
* @return int 0 => ok; error with negative number
261261
*/
262262
virtual void begin(int input_channels=2, int input_sample_rate=44100, int input_bits_per_sample=16) {
263-
LOGD(LOG_METHOD);
263+
TRACED();
264264
enc->begin(input_channels,input_sample_rate, input_bits_per_sample);
265265
}
266266

@@ -277,7 +277,7 @@ class AACEncoderFDK : public AudioEncoder {
277277

278278
// release resources
279279
void end(){
280-
LOGD(LOG_METHOD);
280+
TRACED();
281281
enc->end();
282282
}
283283

src/AudioCodecs/CodecAACHelix.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AACDecoderHelix : public AudioDecoder {
1919
public:
2020

2121
AACDecoderHelix() {
22-
LOGD(LOG_METHOD);
22+
TRACED();
2323
aac = new libhelix::AACDecoderHelix();
2424
if (aac==nullptr){
2525
LOGE("Not enough memory for libhelix");
@@ -31,7 +31,7 @@ class AACDecoderHelix : public AudioDecoder {
3131
* @param out_stream
3232
*/
3333
AACDecoderHelix(Print &out_stream){
34-
LOGD(LOG_METHOD);
34+
TRACED();
3535
aac = new libhelix::AACDecoderHelix(out_stream);
3636
if (aac==nullptr){
3737
LOGE("Not enough memory for libhelix");
@@ -46,7 +46,7 @@ class AACDecoderHelix : public AudioDecoder {
4646
* @param bi
4747
*/
4848
AACDecoderHelix(Print &out_stream, AudioBaseInfoDependent &bi){
49-
LOGD(LOG_METHOD);
49+
TRACED();
5050
aac = new libhelix::AACDecoderHelix(out_stream);
5151
if (aac==nullptr){
5252
LOGE("Not enough memory for libhelix");
@@ -59,19 +59,19 @@ class AACDecoderHelix : public AudioDecoder {
5959
*
6060
*/
6161
~AACDecoderHelix(){
62-
LOGD(LOG_METHOD);
62+
TRACED();
6363
if (aac!=nullptr) delete aac;
6464
}
6565

6666
/// Defines the output Stream
6767
virtual void setOutputStream(Print &out_stream){
68-
LOGD(LOG_METHOD);
68+
TRACED();
6969
if (aac!=nullptr) aac->setOutput(out_stream);
7070
}
7171

7272
/// Starts the processing
7373
void begin(){
74-
LOGD(LOG_METHOD);
74+
TRACED();
7575
if (aac!=nullptr) {
7676
aac->setDelay(CODEC_DELAY_MS);
7777
aac->begin();
@@ -80,7 +80,7 @@ class AACDecoderHelix : public AudioDecoder {
8080

8181
/// Releases the reserved memory
8282
virtual void end(){
83-
LOGD(LOG_METHOD);
83+
TRACED();
8484
if (aac!=nullptr) aac->end();
8585
}
8686

@@ -113,15 +113,15 @@ class AACDecoderHelix : public AudioDecoder {
113113

114114
/// Defines the callback object to which the Audio information change is provided
115115
virtual void setNotifyAudioChange(AudioBaseInfoDependent &bi){
116-
LOGD(LOG_METHOD);
116+
TRACED();
117117
audioChangeAACHelix = &bi;
118118
if (aac!=nullptr) aac->setInfoCallback(infoCallback);
119119
}
120120

121121
/// notifies the subscriber about a change
122122
static void infoCallback(_AACFrameInfo &i){
123123
if (audioChangeAACHelix!=nullptr){
124-
LOGD(LOG_METHOD);
124+
TRACED();
125125
AudioBaseInfo baseInfo;
126126
baseInfo.channels = i.nChans;
127127
baseInfo.sample_rate = i.sampRateOut;

0 commit comments

Comments
 (0)