diff options
author | Max Kellermann <max@musicpd.org> | 2020-03-11 20:10:14 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-03-12 21:41:39 +0100 |
commit | a718086ffb989b7c56afc51eb3380f6568ef929e (patch) | |
tree | 39a8560cdf5a01fbc6d4095a32b02611f568b2b7 /test | |
parent | 8d40e68dec09c9d33794f8ebf2929b2f5286657d (diff) |
test/run_convert: add option --config
Diffstat (limited to 'test')
-rw-r--r-- | test/run_convert.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/run_convert.cxx b/test/run_convert.cxx index b5491446d..0e0617617 100644 --- a/test/run_convert.cxx +++ b/test/run_convert.cxx @@ -23,9 +23,11 @@ * */ +#include "ConfigGlue.hxx" #include "pcm/AudioParser.hxx" #include "pcm/AudioFormat.hxx" #include "pcm/Convert.hxx" +#include "fs/Path.hxx" #include "util/ConstBuffer.hxx" #include "util/StaticFifoBuffer.hxx" #include "util/OptionDef.hxx" @@ -45,14 +47,18 @@ struct CommandLine { AudioFormat in_audio_format, out_audio_format; + Path config_path = nullptr; + bool verbose = false; }; enum Option { + OPTION_CONFIG, OPTION_VERBOSE, }; static constexpr OptionDef option_defs[] = { + {"config", 0, true, "Load a MPD configuration file"}, {"verbose", 'v', false, "Verbose logging"}, }; @@ -64,6 +70,10 @@ ParseCommandLine(int argc, char **argv) OptionParser option_parser(option_defs, argc, argv); while (auto o = option_parser.Next()) { switch (Option(o.index)) { + case OPTION_CONFIG: + c.config_path = Path::FromFS(o.value); + break; + case OPTION_VERBOSE: c.verbose = true; break; @@ -79,12 +89,24 @@ ParseCommandLine(int argc, char **argv) return c; } +class GlobalInit { + const ConfigData config; + +public: + explicit GlobalInit(Path config_path) + :config(AutoLoadConfigFile(config_path)) + { + pcm_convert_global_init(config); + } +}; + int main(int argc, char **argv) try { const auto c = ParseCommandLine(argc, argv); SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO); + const GlobalInit init(c.config_path); const size_t in_frame_size = c.in_audio_format.GetFrameSize(); |