diff --git a/src/config/PlayerConfig.cxx b/src/config/PlayerConfig.cxx index 80e4319e3..ffb9afa56 100644 --- a/src/config/PlayerConfig.cxx +++ b/src/config/PlayerConfig.cxx @@ -30,8 +30,8 @@ static constexpr size_t MIN_BUFFER_SIZE = std::max(CHUNK_SIZE * 32, 64 * KILOBYTE); -PlayerConfig::PlayerConfig(const ConfigData &config) - :replay_gain(config) +static unsigned +GetBufferChunks(const ConfigData &config) { size_t buffer_size = PlayerConfig::DEFAULT_BUFFER_SIZE; if (auto *param = config.GetParam(ConfigOption::AUDIO_BUFFER_SIZE)) { @@ -51,15 +51,22 @@ PlayerConfig::PlayerConfig(const ConfigData &config) }); } - buffer_chunks = buffer_size / CHUNK_SIZE; + unsigned buffer_chunks = buffer_size / CHUNK_SIZE; if (buffer_chunks >= 1 << 15) throw FormatRuntimeError("buffer size \"%lu\" is too big", (unsigned long)buffer_size); - audio_format = config.With(ConfigOption::AUDIO_OUTPUT_FORMAT, [](const char *s){ - if (s == nullptr) - return AudioFormat::Undefined(); - - return ParseAudioFormat(s, true); - }); + return buffer_chunks; +} + +PlayerConfig::PlayerConfig(const ConfigData &config) + :buffer_chunks(GetBufferChunks(config)), + audio_format(config.With(ConfigOption::AUDIO_OUTPUT_FORMAT, [](const char *s){ + if (s == nullptr) + return AudioFormat::Undefined(); + + return ParseAudioFormat(s, true); + })), + replay_gain(config) +{ }