ReplayGainGlobal: move replay_gain_config into struct Config

Yet another global variable removed.
This commit is contained in:
Max Kellermann 2016-12-03 13:15:56 +01:00
parent d2a1294e9a
commit 94e9e93fa4
3 changed files with 14 additions and 14 deletions

View File

@ -128,13 +128,14 @@ Context *context;
Instance *instance; Instance *instance;
struct Config { struct Config {
ReplayGainConfig replay_gain;
}; };
gcc_const gcc_const
static Config static Config
LoadConfig() LoadConfig()
{ {
return {}; return {LoadReplayGainConfig()};
} }
#ifdef ENABLE_DAEMON #ifdef ENABLE_DAEMON
@ -290,7 +291,7 @@ static void winsock_init(void)
* Initialize the decoder and player core, including the music pipe. * Initialize the decoder and player core, including the music pipe.
*/ */
static void static void
initialize_decoder_and_player(void) initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
{ {
const ConfigParam *param; const ConfigParam *param;
@ -443,7 +444,6 @@ try {
stats_global_init(); stats_global_init();
TagLoadConfig(); TagLoadConfig();
replay_gain_global_init();
log_init(options.verbose, options.log_stderr); log_init(options.verbose, options.log_stderr);
@ -463,7 +463,7 @@ try {
config_get_positive(ConfigOption::MAX_CONN, 10); config_get_positive(ConfigOption::MAX_CONN, 10);
instance->client_list = new ClientList(max_clients); instance->client_list = new ClientList(max_clients);
initialize_decoder_and_player(); initialize_decoder_and_player(config.replay_gain);
listen_global_init(instance->event_loop, *instance->partition); listen_global_init(instance->event_loop, *instance->partition);
@ -495,8 +495,6 @@ try {
static int static int
mpd_main_after_fork(const Config &config) mpd_main_after_fork(const Config &config)
try { try {
(void)config;
ConfigureFS(); ConfigureFS();
glue_mapper_init(); glue_mapper_init();
@ -518,8 +516,9 @@ try {
glue_sticker_init(); glue_sticker_init();
command_init(); command_init();
instance->partition->outputs.Configure(instance->event_loop, instance->partition->outputs.Configure(instance->event_loop,
replay_gain_config, config.replay_gain,
instance->partition->pc); instance->partition->pc);
client_manager_init(); client_manager_init();
input_stream_global_init(); input_stream_global_init();

View File

@ -28,8 +28,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
ReplayGainConfig replay_gain_config;
static float static float
ParsePreamp(const char *s) ParsePreamp(const char *s)
{ {
@ -57,8 +55,11 @@ ParsePreamp(const ConfigParam &p)
} }
} }
void replay_gain_global_init(void) ReplayGainConfig
LoadReplayGainConfig()
{ {
ReplayGainConfig replay_gain_config;
const auto *param = config_get_param(ConfigOption::REPLAYGAIN_PREAMP); const auto *param = config_get_param(ConfigOption::REPLAYGAIN_PREAMP);
if (param) if (param)
replay_gain_config.preamp = ParsePreamp(*param); replay_gain_config.preamp = ParsePreamp(*param);
@ -69,4 +70,6 @@ void replay_gain_global_init(void)
replay_gain_config.limit = config_get_bool(ConfigOption::REPLAYGAIN_LIMIT, replay_gain_config.limit = config_get_bool(ConfigOption::REPLAYGAIN_LIMIT,
ReplayGainConfig::DEFAULT_LIMIT); ReplayGainConfig::DEFAULT_LIMIT);
return replay_gain_config;
} }

View File

@ -24,9 +24,7 @@
struct ReplayGainConfig; struct ReplayGainConfig;
extern ReplayGainConfig replay_gain_config; ReplayGainConfig
LoadReplayGainConfig();
void
replay_gain_global_init();
#endif #endif