output/alsa: use IsCleared() instead of IsDrained() in DrainInternal()
Really drain all data from the period_buffer in any case.
This commit is contained in:
parent
d66f5a8590
commit
a92aa0bedc
@ -77,14 +77,6 @@ public:
|
|||||||
return tail >= capacity;
|
return tail >= capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Has some data already been consumed at the buffer's head in
|
|
||||||
* this period?
|
|
||||||
*/
|
|
||||||
bool WasConsumed() const noexcept {
|
|
||||||
return head > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has all data for the current period been drained? If not,
|
* Has all data for the current period been drained? If not,
|
||||||
* then there is pending data. This ignores the partial frame
|
* then there is pending data. This ignores the partial frame
|
||||||
|
@ -747,26 +747,30 @@ AlsaOutput::DrainInternal()
|
|||||||
/* drain ring_buffer */
|
/* drain ring_buffer */
|
||||||
CopyRingToPeriodBuffer();
|
CopyRingToPeriodBuffer();
|
||||||
|
|
||||||
if (period_buffer.WasConsumed() && !period_buffer.IsFull())
|
|
||||||
/* generate some silence to finish the partial
|
|
||||||
period */
|
|
||||||
period_buffer.FillWithSilence(silence, out_frame_size);
|
|
||||||
|
|
||||||
/* drain period_buffer */
|
/* drain period_buffer */
|
||||||
if (!period_buffer.IsDrained()) {
|
if (!period_buffer.IsCleared()) {
|
||||||
auto frames_written = WriteFromPeriodBuffer();
|
if (!period_buffer.IsFull())
|
||||||
if (frames_written < 0) {
|
/* generate some silence to finish the partial
|
||||||
if (frames_written == -EAGAIN)
|
period */
|
||||||
return false;
|
period_buffer.FillWithSilence(silence, out_frame_size);
|
||||||
|
|
||||||
throw FormatRuntimeError("snd_pcm_writei() failed: %s",
|
/* drain period_buffer */
|
||||||
snd_strerror(-frames_written));
|
if (!period_buffer.IsDrained()) {
|
||||||
|
auto frames_written = WriteFromPeriodBuffer();
|
||||||
|
if (frames_written < 0) {
|
||||||
|
if (frames_written == -EAGAIN)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
throw FormatRuntimeError("snd_pcm_writei() failed: %s",
|
||||||
|
snd_strerror(-frames_written));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* need to call CopyRingToPeriodBuffer() and
|
||||||
|
WriteFromPeriodBuffer() again in the next
|
||||||
|
iteration, so don't finish the drain just
|
||||||
|
yet */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need to call CopyRingToPeriodBuffer() and
|
|
||||||
WriteFromPeriodBuffer() again in the next
|
|
||||||
iteration, so don't finish the drain just yet */
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!written)
|
if (!written)
|
||||||
|
Loading…
Reference in New Issue
Block a user