diff --git a/src/Magnum/Audio/Context.cpp b/src/Magnum/Audio/Context.cpp index aa25c62e4..0563feaf9 100644 --- a/src/Magnum/Audio/Context.cpp +++ b/src/Magnum/Audio/Context.cpp @@ -4,6 +4,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Vladimír Vondruš Copyright © 2015 Jonathan Hale + Copyright © 2019 Guillaume Jacquemin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -32,6 +33,7 @@ #include #include +#include #include #include #include @@ -120,12 +122,15 @@ Context& Context::current() { return *_current; } -#ifndef DOXYGEN_GENERATING_OUTPUT -Context::Context(): Context{Configuration{}} {} -#endif +Context::Context(Int argc, const char** argv): Context(Configuration{}, argc, argv) {} -Context::Context(const Configuration& configuration) { - create(configuration); +Context::Context(NoCreateT, Int argc, const char** argv): Context(NoCreate) { + Utility::Arguments args{"magnum"}; + args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose") + .setFromEnvironment("log") + .parse(argc, argv); + + _displayInitializationLog = !(args.value("log") == "quiet" || args.value("log") == "QUIET"); } Context::Context(NoCreateT) noexcept: _device{}, _context{} {} @@ -211,9 +216,11 @@ bool Context::tryCreate(const Configuration& configuration) { } } - /* Print some info */ - Debug() << "Audio Renderer:" << rendererString() << "by" << vendorString(); - Debug() << "OpenAL version:" << versionString(); + if(_displayInitializationLog) { + /* Print some info */ + Debug() << "Audio Renderer:" << rendererString() << "by" << vendorString(); + Debug() << "OpenAL version:" << versionString(); + } return true; } diff --git a/src/Magnum/Audio/Context.h b/src/Magnum/Audio/Context.h index 2c9e78009..481c0dfbc 100644 --- a/src/Magnum/Audio/Context.h +++ b/src/Magnum/Audio/Context.h @@ -6,6 +6,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Vladimír Vondruš Copyright © 2015 Jonathan Hale + Copyright © 2019 Guillaume Jacquemin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -158,22 +159,42 @@ class MAGNUM_AUDIO_EXPORT Context { /** * @brief Constructor * - * Creates OpenAL context with given configuration. + * Parses command-line arguments, and creates OpenAL context with given + * configuration. */ - #ifdef DOXYGEN_GENERATING_OUTPUT - explicit Context(const Configuration& configuration = Configuration()); - #else - explicit Context(const Configuration& configuration); - explicit Context(); - #endif + explicit Context(const Configuration& configuration, Int argc, const char** argv): Context(NoCreate, argc, argv) { create(configuration); } - /** - * @brief Construct without creating the underlying OpenAL context - * - * Useful in cases where you need to defer context creation to a later - * time, for example to do a more involved configuration. Call - * @ref create() or @ref tryCreate() to create the actual context. - */ + /** @overload */ + explicit Context(const Configuration& configuration, Int argc, char** argv): Context(configuration, argc, const_cast(argv)) {} + + /** @overload */ + explicit Context(const Configuration& configuration, Int argc, std::nullptr_t argv): Context(configuration, argc, static_cast(argv)) {} + + /** @overload */ + explicit Context(const Configuration& configuration): Context(configuration, 0, nullptr) {} + + /** @overload */ + explicit Context(Int argc, const char** argv); + + /** @overload */ + explicit Context(Int argc, char** argv): Context(argc, const_cast(argv)) {} + + /** @overload */ + explicit Context(Int argc, std::nullptr_t argv): Context(argc, static_cast(argv)) {} + + /** @overload */ + explicit Context(): Context(0, nullptr) {} + + /** @overload */ + explicit Context(NoCreateT, Int argc, const char** argv); + + /** @overload */ + explicit Context(NoCreateT, Int argc, char** argv): Context(NoCreate, argc, const_cast(argv)) {} + + /** @overload */ + explicit Context(NoCreateT, Int argc, std::nullptr_t argv): Context(NoCreate, argc, static_cast(argv)) {} + + /** @overload */ explicit Context(NoCreateT) noexcept; /** @brief Copying is not allowed */ @@ -331,6 +352,8 @@ class MAGNUM_AUDIO_EXPORT Context { private: MAGNUM_AUDIO_LOCAL static Context* _current; + bool _displayInitializationLog; + ALCdevice* _device; ALCcontext* _context;