From c5eeb8c555062834f523b9a5a14db2d84793a36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 25 Sep 2016 12:51:59 +0200 Subject: [PATCH] Audio: added magnum-al-info utility. --- CMakeLists.txt | 5 +- doc/building.dox | 2 + doc/cmake.dox | 1 + modules/FindMagnum.cmake | 3 +- src/Magnum/Audio/CMakeLists.txt | 22 ++++- src/Magnum/Audio/MacOSXBundleInfo.plist.in | 18 ++++ src/Magnum/Audio/magnum-al-info.cpp | 110 +++++++++++++++++++++ 7 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 src/Magnum/Audio/MacOSXBundleInfo.plist.in create mode 100644 src/Magnum/Audio/magnum-al-info.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e6cc02b4f..4ec90174d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) option(WITH_MAGNUMINFO "Build magnum-info utility" OFF) endif() -# Utilities (currently only using GLX, CGL or WGL) +# Desktop-only utilities if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) cmake_dependent_option(WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF "NOT TARGET_GLES" OFF) cmake_dependent_option(WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF "NOT TARGET_GLES" OFF) @@ -84,6 +84,9 @@ cmake_dependent_option(WITH_SHADERS "Build Shaders library" ON "NOT WITH_DEBUGTO cmake_dependent_option(WITH_TEXT "Build Text library" ON "NOT WITH_MAGNUMFONT;NOT WITH_MAGNUMFONTCONVERTER" ON) cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT;NOT WITH_DISTANCEFIELDCONVERTER" ON) +# Magnum AL Info +cmake_dependent_option(WITH_AL_INFO "Build magnum-al-info utility" OFF "WITH_AUDIO" OFF) + # EGL context and windowless EGL application, available everywhere except on # platforms which don't support extension loading if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL) diff --git a/doc/building.dox b/doc/building.dox index 31f576d6b..c1813fb13 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -239,6 +239,8 @@ on Linux, Mac OS X and Windows, also disabled by default: - `WITH_MAGNUMINFO` - @ref magnum-info "magnum-info" executable, provides information about the engine and OpenGL capabilities. +- `WITH_AL_INFO` -- @ref magnum-al-info "magnum-al-info" executable, provides + information about OpenAL capabilities. - `WITH_DISTANCEFIELDCONVERTER` - @ref magnum-distancefieldconverter "magnum-distancefieldconverter" executable for converting black&white images to distance field textures. Enables also building of TextureTools library. diff --git a/doc/cmake.dox b/doc/cmake.dox index 8efb9ba68..d491fc795 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -143,6 +143,7 @@ Lastly, a few utility executables are available: - `distancefieldconverter` -- @ref magnum-distancefieldconverter executable - `fontconverter` -- @ref magnum-fontconverter executable - `info` -- @ref magnum-info executable +- `al-info` -- @ref magnum-al-info executable Note that [each namespace](namespaces.html), all @ref Platform libraries and each plugin class contain more detailed information about dependencies, diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 949d54a28..846ed9da0 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -73,6 +73,7 @@ # distancefieldconverter - magnum-distancefieldconverter executable # fontconverter - magnum-fontconverter executable # info - magnum-info executable +# al-info - magnum-al-info executable # # Example usage with specifying additional components is:: # @@ -344,7 +345,7 @@ endif() # components from other repositories) set(_MAGNUM_LIBRARY_COMPONENTS "^(Audio|DebugTools|MeshTools|Primitives|SceneGraph|Shaders|Shapes|Text|TextureTools|AndroidApplication|GlfwApplication|GlutApplication|GlxApplication|NaClApplication|Sdl2Application|XEglApplication|WindowlessCglApplication|WindowlessEglApplication|WindowlessGlxApplication|WindowlessIosApplication|WindowlessNaClApplication|WindowlessWglApplication|WindowlessWindowsEglApplication|CglContext|EglContext|GlxContext|WglContext)$") set(_MAGNUM_PLUGIN_COMPONENTS "^(MagnumFont|MagnumFontConverter|ObjImporter|TgaImageConverter|TgaImporter|WavAudioImporter)$") -set(_MAGNUM_EXECUTABLE_COMPONENTS "^(distancefieldconverter|fontconverter|info)$") +set(_MAGNUM_EXECUTABLE_COMPONENTS "^(distancefieldconverter|fontconverter|info|al-info)$") # Find all components foreach(_component ${Magnum_FIND_COMPONENTS}) diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index 1a156e3ff..0607c8d2b 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -74,9 +74,25 @@ install(TARGETS MagnumAudio ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES ${MagnumAudio_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Audio) +# Magnum Audio target alias for superprojects +add_library(Magnum::Audio ALIAS MagnumAudio) + +if(WITH_AL_INFO) + add_executable(magnum-al-info magnum-al-info.cpp) + target_link_libraries(magnum-al-info MagnumAudio) + install(TARGETS magnum-al-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) + + if(CORRADE_TARGET_IOS) + set_target_properties(magnum-al-info PROPERTIES + MACOSX_BUNDLE ON + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") + endif() + + # Magnum AL info target alias for superprojects + add_executable(Magnum::al-info ALIAS magnum-al-info) +endif() + if(BUILD_TESTS) add_subdirectory(Test) endif() - -# Magnum Audio target alias for superprojects -add_library(Magnum::Audio ALIAS MagnumAudio) diff --git a/src/Magnum/Audio/MacOSXBundleInfo.plist.in b/src/Magnum/Audio/MacOSXBundleInfo.plist.in new file mode 100644 index 000000000..ee4083277 --- /dev/null +++ b/src/Magnum/Audio/MacOSXBundleInfo.plist.in @@ -0,0 +1,18 @@ + + + + + CFBundleDevelopmentRegion + en-US + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleIdentifier + cz.mosra.magnum.magnum-al-info + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + magnum-al-info + CFBundlePackageType + APPL + + diff --git a/src/Magnum/Audio/magnum-al-info.cpp b/src/Magnum/Audio/magnum-al-info.cpp new file mode 100644 index 000000000..50a3b8f6e --- /dev/null +++ b/src/Magnum/Audio/magnum-al-info.cpp @@ -0,0 +1,110 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/Magnum.h" +#include "Magnum/Audio/Context.h" + +namespace Magnum { + +/** @page magnum-al-info Magnum OpenAL Info +@brief Displays information about Magnum OpenAL capabilities + +@section magnum-al-info-usage Usage + + magnum-al-info [-h|--help] [-s|--short] [--extension-strings] + +Arguments: +- `-h`,` --help` -- display this help message and exit +- `-s`, `--short` -- display just essential info and exit +- `--extension-strings` -- list all extension strings provided by the driver + (implies `--short`) + +@section magnum-al-info-example Example output + +``` + +---------------------------------------------------------+ + | Information about Magnum engine and OpenAL capabilities | + +---------------------------------------------------------+ + +connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory) +attempt to connect to server failed +Audio Renderer: OpenAL Soft by OpenAL Community +OpenAL version: 1.1 ALSOFT 1.17.2 +Available devices: + OpenAL Soft +Current device: OpenAL Soft +Vendor extension support: + AL_EXT_FLOAT32 SUPPORTED + AL_EXT_DOUBLE SUPPORTED + AL_EXT_ALAW SUPPORTED + AL_EXT_MULAW SUPPORTED + AL_EXT_MCFORMATS SUPPORTED + ALC_ENUMERATION_EXT SUPPORTED + ALC_SOFTX_HRTF - + ALC_SOFT_HRTF SUPPORTED + +``` + +*/ + +} + +using namespace Magnum; + +int main(const int argc, const char** const argv) { + Utility::Arguments args; + args.addBooleanOption('s', "short").setHelp("short", "display just essential info and exit") + .addBooleanOption("extension-strings").setHelp("extension-strings", "list all extension strings provided by the driver (implies --short)") + .parse(argc, argv); + + Debug() << ""; + Debug() << " +---------------------------------------------------------+"; + Debug() << " | Information about Magnum engine and OpenAL capabilities |"; + Debug() << " +---------------------------------------------------------+"; + Debug() << ""; + + Audio::Context c; + + if(args.isSet("extension-strings")) { + Debug() << "Extension strings:" << Debug::newline + << c.extensionStrings(); + return 0; + } + + if(args.isSet("short")) return 0; + + Debug() << "Vendor extension support:"; + for(const auto& extension: Audio::Extension::extensions()) { + std::string extensionName = extension.string(); + Debug d; + d << " " << extensionName << std::string(60-extensionName.size(), ' '); + if(c.isExtensionSupported(extension)) + d << "SUPPORTED"; + else + d << " -"; + } +}