Commit 8f6c7500 authored by Max Kellermann's avatar Max Kellermann

output/alsa: improve silence generator test in DrainInternal()

There cannot be partial frames in the buffer, so we don't need GetPeriodPosition(); it's enough to check whether head has been moved in this period.
parent 9fc1668d
......@@ -74,6 +74,14 @@ public:
}
/**
* 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
* copied to the returned pointer, and call AppendBytes() to
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment