Fix double close in ID3 routine, add buff to tests

This commit is contained in:
Earle F. Philhower, III committed 2018-01-20 09:24:10 -08:00
1 parent 4b3ca23d6e
commit a359222eae
4 files changed
+19 -3

No files matched your search

+17 -1
View File
@@ -3,6 +3,7 @@
#include "AudioOutputSTDIO.h"
#include "AudioGeneratorMP3.h"
#include "AudioFileSourceID3.h"
#include "AudioFileSourceBuffer.h"
// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
@@ -26,13 +27,27 @@ void MDCallback(void *cbData, const char *type, bool isUnicode, const char *stri
}
// Called when there's a warning or error (like a buffer underflow or decode hiccup)
void StatusCallback(void *cbData, int code, const char *string)
{
const char *ptr = reinterpret_cast<const char *>(cbData);
// Note that the string may be in PROGMEM, so copy it to RAM for printf
char s1[64];
strncpy_P(s1, string, sizeof(s1));
s1[sizeof(s1)-1]=0;
Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1);
Serial.flush();
}
int main(int argc, char **argv)
{
(void) argc;
(void) argv;
AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO("jamonit.mp3");
AudioFileSourceID3 *id3 = new AudioFileSourceID3(in);
AudioFileSourceBuffer *buff = new AudioFileSourceBuffer(in, 2048);
buff->RegisterStatusCB(StatusCallback, (void*)"buffer");
AudioFileSourceID3 *id3 = new AudioFileSourceID3(buff);
id3->RegisterMetadataCB(MDCallback, (void*)"ID3TAG");
AudioOutputSTDIO *out = new AudioOutputSTDIO();
out->SetFilename("jamonit.wav");
@@ -45,5 +60,6 @@ int main(int argc, char **argv)
delete mp3;
delete out;
delete id3;
delete buff;
delete in;
}