From bca62a5a1cfbddbacaf49eac035ca2daf544956c Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Mon, 6 Jan 2025 20:24:47 +0100 Subject: [PATCH] RP2040 BaseStream correct read() empty to -1 --- src/AudioTools/CoreAudio/BaseStream.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AudioTools/CoreAudio/BaseStream.h b/src/AudioTools/CoreAudio/BaseStream.h index 7dc8afaa2..8bb19bed0 100644 --- a/src/AudioTools/CoreAudio/BaseStream.h +++ b/src/AudioTools/CoreAudio/BaseStream.h @@ -72,11 +72,15 @@ class BaseStream : public Stream { virtual int read() override { refillReadBuffer(); + // if it is empty we need to return an int -1 + if (tmp_in.isEmpty()) return -1; return tmp_in.read(); } virtual int peek() override { refillReadBuffer(); + // if it is empty we need to return an int -1 + if (tmp_in.isEmpty()) return -1; return tmp_in.peek(); }