diff --git a/src/AudioGeneratorAAC.cpp b/src/AudioGeneratorAAC.cpp index 10e3f58..67ad883 100644 --- a/src/AudioGeneratorAAC.cpp +++ b/src/AudioGeneratorAAC.cpp @@ -50,8 +50,8 @@ AudioGeneratorAAC::~AudioGeneratorAAC() bool AudioGeneratorAAC::stop() { - if (!running) return true; running = false; + output->stop(); return file->close(); } diff --git a/src/libhelix-aac/aaccommon.h b/src/libhelix-aac/aaccommon.h index 242bb4b..e167c8f 100644 --- a/src/libhelix-aac/aaccommon.h +++ b/src/libhelix-aac/aaccommon.h @@ -50,7 +50,7 @@ #include // Can't fit in ESP8266 RAM -#ifdef ESP32 +#ifndef ESP8266 #define AAC_ENABLE_SBR 1 #endif diff --git a/src/libhelix-aac/aacdec.h b/src/libhelix-aac/aacdec.h index 8c81aff..3b1d579 100644 --- a/src/libhelix-aac/aacdec.h +++ b/src/libhelix-aac/aacdec.h @@ -74,7 +74,9 @@ #error No platform defined. See valid options in aacdec.h #endif +#ifndef USE_DEFAULT_STDLIB #define USE_DEFAULT_STDLIB +#endif #ifdef __cplusplus extern "C" { diff --git a/src/libhelix-aac/assembly.h b/src/libhelix-aac/assembly.h index 3276462..d995c5e 100644 --- a/src/libhelix-aac/assembly.h +++ b/src/libhelix-aac/assembly.h @@ -606,4 +606,28 @@ clip to [-2^n, 2^n-1], valid range of n = [1, 30] #endif /* platforms */ +#ifndef CLIP_2N +#define CLIP_2N(y, n) { \ + int sign = (y) >> 31; \ + if (sign != (y) >> (n)) { \ + (y) = sign ^ ((1 << (n)) - 1); \ + } \ +} +#endif + +#ifndef CLIP_2N_SHIFT +/* From coder.h, ORIGINAL: + do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) +*/ +//TODO (FB) Is there a better way ? +#define CLIP_2N_SHIFT(y, n) { \ + int sign = (y) >> 31; \ + if (sign != (y) >> (30 - (n))) { \ + (y) = sign ^ (0x3fffffff); \ + } else { \ + (y) = (y) << (n); \ + } \ + } +#endif + #endif /* _ASSEMBLY_H */ diff --git a/tests/host/Makefile b/tests/host/Makefile index 1af8ade..7ae5851 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -1,4 +1,4 @@ -all: mp3 +all: mp3 aac libmad=../../src/libmad/decoder.c ../../src/libmad/frame.c ../../src/libmad/bit.c ../../src/libmad/stream.c ../../src/libmad/fixed.c \ ../../src/libmad/timer.c ../../src/libmad/layer3.c ../../src/libmad/synth.c ../../src/libmad/huffman.c ../../src/libmad/version.c @@ -36,10 +36,16 @@ mp3: FORCE gcc $(CCOPTS) -c $(libmad) -I ../../src/ -I. g++ $(CPPOPTS) -o mp3 mp3.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioGeneratorMP3.cpp -I ../../src/ -I. rm -f *.o - valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./mp3 + echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./mp3 + +aac: FORCE + rm -f *.o + gcc $(CCOPTS) -DUSE_DEFAULT_STDLIB -c $(libhelix_aac) -I ../../src/ -I. + g++ $(CPPOPTS) -o aac aac.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioGeneratorAAC.cpp -I ../../src/ -I. + rm -f *.o + echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./aac clean: - rm -f mp3 *.o - + rm -f mp3 aac *.o FORCE: diff --git a/tests/host/aac.cpp b/tests/host/aac.cpp new file mode 100644 index 0000000..3bb6891 --- /dev/null +++ b/tests/host/aac.cpp @@ -0,0 +1,22 @@ +#include +#include "AudioFileSourceSTDIO.h" +#include "AudioOutputSTDIO.h" +#include "AudioGeneratorAAC.h" + +int main(int argc, char **argv) +{ + (void) argc; + (void) argv; + AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO("jamonit.aac"); + AudioOutputSTDIO *out = new AudioOutputSTDIO(); + out->SetFilename("jamonit.aac.wav"); + AudioGeneratorAAC *aac = new AudioGeneratorAAC(); + + aac->begin(in, out); + while (aac->loop()) { /*noop*/ } + aac->stop(); + + delete aac; + delete out; + delete in; +}