Commit 8d40e68d authored by Max Kellermann's avatar Max Kellermann

test/run_convert: add option --verbose

parent de0affe1
...@@ -28,8 +28,11 @@ ...@@ -28,8 +28,11 @@
#include "pcm/Convert.hxx" #include "pcm/Convert.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx" #include "util/StaticFifoBuffer.hxx"
#include "util/OptionDef.hxx"
#include "util/OptionParser.hxx" #include "util/OptionParser.hxx"
#include "util/PrintException.hxx" #include "util/PrintException.hxx"
#include "Log.hxx"
#include "LogBackend.hxx"
#include <stdexcept> #include <stdexcept>
...@@ -41,6 +44,16 @@ ...@@ -41,6 +44,16 @@
struct CommandLine { struct CommandLine {
AudioFormat in_audio_format, out_audio_format; 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 static CommandLine
...@@ -48,8 +61,13 @@ ParseCommandLine(int argc, char **argv) ...@@ -48,8 +61,13 @@ ParseCommandLine(int argc, char **argv)
{ {
CommandLine c; CommandLine c;
OptionParser option_parser(nullptr, argc, argv); OptionParser option_parser(option_defs, argc, argv);
while (option_parser.Next()) { while (auto o = option_parser.Next()) {
switch (Option(o.index)) {
case OPTION_VERBOSE:
c.verbose = true;
break;
}
} }
auto args = option_parser.GetRemaining(); auto args = option_parser.GetRemaining();
...@@ -66,6 +84,8 @@ main(int argc, char **argv) ...@@ -66,6 +84,8 @@ main(int argc, char **argv)
try { try {
const auto c = ParseCommandLine(argc, argv); const auto c = ParseCommandLine(argc, argv);
SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO);
const size_t in_frame_size = c.in_audio_format.GetFrameSize(); const size_t in_frame_size = c.in_audio_format.GetFrameSize();
PcmConvert state(c.in_audio_format, c.out_audio_format); PcmConvert state(c.in_audio_format, c.out_audio_format);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment