Skip to content

Commit af9091a

Browse files
committed
idf logging support outside of Arduino
1 parent 026daf0 commit af9091a

14 files changed

+336
-270
lines changed

docs/html/_a_a_c_decoder_helix_8h_source.html

Lines changed: 51 additions & 46 deletions
Large diffs are not rendered by default.

docs/html/_common_helix_8h_source.html

Lines changed: 147 additions & 139 deletions
Large diffs are not rendered by default.

docs/html/_config_helix_8h_source.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;<span class="preprocessor">#define ALLOCATOR libhelix::AllocatorExt</span></div>
107107
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; </div>
108108
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160;<span class="comment">// Logging: Activate/Deactivate logging</span></div>
109-
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="preprocessor">#if ! defined(HELIX_LOGGING_ACTIVE) &amp;&amp; defined(ARDUINO)</span></div>
109+
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="preprocessor">#if !defined(HELIX_LOGGING_ACTIVE) </span></div>
110110
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;<span class="preprocessor"># define HELIX_LOGGING_ACTIVE true</span></div>
111111
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="preprocessor">#endif</span></div>
112112
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; </div>
@@ -122,9 +122,17 @@
122122
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160;<span class="preprocessor"># define HELIX_LOGGING_OUT Serial</span></div>
123123
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="preprocessor">#endif</span></div>
124124
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; </div>
125-
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="preprocessor">#ifndef HELIX_LOG_SIZE</span></div>
126-
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;<span class="preprocessor"># define HELIX_LOG_SIZE 256</span></div>
127-
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor">#endif</span></div>
125+
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160;<span class="preprocessor">#if HELIX_LOGGING_ACTIVE &amp;&amp; defined(ESP32) &amp;&amp; !defined(ARDUINO)</span></div>
126+
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;<span class="preprocessor"># define USE_IDF_LOGGER</span></div>
127+
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="preprocessor">#endif</span></div>
128+
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; </div>
129+
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;<span class="preprocessor">#ifndef HELIX_LOG_SIZE</span></div>
130+
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;<span class="preprocessor"># define HELIX_LOG_SIZE 256</span></div>
131+
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160;<span class="preprocessor">#endif</span></div>
132+
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; </div>
133+
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;<span class="preprocessor">#ifndef ESP8266</span></div>
134+
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;<span class="preprocessor"># define HELIX_FEATURE_AUDIO_CODEC_AAC_SBR</span></div>
135+
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160;<span class="preprocessor">#endif</span></div>
128136
</div><!-- fragment --></div><!-- contents -->
129137
<!-- start footer part -->
130138
<hr class="footer"/><address class="footer"><small>

docs/html/_m_p3_decoder_helix_8h_source.html

Lines changed: 42 additions & 38 deletions
Large diffs are not rendered by default.

docs/html/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h1><a class="anchor" id="autotoc_md1"></a>
107107
Installation</h1>
108108
<p>For Arduino, you can download the library as zip and call include Library -&gt; zip library. Or you can git clone this project into the Arduino libraries folder e.g. with</p>
109109
<div class="fragment"><div class="line">cd ~/Documents/Arduino/libraries</div>
110-
<div class="line">git clone pschatzmann/arduino-libhelix.git</div>
110+
<div class="line">git clone https://github.com/pschatzmann/arduino-libhelix.git</div>
111111
</div><!-- fragment --><p>This project can also be built and executed on your desktop with cmake:</p>
112112
<div class="fragment"><div class="line">cd arduino-libhelix</div>
113113
<div class="line">mkdir build</div>
@@ -135,6 +135,8 @@ <h1><a class="anchor" id="autotoc_md5"></a>
135135
Documentation</h1>
136136
<ul>
137137
<li>The <a href="https://pschatzmann.github.io/arduino-libhelix/html/annotated.html">Class Documentation can be found here</a></li>
138+
<li>aac <a href="https://github.com/pschatzmann/arduino-libhelix/blob/main/src/libhelix-aac/readme.txt">readme.txt</a></li>
139+
<li>mp3 <a href="https://github.com/pschatzmann/arduino-libhelix/blob/main/src/libhelix-mp3/readme.txt">readme.txt</a></li>
138140
<li>I also suggest that you have a look at <a href="https://www.pschatzmann.ch/home/tag/codecs/">my related blogs</a></li>
139141
</ul>
140142
<p>I recommend to use this library together with my <a href="https://github.com/pschatzmann/arduino-audio-tools">Arduino Audio Tools</a>. This is just one of many codecs that I have collected so far: Further details can be found in the <a href="https://github.com/pschatzmann/arduino-audio-tools/wiki/Encoding-and-Decoding-of-Audio">Encoding and Decoding Wiki</a> of the Audio Tools.</p>

src/AACDecoderHelix.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AACDecoderHelix : public CommonHelix {
4949

5050
/// Releases the reserved memory
5151
virtual void end() override {
52-
LOG_HELIX(LogLevelHelix::Debug, "end");
52+
LOGD_HELIX( "end");
5353
if (decoder != nullptr) {
5454
flush();
5555
AACFreeDecoder(decoder);
@@ -104,7 +104,7 @@ class AACDecoderHelix : public CommonHelix {
104104

105105
/// decods the data and removes the decoded frame from the buffer
106106
int decode() override {
107-
LOG_HELIX(LogLevelHelix::Debug, "decode");
107+
LOGD_HELIX( "decode");
108108
int processed = 0;
109109
int available = frame_buffer.available();
110110
int bytes_left = frame_buffer.available();
@@ -126,7 +126,7 @@ class AACDecoderHelix : public CommonHelix {
126126
int sampleSize = info.bitsPerSample / 8;
127127
assert(info.outputSamps * sampleSize <= maxPCMSize());
128128

129-
LOG_HELIX(LogLevelHelix::Debug, "==> provideResult: %d samples", info.outputSamps);
129+
LOGD_HELIX( "==> provideResult: %d samples", info.outputSamps);
130130
if (info.outputSamps > 0) {
131131
// provide result
132132
if (pcmCallback != nullptr) {

src/CommonHelix.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CommonHelix {
7474
* not fit into the buffer it is split up into small pieces that fit
7575
*/
7676
virtual size_t write(const void *in_ptr, size_t in_size) {
77-
LOG_HELIX(LogLevelHelix::Info, "write %zu", in_size);
77+
LOGI_HELIX( "write %zu", in_size);
7878
int open = in_size;
7979
size_t processed = 0;
8080
uint8_t *data = (uint8_t *)in_ptr;
@@ -156,7 +156,7 @@ class CommonHelix {
156156

157157
/// make sure that we start with a valid sync: remove ID3 data
158158
bool presync() {
159-
LOG_HELIX(LogLevelHelix::Debug, "presynch");
159+
LOGD_HELIX( "presynch");
160160
bool rc = true;
161161
int pos = findSynchWord();
162162
if (pos > 3) rc = removeInvalidData(pos);
@@ -167,14 +167,14 @@ class CommonHelix {
167167
/// advance on invalid data, returns true if we need to continue the
168168
/// processing
169169
bool resynch(int rc) {
170-
LOG_HELIX(LogLevelHelix::Debug, "resynch: %d" , rc);
170+
LOGD_HELIX( "resynch: %d" , rc);
171171
// reset 0 result counter
172172
if (rc != 0) parse_0_count = 0;
173173
if (rc <= 0) {
174174
if (rc == 0) {
175175
parse_0_count++;
176176
int pos = findSynchWord(SYNCH_WORD_LEN);
177-
LOG_HELIX(LogLevelHelix::Debug, "rc: %d - available %d - pos %d", rc,
177+
LOGD_HELIX( "rc: %d - available %d - pos %d", rc,
178178
frame_buffer.available(), pos);
179179
// if we are stuck, request more data and if this does not help we
180180
// remove the invalid data
@@ -184,7 +184,7 @@ class CommonHelix {
184184
return false;
185185
} else if (rc == -1) {
186186
// underflow
187-
LOG_HELIX(LogLevelHelix::Debug, "rc: %d - available %d", rc,
187+
LOGD_HELIX( "rc: %d - available %d", rc,
188188
frame_buffer.available());
189189
return false;
190190
} else {
@@ -199,9 +199,9 @@ class CommonHelix {
199199
/// removes invalid data not starting with a synch word.
200200
/// @return Returns true if we still have data to be played
201201
bool removeInvalidData(int pos) {
202-
LOG_HELIX(LogLevelHelix::Debug, "removeInvalidData: %d", pos);
202+
LOGD_HELIX( "removeInvalidData: %d", pos);
203203
if (pos > 0) {
204-
LOG_HELIX(LogLevelHelix::Info, "removing: %d bytes", pos);
204+
LOGI_HELIX( "removing: %d bytes", pos);
205205
frame_buffer.clearArray(pos);
206206
return true;
207207
} else if (pos <= 0) {
@@ -213,7 +213,7 @@ class CommonHelix {
213213

214214
/// Decoding Loop: We decode the procided data until we run out of data
215215
virtual size_t writeChunk(const void *in_ptr, size_t in_size) {
216-
LOG_HELIX(LogLevelHelix::Info, "writeChunk %zu", in_size);
216+
LOGI_HELIX( "writeChunk %zu", in_size);
217217
#ifdef ARDUINO
218218
time_last_write = millis();
219219
#endif
@@ -227,7 +227,7 @@ class CommonHelix {
227227
// remove processed data
228228
frame_buffer.clearArray(rc);
229229

230-
LOG_HELIX(LogLevelHelix::Info, "rc: %d - available %d", rc,
230+
LOGI_HELIX( "rc: %d - available %d", rc,
231231
frame_buffer.available());
232232

233233
}

src/ConfigHelix.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define ALLOCATOR libhelix::AllocatorExt
3636

3737
// Logging: Activate/Deactivate logging
38-
#if ! defined(HELIX_LOGGING_ACTIVE) && defined(ARDUINO)
38+
#if !defined(HELIX_LOGGING_ACTIVE)
3939
# define HELIX_LOGGING_ACTIVE true
4040
#endif
4141

@@ -51,6 +51,11 @@
5151
# define HELIX_LOGGING_OUT Serial
5252
#endif
5353

54+
/// Use the IDF logger for ESP32 wieh
55+
#if HELIX_LOGGING_ACTIVE && defined(ESP32) && !defined(ARDUINO)
56+
# define USE_IDF_LOGGER
57+
#endif
58+
5459
#ifndef HELIX_LOG_SIZE
5560
# define HELIX_LOG_SIZE 256
5661
#endif

src/MP3DecoderHelix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MP3DecoderHelix : public CommonHelix {
6060

6161
/// Releases the reserved memory
6262
void end() override {
63-
LOG_HELIX(LogLevelHelix::Debug, "end");
63+
LOGD_HELIX( "end");
6464

6565
if (decoder != nullptr) {
6666
flush();
@@ -113,7 +113,7 @@ class MP3DecoderHelix : public CommonHelix {
113113
int processed = 0;
114114
int available = frame_buffer.available();
115115
int bytes_left = frame_buffer.available();
116-
LOG_HELIX(LogLevelHelix::Info, "decode: %d (left:%d)", available, bytes_left);
116+
LOGI_HELIX( "decode: %d (left:%d)", available, bytes_left);
117117
uint8_t *data = frame_buffer.data();
118118
int rc = MP3Decode(decoder, &data, &bytes_left, (short *)pcm_buffer.data(),
119119
mp3_type);
@@ -124,7 +124,7 @@ class MP3DecoderHelix : public CommonHelix {
124124
MP3GetLastFrameInfo(decoder, &info);
125125
provideResult(info);
126126
} else {
127-
LOG_HELIX(LogLevelHelix::Info, "MP3Decode rc: %d", rc);
127+
LOGI_HELIX( "MP3Decode rc: %d", rc);
128128
}
129129
return processed;
130130
}
@@ -134,7 +134,7 @@ class MP3DecoderHelix : public CommonHelix {
134134
// increase PCM size if this fails
135135
assert(info.outputSamps * sizeof(short) < maxPCMSize());
136136

137-
LOG_HELIX(LogLevelHelix::Debug, "=> provideResult: %d", info.outputSamps);
137+
LOGD_HELIX( "=> provideResult: %d", info.outputSamps);
138138
if (info.outputSamps > 0) {
139139
// provide result
140140
if (pcmCallback != nullptr) {

src/utils/Allocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class Allocator {
6868
virtual void* allocate(size_t size) {
6969
void* result = do_allocate(size);
7070
if (result == nullptr) {
71-
LOG_HELIX(LogLevelHelix::Error,"Allocateation failed for %zu bytes", size);
71+
LOGE_HELIX("Allocateation failed for %zu bytes", size);
7272
while(1);
7373
} else {
74-
LOG_HELIX(LogLevelHelix::Debug,"Allocated %zu", size);
74+
LOGD_HELIX("Allocated %zu", size);
7575
}
7676
return result;
7777
}
@@ -107,7 +107,7 @@ class AllocatorExt : public Allocator {
107107
#endif
108108
if (result == nullptr) result = malloc(size);
109109
if (result == nullptr) {
110-
LOG_HELIX(LogLevelHelix::Error,"allocateation failed for %zu bytes", size);
110+
LOGE_HELIX("allocateation failed for %zu bytes", size);
111111
while(true);
112112
}
113113
// initialize object
@@ -132,7 +132,7 @@ class AllocatorPSRAM : public Allocator {
132132
void* result = nullptr;
133133
result = ps_calloc(1, size);
134134
if (result == nullptr) {
135-
LOG_HELIX(LogLevelHelix::Error,"allocateation failed for %zu bytes", size);
135+
LOGE_HELIX("allocateation failed for %zu bytes", size);
136136
while(true);
137137
}
138138
return result;

0 commit comments

Comments
 (0)