Replace Stream with simple string in MD callback

@armSeb found that the stream interface caused a big slowdown and
hiccups in his playback, replace the MetadataCallback's *Stream with
a simple *char for faster operation and less overhead.
This commit is contained in:
Earle F. Philhower, III committed 2017-12-15 12:54:49 -08:00
1 parent d923ebef36
commit 8e94702468
5 files changed
+29 -33

No files matched your search

@@ -18,20 +18,19 @@ AudioFileSourceID3 *id3;
// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
void MDCallback(void *cbData, const char *type, bool isUnicode, Stream *stream)
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
{
(void)cbData;
Serial.printf("ID3 callback for: %s = '", type);
if (isUnicode) {
// Skip byte order marker
stream->read();
stream->read();
string += 2;
}
while (stream->available()) {
char a = stream->read();
while (*string) {
char a = *(string++);
if (isUnicode) {
stream->read();
string++;
}
Serial.printf("%c", a);
}
+3 -3
View File
@@ -209,13 +209,13 @@ void HandleStop(WiFiClient *client)
RedirectToIndex(client);
}
void MDCallback(void *cbData, const char *type, bool isUnicode, Stream *stream)
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
{
const char *ptr = reinterpret_cast<const char *>(cbData);
(void) isUnicode; // Punt this ball for now
(void) ptr;
if (strstr(type, PSTR("Title"))) {
strncpy(title, stream->readString().c_str(), sizeof(title));
if (strstr_P(type, PSTR("Title"))) {
strncpy_P(title, string, sizeof(title));
title[sizeof(title)-1] = 0;
} else {
// Who knows what to do? Not me!