From 04077dcf6bfe5929162cb954082044ba4a8b623f Mon Sep 17 00:00:00 2001 From: Squareys Date: Sun, 18 Oct 2015 16:50:45 +0200 Subject: [PATCH] Audio: Make sure AL and ALC extensions are both detected. Signed-off-by: Squareys --- src/Magnum/Audio/Context.cpp | 19 +++++++++++++------ src/Magnum/Audio/Context.h | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Audio/Context.cpp b/src/Magnum/Audio/Context.cpp index 2c4301a83..4d1965df8 100644 --- a/src/Magnum/Audio/Context.cpp +++ b/src/Magnum/Audio/Context.cpp @@ -72,6 +72,9 @@ Context::Context(const Configuration& config) { std::exit(1); } + alcMakeContextCurrent(_context); + _current = this; + /* Add all extensions to a map for faster lookup */ std::unordered_map extensionMap; for(const Extension& extension: Extension::extensions()) @@ -87,9 +90,6 @@ Context::Context(const Configuration& config) { } } - alcMakeContextCurrent(_context); - _current = this; - /* Print some info */ Debug() << "Audio Renderer:" << rendererString() << "by" << vendorString(); Debug() << "OpenAL version:" << versionString(); @@ -105,9 +105,16 @@ Context::~Context() { std::vector Context::extensionStrings() const { std::vector extensions; - /* Don't crash when glGetString() returns nullptr */ - const char* e = reinterpret_cast(alGetString(AL_EXTENSIONS)); - if(e) extensions = Utility::String::splitWithoutEmptyParts(e, ' '); + /* Don't crash when alGetString() returns nullptr */ + const char* alExts = reinterpret_cast(alGetString(AL_EXTENSIONS)); + if(alExts) extensions = Utility::String::splitWithoutEmptyParts(alExts, ' '); + + /* Add ALC extensions aswell */ + const char* alcExts = reinterpret_cast(alcGetString(_device, ALC_EXTENSIONS)); + if(alcExts) { + auto splitAlcExts = Utility::String::splitWithoutEmptyParts(alcExts, ' '); + extensions.insert(extensions.end(), splitAlcExts.begin(), splitAlcExts.end()); + } return extensions; } diff --git a/src/Magnum/Audio/Context.h b/src/Magnum/Audio/Context.h index 29e333c08..b7f647207 100644 --- a/src/Magnum/Audio/Context.h +++ b/src/Magnum/Audio/Context.h @@ -140,7 +140,8 @@ class MAGNUM_AUDIO_EXPORT Context { * @ref supportedExtensions(), @ref Extension::extensions() or * @ref isExtensionSupported() for alternatives. * @see @fn_al{Get} with @def_al{NUM_EXTENSIONS}, @fn_al{GetString} - * with @def_al{EXTENSIONS} + * with @def_al{EXTENSIONS}, @fn_alc{GetString} with + * @def_alc{EXTENSIONS} */ std::vector extensionStrings() const;