From 71ef0faa2cdb75c53dab2198441eef510c042f5b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 27 Aug 2019 19:04:51 +0200 Subject: [PATCH] output/Source: move code to DropCurrentChunk() --- src/output/Source.cxx | 4 ++-- src/output/Source.hxx | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/output/Source.cxx b/src/output/Source.cxx index 5dff228a3..0db6b790d 100644 --- a/src/output/Source.cxx +++ b/src/output/Source.cxx @@ -216,7 +216,7 @@ AudioOutputSource::Fill(Mutex &mutex) { if (current_chunk != nullptr && pending_tag == nullptr && pending_data.empty()) - pipe.Consume(*std::exchange(current_chunk, nullptr)); + DropCurrentChunk(); if (current_chunk != nullptr) return true; @@ -247,7 +247,7 @@ AudioOutputSource::ConsumeData(size_t nbytes) noexcept pending_data.skip_front(nbytes); if (pending_data.empty()) - pipe.Consume(*std::exchange(current_chunk, nullptr)); + DropCurrentChunk(); } ConstBuffer diff --git a/src/output/Source.hxx b/src/output/Source.hxx index 62fa5ee8d..df104ddf2 100644 --- a/src/output/Source.hxx +++ b/src/output/Source.hxx @@ -212,6 +212,12 @@ private: unsigned *replay_gain_serial_p); ConstBuffer FilterChunk(const MusicChunk &chunk); + + void DropCurrentChunk() noexcept { + assert(current_chunk != nullptr); + + pipe.Consume(*std::exchange(current_chunk, nullptr)); + } }; #endif