output/alsa: add full check before calling FillWithSilence()

This commit is contained in:
Max Kellermann 2019-06-27 21:20:38 +02:00
parent 8f6c750064
commit 549faa8a9c
2 changed files with 3 additions and 1 deletions

View File

@ -123,6 +123,8 @@ public:
*/
void FillWithSilence(const uint8_t *_silence,
const size_t frame_size) noexcept {
assert(!IsFull());
size_t partial_frame = tail % frame_size;
auto *dest = GetTail() - partial_frame;

View File

@ -746,7 +746,7 @@ AlsaOutput::DrainInternal()
/* drain ring_buffer */
CopyRingToPeriodBuffer();
if (period_buffer.WasConsumed())
if (period_buffer.WasConsumed() && !period_buffer.IsFull())
/* generate some silence to finish the partial
period */
period_buffer.FillWithSilence(silence, out_frame_size);