MusicPipe: add MusicBuffer reference

This tiny amount of overhead allows omitting the MusicBuffer in
Clear().
This commit is contained in:
Max Kellermann
2017-12-30 17:24:58 +01:00
parent cb412b221c
commit 9f14e7a98d
9 changed files with 34 additions and 49 deletions

View File

@@ -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.