diff --git a/src/AudioFileSourceBuffer.cpp b/src/AudioFileSourceBuffer.cpp index 2b2641b..475f4f9 100644 --- a/src/AudioFileSourceBuffer.cpp +++ b/src/AudioFileSourceBuffer.cpp @@ -56,11 +56,16 @@ AudioFileSourceBuffer::~AudioFileSourceBuffer() bool AudioFileSourceBuffer::seek(int32_t pos, int dir) { - // Invalidate - readPtr = 0; - writePtr = 0; - length = 0; - return src->seek(pos, dir); + if(dir == SEEK_CUR && (readPtr+pos) < length) { + readPtr += pos; + return true; + } else { + // Invalidate + readPtr = 0; + writePtr = 0; + length = 0; + return src->seek(pos, dir); + } } bool AudioFileSourceBuffer::close() diff --git a/src/AudioFileSourceHTTPStream.cpp b/src/AudioFileSourceHTTPStream.cpp index 23b4644..4060ff2 100644 --- a/src/AudioFileSourceHTTPStream.cpp +++ b/src/AudioFileSourceHTTPStream.cpp @@ -123,6 +123,7 @@ retry: bool AudioFileSourceHTTPStream::seek(int32_t pos, int dir) { + audioLogger->printf_P(PSTR("ERROR! AudioFileSourceHTTPStream::seek not implemented!")); (void) pos; (void) dir; return false; diff --git a/src/AudioGeneratorWAV.cpp b/src/AudioGeneratorWAV.cpp index 0b82354..6c8f7a2 100644 --- a/src/AudioGeneratorWAV.cpp +++ b/src/AudioGeneratorWAV.cpp @@ -242,10 +242,13 @@ bool AudioGeneratorWAV::ReadWAVInfo() Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: failed to read WAV data\n")); return false; }; - file->seek(u32, SEEK_CUR); + if(!file->seek(u32, SEEK_CUR)) { + Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: failed to read WAV data, seek failed\n")); + return false; + } } while (1); if (!file->isOpen()) { - Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, file is not open \n")); + Serial.printf_P(PSTR("AudioGeneratorWAV::ReadWAVInfo: cannot read WAV, file is not open\n")); return false; };