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,
|
size_t MIN_BUFFER_SIZE = std::max(CHUNK_SIZE * 32,
|
||||||
64 * KILOBYTE);
|
64 * KILOBYTE);
|
||||||
|
|
||||||
PlayerConfig::PlayerConfig(const ConfigData &config)
|
static unsigned
|
||||||
:replay_gain(config)
|
GetBufferChunks(const ConfigData &config)
|
||||||
{
|
{
|
||||||
size_t buffer_size = PlayerConfig::DEFAULT_BUFFER_SIZE;
|
size_t buffer_size = PlayerConfig::DEFAULT_BUFFER_SIZE;
|
||||||
if (auto *param = config.GetParam(ConfigOption::AUDIO_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)
|
if (buffer_chunks >= 1 << 15)
|
||||||
throw FormatRuntimeError("buffer size \"%lu\" is too big",
|
throw FormatRuntimeError("buffer size \"%lu\" is too big",
|
||||||
(unsigned long)buffer_size);
|
(unsigned long)buffer_size);
|
||||||
|
|
||||||
audio_format = config.With(ConfigOption::AUDIO_OUTPUT_FORMAT, [](const char *s){
|
return buffer_chunks;
|
||||||
if (s == nullptr)
|
}
|
||||||
return AudioFormat::Undefined();
|
|
||||||
|
PlayerConfig::PlayerConfig(const ConfigData &config)
|
||||||
return ParseAudioFormat(s, true);
|
: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