From 28e864e096a506338e633f7cbca14c7922c01960 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Oct 2017 20:26:09 +0200 Subject: [PATCH] player/Thread: log message when decoder is too slow --- NEWS | 2 ++ src/player/Thread.cxx | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 88855d969..f21b4224c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.20.12 (not yet released) * input - curl: fix seeking +* player + - log message when decoder is too slow ver 0.20.11 (2017/10/18) * storage diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 923e5ee59..c06bd419f 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -32,6 +32,7 @@ #include "output/MultipleOutputs.hxx" #include "tag/Tag.hxx" #include "Idle.hxx" +#include "system/PeriodClock.hxx" #include "util/Domain.hxx" #include "thread/Name.hxx" #include "Log.hxx" @@ -146,6 +147,8 @@ class Player { */ SongTime elapsed_time; + PeriodClock throttle_silence_log; + public: Player(PlayerControl &_pc, DecoderControl &_dc, MusicBuffer &_buffer) @@ -934,6 +937,8 @@ Player::SongBorder() { FormatDefault(player_domain, "played \"%s\"", song->GetURI()); + throttle_silence_log.Reset(); + ReplacePipe(dc.pipe); pc.outputs.SongBorder(); @@ -1095,6 +1100,10 @@ Player::Run() /* the decoder is too busy and hasn't provided new PCM data in time: send silence (if the output pipe is empty) */ + + if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5))) + FormatWarning(player_domain, "Decoder is too slow; playing silence to avoid xrun"); + if (!SendSilence()) break; }