summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-05-15 22:25:39 +0200
committerMax Kellermann <max@musicpd.org>2017-05-15 22:49:31 +0200
commitfa2b59df4b4dd0b480b3ee8d71d810e207cd806b (patch)
tree623c79c78fee8ad0efbee06b37df4929bb156445
parentf41a1694604752b95f81dd8b70b81c32a464237d (diff)
Main: cap buffer_before_play at 80% to prevent deadlock
Closes #34
-rw-r--r--NEWS1
-rw-r--r--src/Main.cxx13
2 files changed, 14 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index f81782417..b04e8cae9 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ ver 0.20.7 (not yet released)
* database
- simple: fix false positive directory loop detection with NFS
* enforce a reasonable minimum audio_buffer_size setting
+* cap buffer_before_play at 80% to prevent deadlock
* fix random crashes when compiled with clang
ver 0.20.6 (2017/03/10)
diff --git a/src/Main.cxx b/src/Main.cxx
index 5e7610880..a431aa4ec 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -340,6 +340,19 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
"than 100 percent, line %i",
param->value.c_str(), param->line);
}
+
+ if (perc > 80) {
+ /* this upper limit should avoid deadlocks
+ which can occur because the DecoderThread
+ cannot ever fill the music buffer to
+ exactly 100%; a few chunks always need to
+ be available to generate silence in
+ Player::SendSilence() */
+ FormatError(config_domain,
+ "buffer_before_play is too large (%f%%), capping at 80%%; please fix your configuration",
+ perc);
+ perc = 80;
+ }
} else
perc = DEFAULT_BUFFER_BEFORE_PLAY;