Skip to content

Commit fa2b59d

Browse files
committed
Main: cap buffer_before_play at 80% to prevent deadlock
Closes MusicPlayerDaemon#34
1 parent f41a169 commit fa2b59d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ver 0.20.7 (not yet released)
22
* database
33
- simple: fix false positive directory loop detection with NFS
44
* enforce a reasonable minimum audio_buffer_size setting
5+
* cap buffer_before_play at 80% to prevent deadlock
56
* fix random crashes when compiled with clang
67

78
ver 0.20.6 (2017/03/10)

src/Main.cxx

+13
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,19 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
340340
"than 100 percent, line %i",
341341
param->value.c_str(), param->line);
342342
}
343+
344+
if (perc > 80) {
345+
/* this upper limit should avoid deadlocks
346+
which can occur because the DecoderThread
347+
cannot ever fill the music buffer to
348+
exactly 100%; a few chunks always need to
349+
be available to generate silence in
350+
Player::SendSilence() */
351+
FormatError(config_domain,
352+
"buffer_before_play is too large (%f%%), capping at 80%%; please fix your configuration",
353+
perc);
354+
perc = 80;
355+
}
343356
} else
344357
perc = DEFAULT_BUFFER_BEFORE_PLAY;
345358

0 commit comments

Comments
 (0)