From 5a9340c4529805038ee257465e4e1e2cb63fc059 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 15 Dec 2017 19:49:37 -0800 Subject: [PATCH] Fix ICY decoding when apostrophes encountered The ICYMDReader was not properly returning the unread "'" characters and so StreamTitles were being truncated at the first apostrophe. Fix the unread() and read() member functions to clean up. --- src/AudioFileSourceICYStream.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AudioFileSourceICYStream.cpp b/src/AudioFileSourceICYStream.cpp index 0b2a9b4..9fcd45c 100644 --- a/src/AudioFileSourceICYStream.cpp +++ b/src/AudioFileSourceICYStream.cpp @@ -77,6 +77,7 @@ class ICYMDReader { ~ICYMDReader() { // Get rid of any remaining bytes in the MD block char xxx[16]; + if (saved) avail--; // Throw away any unread bytes while (avail > 16) { stream->readBytes(xxx, 16); avail -= 16; @@ -85,8 +86,8 @@ class ICYMDReader { } int read(uint8_t *dest, int len) { if (!len) return 0; - if (saved >= 0) { *(dest++) = (uint8_t)saved; saved = -1; len--; } int ret = 0; + if (saved >= 0) { *(dest++) = (uint8_t)saved; saved = -1; len--; avail--; ret++; } while ((len>0) && (avail>0)) { // Always copy from bounce buffer first while ((ptr < sizeof(buff)) && (len>0) && (avail>0)) { @@ -106,7 +107,7 @@ class ICYMDReader { return ret; } bool eof() { return (avail==0); } - bool unread(uint8_t c) { if (saved>=0) return false; saved = c; return true; } + bool unread(uint8_t c) { if (saved>=0) return false; saved = c; avail++; return true; } private: WiFiClient *stream;