From f780ac418a38a0a86ffcead364a27367b9210710 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 28 Jun 2019 14:35:56 +0200 Subject: [PATCH] output/alsa: log when generating silence due to slow decoder MPD used to do that when this code lived in the player thread, but it was removed by commit 98a7c62d7a4f716d90af6d78e18d1a3b10bc54b3; and the replacement code in the ALSA output plugin didn't have it. --- NEWS | 1 + src/output/plugins/AlsaOutputPlugin.cxx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 354491ea5..8c8f514a5 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ ver 0.21.11 (not yet released) - alsa: fix busy loop while draining - alsa: fix missing drain call - alsa: improve xrun-avoiding silence generator + - alsa: log when generating silence due to slow decoder - alsa, osx: fix distortions with DSD_U32 and DoP on 32 bit CPUs * protocol - fix "list" with multiple "group" levels diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 7e1919e43..8ccdd2121 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -27,6 +27,7 @@ #include "../OutputAPI.hxx" #include "mixer/MixerList.hxx" #include "pcm/PcmExport.hxx" +#include "system/PeriodClock.hxx" #include "thread/Mutex.hxx" #include "thread/Cond.hxx" #include "util/Manual.hxx" @@ -65,6 +66,8 @@ class AlsaOutput final */ TimerEvent silence_timer; + PeriodClock throttle_silence_log; + Manual pcm_export; /** @@ -1073,6 +1076,9 @@ try { return; } + if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5))) + FormatWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun"); + /* insert some silence if the buffer has not enough data yet, to avoid ALSA xrun */ period_buffer.FillWithSilence(silence, out_frame_size);