Add callbacks for metadata and status reports
All objects can have a metadata and/or status report callback once created. They will call the source program with the parsed ID3 tag, ICY StreamTitle, or text and numeric error ID of any interesting event. It is up to the end application to figure out what to do with this. Normally, you'd just print it to the LCD or Serial port. But it is possible to detect, say, a buffer overflow and then switch to a lower bitrate stream for example.
This commit is contained in:
1 parent
1ab9348a4c
commit
9c120a777a
22 files changed
+339
-85
No files matched your search
+13
-13
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "AudioFileSourceID3.h"
|
||||
|
||||
#include "AudioFileStream.h"
|
||||
|
||||
// Handle unsync operation in ID3 with custom class
|
||||
class AudioFileSourceUnsync : public AudioFileSource
|
||||
@@ -113,7 +113,6 @@ AudioFileSourceID3::AudioFileSourceID3(AudioFileSource *src)
|
||||
{
|
||||
this->src = src;
|
||||
this->checked = false;
|
||||
this->cb = NULL;
|
||||
}
|
||||
|
||||
AudioFileSourceID3::~AudioFileSourceID3()
|
||||
@@ -179,17 +178,18 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
|
||||
for (int j=0; j<framesize; j++)
|
||||
id3.getByte();
|
||||
}
|
||||
if (frameid[0]=='T' && frameid[1]=='A' && frameid[2]=='L' && frameid[3] == 'B') {
|
||||
if (cb) cb("Album", id3.getByte()==1, framesize-1, &id3);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='I' && frameid[2]=='T' && frameid[3] == '2') {
|
||||
if (cb) cb("Title", id3.getByte()==1, framesize-1, &id3);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='E' && frameid[3] == '1') {
|
||||
if (cb) cb("Performer", id3.getByte()==1, framesize-1, &id3);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && frameid[3] == 'R') {
|
||||
if (cb) cb("Year", id3.getByte()==1, framesize-1, &id3);
|
||||
} else {
|
||||
for (int j=0; j<framesize; j++)
|
||||
id3.getByte();
|
||||
{
|
||||
AudioFileStream afs(&id3, framesize);
|
||||
if (frameid[0]=='T' && frameid[1]=='A' && frameid[2]=='L' && frameid[3] == 'B') {
|
||||
cb.md("Album", afs.read()==1, &afs);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='I' && frameid[2]=='T' && frameid[3] == '2') {
|
||||
cb.md("Title", afs.read()==1, &afs);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='P' && frameid[2]=='E' && frameid[3] == '1') {
|
||||
cb.md("Performer", afs.read()==1, &afs);
|
||||
} else if (frameid[0]=='T' && frameid[1]=='Y' && frameid[2]=='E' && frameid[3] == 'R') {
|
||||
cb.md("Year", afs.read()==1, &afs);
|
||||
}
|
||||
//afs destructor here will read any unread bytes
|
||||
}
|
||||
}
|
||||
} while (!id3.eof());
|
||||
|
||||
Reference in new issue
Block a user