From d1b3637082123c32c7f124f68e945cdab1ada920 Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 4 Mar 2018 22:15:29 +1000 Subject: [PATCH] OpenAL: Improvements to how the shared library is opened at runtime. --- mini_al.h | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/mini_al.h b/mini_al.h index 265fdb65..2bef2b89 100644 --- a/mini_al.h +++ b/mini_al.h @@ -9376,30 +9376,27 @@ mal_result mal_context_init__openal(mal_context* pContext) mal_assert(pContext != NULL); #ifndef MAL_NO_RUNTIME_LINKING - const char* libName = NULL; -#ifdef MAL_WIN32 - libName = "OpenAL32.dll"; + const char* libNames[] = { +#if defined(MAL_WIN32) + "OpenAL32.dll", + "soft_oal.dll" #endif #if defined(MAL_UNIX) && !defined(MAL_APPLE) - libName = "libopenal.so"; + "libopenal.so", + "libopenal.so.1" #endif -#ifdef MAL_APPLE - libName = "OpenAL.framework/OpenAL"; +#if defined(MAL_APPLE) + "OpenAL.framework/OpenAL" #endif - if (libName == NULL) { - return MAL_NO_BACKEND; // Don't know what the library name is called. + }; + + for (size_t i = 0; i < mal_countof(libNames); ++i) { + pContext->openal.hOpenAL = mal_dlopen(libNames[i]); + if (pContext->openal.hOpenAL != NULL) { + break; + } } - - pContext->openal.hOpenAL = mal_dlopen(libName); - -#ifdef MAL_WIN32 - // Special case for Win32 - try "soft_oal.dll" for OpenAL-Soft drop-ins. - if (pContext->openal.hOpenAL == NULL) { - pContext->openal.hOpenAL = mal_dlopen("soft_oal.dll"); - } -#endif - if (pContext->openal.hOpenAL == NULL) { return MAL_FAILED_TO_INIT_BACKEND; }