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

@@ -98,7 +98,7 @@ DecoderBridge::GetChunk() noexcept
return current_chunk;
do {
current_chunk = dc.buffer->Allocate();
current_chunk = dc.pipe->GetBuffer().Allocate();
if (current_chunk != nullptr) {
current_chunk->replay_gain_serial = replay_gain_serial;
if (replay_gain_serial != 0)
@@ -123,7 +123,7 @@ DecoderBridge::FlushChunk()
auto *chunk = std::exchange(current_chunk, nullptr);
if (chunk->IsEmpty())
dc.buffer->Return(chunk);
dc.pipe->GetBuffer().Return(chunk);
else
dc.pipe->Push(chunk);
@@ -303,11 +303,11 @@ DecoderBridge::CommandFinished()
/* delete frames from the old song position */
if (current_chunk != nullptr) {
dc.buffer->Return(current_chunk);
dc.pipe->GetBuffer().Return(current_chunk);
current_chunk = nullptr;
}
dc.pipe->Clear(*dc.buffer);
dc.pipe->Clear();
if (convert != nullptr)
convert->Reset();

View File

@@ -92,7 +92,7 @@ DecoderControl::IsCurrentSong(const DetachedSong &_song) const noexcept
void
DecoderControl::Start(std::unique_ptr<DetachedSong> _song,
SongTime _start_time, SongTime _end_time,
MusicBuffer &_buffer, MusicPipe &_pipe) noexcept
MusicPipe &_pipe) noexcept
{
assert(_song != nullptr);
assert(_pipe.IsEmpty());
@@ -100,7 +100,6 @@ DecoderControl::Start(std::unique_ptr<DetachedSong> _song,
song = std::move(_song);
start_time = _start_time;
end_time = _end_time;
buffer = &_buffer;
pipe = &_pipe;
ClearError();

View File

@@ -44,7 +44,6 @@
#endif
class DetachedSong;
class MusicBuffer;
class MusicPipe;
enum class DecoderState : uint8_t {
@@ -152,9 +151,6 @@ struct DecoderControl final : InputStreamHandler {
SignedSongTime total_time;
/** the #MusicChunk allocator */
MusicBuffer *buffer;
/**
* The destination pipe for decoded chunks. The caller thread
* owns this object, and is responsible for freeing it.
@@ -383,7 +379,7 @@ public:
*/
void Start(std::unique_ptr<DetachedSong> song,
SongTime start_time, SongTime end_time,
MusicBuffer &buffer, MusicPipe &pipe) noexcept;
MusicPipe &pipe) noexcept;
/**
* Caller must lock the object.

View File

@@ -551,7 +551,7 @@ DecoderControl::RunThread() noexcept
/* we need to clear the pipe here; usually the
PlayerThread is responsible, but it is not
aware that the decoder has finished */
pipe->Clear(*buffer);
pipe->Clear();
decoder_run(*this);
break;