config/PlayerConfig: move code to functions
This commit is contained in:
parent
2cafbb2aba
commit
866e7ff3ce
@ -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)
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user