diff options
author | Max Kellermann <max@musicpd.org> | 2017-12-30 17:24:58 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-06-22 22:59:44 +0200 |
commit | 9f14e7a98d8be5cc4b916456df0124b65ece8ae4 (patch) | |
tree | a0fb35ce16a77bc5d0b647e80c70d85192be6b92 /src/MusicPipe.hxx | |
parent | cb412b221c2a21e9277faa0939e964ab563a36f2 (diff) |
MusicPipe: add MusicBuffer reference
This tiny amount of overhead allows omitting the MusicBuffer in
Clear().
Diffstat (limited to 'src/MusicPipe.hxx')
-rw-r--r-- | src/MusicPipe.hxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/MusicPipe.hxx b/src/MusicPipe.hxx index ecb923431..b3e28a656 100644 --- a/src/MusicPipe.hxx +++ b/src/MusicPipe.hxx @@ -37,6 +37,11 @@ class MusicBuffer; * tail, and the other consumes them from the head. */ class MusicPipe { + /** + * The #MusicBuffer where all chunks must be returned. + */ + MusicBuffer &buffer; + /** the first chunk */ MusicChunk *head = nullptr; @@ -57,7 +62,8 @@ public: /** * Creates a new #MusicPipe object. It is empty. */ - MusicPipe() = default; + explicit MusicPipe(MusicBuffer &_buffer) noexcept + :buffer(_buffer) {} MusicPipe(const MusicPipe &) = delete; @@ -71,6 +77,10 @@ public: MusicPipe &operator=(const MusicPipe &) = delete; + MusicBuffer &GetBuffer() noexcept { + return buffer; + } + #ifndef NDEBUG /** * Checks if the audio format if the chunk is equal to the specified @@ -106,10 +116,8 @@ public: /** * Clears the whole pipe and returns the chunks to the buffer. - * - * @param buffer the buffer object to return the chunks to */ - void Clear(MusicBuffer &buffer) noexcept; + void Clear() noexcept; /** * Pushes a chunk to the tail of the pipe. |