From d18123b604f9f6e981eb68fd970644a04e1a20d4 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 21 Nov 2018 21:03:11 +1000 Subject: [PATCH] ALSA: Make runtime linking more robust. --- mini_al.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mini_al.h b/mini_al.h index baf3343e..34adf201 100644 --- a/mini_al.h +++ b/mini_al.h @@ -11098,8 +11098,22 @@ mal_result mal_context_init__alsa(mal_context* pContext) mal_assert(pContext != NULL); #ifndef MAL_NO_RUNTIME_LINKING - pContext->alsa.asoundSO = mal_dlopen("libasound.so"); + const char* libasoundNames[] = { + "libasound.so.2", + "libasound.so" + }; + + for (size_t i = 0; i < mal_countof(libasoundNames); ++i) { + pContext->alsa.asoundSO = mal_dlopen(libasoundNames[i]); + if (pContext->alsa.asoundSO != NULL) { + break; + } + } + if (pContext->alsa.asoundSO == NULL) { +#ifdef MAL_DEBUG_OUTPUT + printf("[ALSA] Failed to open shared object.\n"); +#endif return MAL_NO_BACKEND; }