From 00b8ced09f6bbf8199345e18d4e2b837e8576738 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Jul 2022 12:18:52 +0200 Subject: [PATCH] encoder/flac: Read() returns the internal buffer --- src/encoder/plugins/FlacEncoderPlugin.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx index 4490d1c48..69b76c77e 100644 --- a/src/encoder/plugins/FlacEncoderPlugin.cxx +++ b/src/encoder/plugins/FlacEncoderPlugin.cxx @@ -43,7 +43,7 @@ class FlacEncoder final : public Encoder { /** * This buffer will hold encoded data from libFLAC until it is - * picked up with flac_encoder_read(). + * picked up with Read(). */ DynamicFifoBuffer output_buffer{8192}; @@ -73,8 +73,10 @@ public: void Write(std::span src) override; - std::span Read(std::span buffer) noexcept override { - return buffer.first(output_buffer.Read(buffer.data(), buffer.size())); + std::span Read(std::span) noexcept override { + auto r = output_buffer.Read(); + output_buffer.Consume(r.size()); + return r; } private: