From e3a3f2b2785648a7df15819dd5792961e638b7e0 Mon Sep 17 00:00:00 2001 From: h3ndrik Date: Sun, 25 Mar 2018 21:14:08 +0200 Subject: [PATCH] Report buffer fill level (#52) Add method to get the current buffer fill level (for real-time display/etc.) --- src/AudioFileSourceBuffer.cpp | 5 +++++ src/AudioFileSourceBuffer.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/AudioFileSourceBuffer.cpp b/src/AudioFileSourceBuffer.cpp index b85efffd..abd9947d 100644 --- a/src/AudioFileSourceBuffer.cpp +++ b/src/AudioFileSourceBuffer.cpp @@ -85,6 +85,11 @@ uint32_t AudioFileSourceBuffer::getPos() return src->getPos(); } +uint32_t AudioFileSourceBuffer::getFillLevel() +{ + return length; +} + uint32_t AudioFileSourceBuffer::read(void *data, uint32_t len) { if (!buffer) return src->read(data, len); diff --git a/src/AudioFileSourceBuffer.h b/src/AudioFileSourceBuffer.h index fe1ac299..cc4e659c 100644 --- a/src/AudioFileSourceBuffer.h +++ b/src/AudioFileSourceBuffer.h @@ -39,6 +39,8 @@ class AudioFileSourceBuffer : public AudioFileSource virtual uint32_t getPos() override; virtual bool loop() override; + virtual uint32_t getFillLevel(); + enum { STATUS_FILLING=2, STATUS_UNDERFLOW }; private: