Skip to content

Commit f41a169

Browse files
committed
Main: enforce a reasonable minimum audio_buffer_size setting
1 parent f567083 commit f41a169

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ver 0.20.7 (not yet released)
22
* database
33
- simple: fix false positive directory loop detection with NFS
4+
* enforce a reasonable minimum audio_buffer_size setting
45
* fix random crashes when compiled with clang
56

67
ver 0.20.6 (2017/03/10)

src/Main.cxx

+10
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ static constexpr size_t KILOBYTE = 1024;
121121
static constexpr size_t MEGABYTE = 1024 * KILOBYTE;
122122

123123
static constexpr size_t DEFAULT_BUFFER_SIZE = 4 * MEGABYTE;
124+
static constexpr size_t MIN_BUFFER_SIZE = std::max(CHUNK_SIZE * 32,
125+
64 * KILOBYTE);
126+
124127
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
125128

126129
#ifdef ANDROID
@@ -310,6 +313,13 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
310313
"positive integer, line %i",
311314
param->value.c_str(), param->line);
312315
buffer_size = tmp * KILOBYTE;
316+
317+
if (buffer_size < MIN_BUFFER_SIZE) {
318+
FormatWarning(config_domain, "buffer size %lu is too small, using %lu bytes instead",
319+
(unsigned long)buffer_size,
320+
(unsigned long)MIN_BUFFER_SIZE);
321+
buffer_size = MIN_BUFFER_SIZE;
322+
}
313323
} else
314324
buffer_size = DEFAULT_BUFFER_SIZE;
315325

0 commit comments

Comments
 (0)