Skip to content

Commit 0307ebe

Browse files
committed
Compile warnings
1 parent 64d66de commit 0307ebe

File tree

4 files changed

+35
-37
lines changed

4 files changed

+35
-37
lines changed

src/AACDecoderHelix.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,26 @@ typedef void (*AACDataCallback)(_AACFrameInfo &info,short *pwm_buffer, size_t le
2020
class AACDecoderHelix : public CommonHelix {
2121
public:
2222
AACDecoderHelix() {
23-
}
23+
decoder = AACInitDecoder();
24+
}
2425

2526
#ifdef ARDUINO
2627
AACDecoderHelix(Print &output, AACInfoCallback infoCallback=nullptr){
28+
decoder = AACInitDecoder();
2729
this->out = &output;
2830
this->infoCallback = infoCallback;
2931
}
3032
#endif
3133
AACDecoderHelix(AACDataCallback dataCallback){
34+
decoder = AACInitDecoder();
3235
this->pwmCallback = dataCallback;
3336
}
37+
38+
~MP3DecoderHelix(){
39+
MP3FreeDecoder(decoder);
40+
}
41+
42+
3443
void setInfoCallback(AACInfoCallback cb){
3544
this->infoCallback = cb;
3645
}
@@ -39,22 +48,13 @@ class AACDecoderHelix : public CommonHelix {
3948
this->pwmCallback = cb;
4049
}
4150

42-
/// Starts the processing
43-
void begin(){
44-
LOG(Debug, "begin");
45-
CommonHelix::begin();
46-
decoder = AACInitDecoder();
47-
if (decoder==nullptr){
48-
LOG(Error, "MP3InitDecoder has failed");
49-
active = false;
50-
return;
51-
}
52-
}
5351

5452
/// Releases the reserved memory
5553
void end(){
5654
LOG(Debug, "end");
57-
AACFreeDecoder(decoder);
55+
if (CommonHelix::active){
56+
AACFreeDecoder(decoder);
57+
}
5858
CommonHelix::end();
5959
}
6060

src/CommonHelix.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
#endif
1010

1111
// Not all processors support assert
12-
#ifdef NDEBUG
12+
#ifndef assert
13+
#ifdef NDEBUG
1314
# define assert(condition) ((void)0)
1415
#else
1516
# define assert(condition) /*implementation defined*/
1617
#endif
18+
#endif
1719

1820
#include "helix_log.h"
1921

@@ -42,7 +44,7 @@ struct Range {
4244
class CommonHelix {
4345
public:
4446

45-
~CommonHelix(){
47+
virtual ~CommonHelix(){
4648
if (active){
4749
end();
4850
}
@@ -116,6 +118,8 @@ class CommonHelix {
116118
write_len = min(in_size - start, static_cast<size_t>(maxFrameSize()-buffer_size));
117119
yield();
118120
}
121+
} else {
122+
LOG(Warn, "CommonHelix not active");
119123
}
120124

121125
return start;
@@ -168,6 +172,9 @@ class CommonHelix {
168172
int process_size = min((int)(maxFrameSize() - buffer_size), in_size);
169173
memmove(frame_buffer+buffer_size, in_ptr, process_size);
170174
buffer_size += process_size;
175+
if (buffer_size>maxFrameSize()){
176+
LOG(Error "Increase MAX_FRAME_SIZE > %ld", buffer_size);
177+
}
171178
assert(buffer_size<=maxFrameSize());
172179

173180
LOG(Debug, "appendToBuffer %d + %d -> %u", buffer_size_old, process_size, buffer_size );

src/MP3DecoderHelix.h

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "libhelix-mp3/mp3common.h"
66

77
#define MP3_MAX_OUTPUT_SIZE 1024 * 2
8-
#define MP3_MAX_FRAME_SIZE 1600
8+
//#define MP3_MAX_FRAME_SIZE 1600
9+
#define MP3_MAX_FRAME_SIZE 10000
910

1011
namespace libhelix {
1112

@@ -26,25 +27,34 @@ class MP3DecoderHelix : public CommonHelix {
2627

2728
public:
2829
MP3DecoderHelix(){
30+
decoder = MP3InitDecoder();
2931
this->mp3_type = MP3Normal;
3032
}
3133

3234
#ifdef ARDUINO
3335
MP3DecoderHelix(Print &output, MP3Type mp3Type=MP3Normal, MP3InfoCallback infoCallback=nullptr){
36+
decoder = MP3InitDecoder();
3437
this->out = &output;
3538
this->infoCallback = infoCallback;
3639
this->mp3_type = mp3Type;
3740
}
3841
#endif
3942
MP3DecoderHelix(MP3DataCallback dataCallback, MP3Type mp3Type=MP3Normal){
43+
decoder = MP3InitDecoder();
4044
this->pwmCallback = dataCallback;
4145
this->mp3_type = mp3Type;
4246
}
4347

4448
MP3DecoderHelix(MP3Type mp3Type){
49+
decoder = MP3InitDecoder();
4550
this->mp3_type = mp3Type;
4651
}
4752

53+
~MP3DecoderHelix(){
54+
MP3FreeDecoder(decoder);
55+
}
56+
57+
4858
void setInfoCallback(MP3InfoCallback cb){
4959
this->infoCallback = cb;
5060
}
@@ -53,25 +63,6 @@ class MP3DecoderHelix : public CommonHelix {
5363
this->pwmCallback = cb;
5464
}
5565

56-
/// Starts the processing
57-
void begin(){
58-
LOG(Debug, "begin");
59-
CommonHelix::begin();
60-
decoder = MP3InitDecoder();
61-
if (decoder==nullptr){
62-
LOG(Error, "MP3InitDecoder has failed");
63-
active = false;
64-
return;
65-
}
66-
}
67-
68-
/// Releases the reserved memory
69-
void end(){
70-
LOG(Debug, "end");
71-
MP3FreeDecoder(decoder);
72-
CommonHelix::end();
73-
}
74-
7566
/// Provides the last available MP3FrameInfo
7667
MP3FrameInfo audioInfo(){
7768
return mp3FrameInfo;

src/helix_log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// User Settings: Activate/Deactivate logging
44
#ifndef HELIX_LOGGING_ACTIVE
5-
#define HELIX_LOGGING_ACTIVE false
5+
#define HELIX_LOGGING_ACTIVE true
66
#endif
77
#ifndef HELIX_LOG_LEVEL
8-
#define HELIX_LOG_LEVEL Warning
8+
#define HELIX_LOG_LEVEL Debug
99
#endif
1010

1111
// Logging Implementation

0 commit comments

Comments
 (0)