output/alsa: DrainInternal() ignores postponed partial frame

This commit is contained in:
Max Kellermann 2019-06-27 21:00:08 +02:00
parent c1eb0583c4
commit f0ac63d5af
2 changed files with 12 additions and 1 deletions

View File

@ -81,6 +81,17 @@ public:
return head > 0;
}
/**
* Has all data for the current period been drained? If not,
* then there is pending data. This ignores the partial frame
* which may have been postponed by FillWithSilence().
*/
bool IsDrained() const noexcept {
/* compare head with capacity, not with tail; this
method makes only sense if the period is full */
return head >= capacity;
}
/**
* Returns the tail of the buffer, i.e. where new data can be
* written. Call GetSpaceBytes() to find out how much may be

View File

@ -753,7 +753,7 @@ AlsaOutput::DrainInternal()
period_buffer.FillWithSilence(silence, out_frame_size);
/* drain period_buffer */
if (!period_buffer.IsEmpty()) {
if (!period_buffer.IsDrained()) {
auto frames_written = WriteFromPeriodBuffer();
if (frames_written < 0) {
if (frames_written == -EAGAIN)