Fix double close in ID3 routine, add buff to tests
This commit is contained in:
1 parent
4b3ca23d6e
commit
a359222eae
4 files changed
+19
-3
No files matched your search
@@ -125,7 +125,6 @@ AudioFileSourceID3::AudioFileSourceID3(AudioFileSource *src)
|
||||
|
||||
AudioFileSourceID3::~AudioFileSourceID3()
|
||||
{
|
||||
src->close();
|
||||
}
|
||||
|
||||
uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define printf_P printf
|
||||
#define strcpy_P strcpy
|
||||
#define snprintf_P snprintf
|
||||
#define strncpy_P strncpy
|
||||
|
||||
#ifdef __cplusplus
|
||||
class SerialEmulator {
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ CPPOPTS=-g -Wall -std=c++11 -m32 -include Arduino.h
|
||||
mp3: FORCE
|
||||
rm -f *.o
|
||||
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.
|
||||
g++ $(CPPOPTS) -o mp3 mp3.cpp Serial.cpp *.o ../../src/AudioFileSourceSTDIO.cpp ../../src/AudioOutputSTDIO.cpp ../../src/AudioFileSourceID3.cpp ../../src/AudioFileSourceBuffer.cpp ../../src/AudioGeneratorMP3.cpp -I ../../src/ -I.
|
||||
rm -f *.o
|
||||
echo valgrind --leak-check=full --track-origins=yes -v --error-limit=no --show-leak-kinds=all ./mp3
|
||||
|
||||
|
||||
+17
-1
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user