The description of `AACDecode()` function states that the output buffer must be big enough for 1024 samples per channel _or_ 2048 if SBR is enabled. By default SBR is enabled on non-ESP8266 platforms, yet the buffer in `AudioGeneratorAAC` is always 1024 samples per channel long. This causes memory corruption on ESP32 and possibly Pi Pico. This change makes the output buffer correct.
28 lines
664 B
C++
28 lines
664 B
C++
#include <Arduino.h>
|
|
#include "AudioFileSourceSTDIO.h"
|
|
#include "AudioOutputSTDIO.h"
|
|
#include "AudioGeneratorAAC.h"
|
|
|
|
#define AAC "../../examples/PlayAACFromPROGMEM/homer.aac"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
(void) argc;
|
|
(void) argv;
|
|
AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO(AAC);
|
|
AudioOutputSTDIO *out = new AudioOutputSTDIO();
|
|
out->SetFilename("out.aac.wav");
|
|
void *space = malloc(28000+60000+2048);
|
|
AudioGeneratorAAC *aac = new AudioGeneratorAAC(space, 28000+60000+2048);
|
|
|
|
aac->begin(in, out);
|
|
while (aac->loop()) { /*noop*/ }
|
|
aac->stop();
|
|
|
|
delete aac;
|
|
delete out;
|
|
delete in;
|
|
|
|
free(space);
|
|
}
|