summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-03-11 20:06:33 +0100
committerMax Kellermann <max@musicpd.org>2020-03-12 21:41:39 +0100
commit8d40e68dec09c9d33794f8ebf2929b2f5286657d (patch)
tree3118909bd8297b3d2792bb77e2354191dc1b6ab9 /test
parentde0affe1157a7852adca5c71391136befe8024a5 (diff)
test/run_convert: add option --verbose
Diffstat (limited to 'test')
-rw-r--r--test/run_convert.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/run_convert.cxx b/test/run_convert.cxx
index 734e2c918..b5491446d 100644
--- a/test/run_convert.cxx
+++ b/test/run_convert.cxx
@@ -28,8 +28,11 @@
#include "pcm/Convert.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx"
+#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx"
#include "util/PrintException.hxx"
+#include "Log.hxx"
+#include "LogBackend.hxx"
#include <stdexcept>
@@ -41,6 +44,16 @@
struct CommandLine {
AudioFormat in_audio_format, out_audio_format;
+
+ bool verbose = false;
+};
+
+enum Option {
+ OPTION_VERBOSE,
+};
+
+static constexpr OptionDef option_defs[] = {
+ {"verbose", 'v', false, "Verbose logging"},
};
static CommandLine
@@ -48,8 +61,13 @@ ParseCommandLine(int argc, char **argv)
{
CommandLine c;
- OptionParser option_parser(nullptr, argc, argv);
- while (option_parser.Next()) {
+ OptionParser option_parser(option_defs, argc, argv);
+ while (auto o = option_parser.Next()) {
+ switch (Option(o.index)) {
+ case OPTION_VERBOSE:
+ c.verbose = true;
+ break;
+ }
}
auto args = option_parser.GetRemaining();
@@ -66,6 +84,8 @@ main(int argc, char **argv)
try {
const auto c = ParseCommandLine(argc, argv);
+ SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO);
+
const size_t in_frame_size = c.in_audio_format.GetFrameSize();
PcmConvert state(c.in_audio_format, c.out_audio_format);