diff --git a/src/lib/alsa/PeriodBuffer.hxx b/src/lib/alsa/PeriodBuffer.hxx index 803a4003a..e2068f5c9 100644 --- a/src/lib/alsa/PeriodBuffer.hxx +++ b/src/lib/alsa/PeriodBuffer.hxx @@ -73,6 +73,14 @@ public: return tail >= capacity; } + /** + * Has some data already been consumed at the buffer's head in + * this period? + */ + bool WasConsumed() const noexcept { + return head > 0; + } + /** * Returns the tail of the buffer, i.e. where new data can be * written. Call GetSpaceBytes() to find out how much may be @@ -163,10 +171,6 @@ public: ConsumeBytes(n * frame_size); } - snd_pcm_uframes_t GetPeriodPosition(size_t frame_size) const noexcept { - return head / frame_size; - } - void Rewind() noexcept { head = 0; } diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index d32213c68..718e0ac66 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -746,8 +746,7 @@ AlsaOutput::DrainInternal() /* drain ring_buffer */ CopyRingToPeriodBuffer(); - auto period_position = period_buffer.GetPeriodPosition(out_frame_size); - if (period_position > 0) + if (period_buffer.WasConsumed()) /* generate some silence to finish the partial period */ period_buffer.FillWithSilence(silence, out_frame_size);