diff options
author | Max Kellermann <max@musicpd.org> | 2017-05-15 22:39:57 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-05-15 22:44:18 +0200 |
commit | f41a1694604752b95f81dd8b70b81c32a464237d (patch) | |
tree | 8340fbf7125b6a19cde362505223e7169a6ca297 /src | |
parent | f567083006a88f0a67390318e6e6011afdcce334 (diff) |
Main: enforce a reasonable minimum audio_buffer_size setting
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index 0f9368b1a..5e7610880 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -121,6 +121,9 @@ static constexpr size_t KILOBYTE = 1024; static constexpr size_t MEGABYTE = 1024 * KILOBYTE; static constexpr size_t DEFAULT_BUFFER_SIZE = 4 * MEGABYTE; +static constexpr size_t MIN_BUFFER_SIZE = std::max(CHUNK_SIZE * 32, + 64 * KILOBYTE); + static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10; #ifdef ANDROID @@ -310,6 +313,13 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config) "positive integer, line %i", param->value.c_str(), param->line); buffer_size = tmp * KILOBYTE; + + if (buffer_size < MIN_BUFFER_SIZE) { + FormatWarning(config_domain, "buffer size %lu is too small, using %lu bytes instead", + (unsigned long)buffer_size, + (unsigned long)MIN_BUFFER_SIZE); + buffer_size = MIN_BUFFER_SIZE; + } } else buffer_size = DEFAULT_BUFFER_SIZE; |