Skip to content

Commit

Permalink
allow both libsndfile-1.dll and sndfile.dll when dynamically loading …
Browse files Browse the repository at this point in the history
…the library.

sndfile.dll is the official name so this should be checked as well.
  • Loading branch information
coelckers committed Oct 13, 2024
1 parent 519b76b commit 3944bbc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions source/decoder/sndfile_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ FModule SndFileModule{"SndFile"};


#ifdef _WIN32
#define SNDFILELIB "libsndfile-1.dll"
static const char* libnames[] = { "sndfile.dll", "libsndfile-1.dll" };
#elif defined(__APPLE__)
#define SNDFILELIB "libsndfile.1.dylib"
static const char* libnames[] = { "libsndfile.1.dylib" };
#else
#define SNDFILELIB "libsndfile.so.1"
static const char* libnames[] = { "libsndfile.so.1" };
#endif

extern "C" int IsSndFilePresent()
Expand All @@ -61,8 +61,12 @@ extern "C" int IsSndFilePresent()
if (!done)
{
done = true;
auto abspath = FModule_GetProgDir() + "/" SNDFILELIB;
cached_result = SndFileModule.Load({abspath.c_str(), SNDFILELIB});
for (auto libname : libnames)
{
auto abspath = FModule_GetProgDir() + "/" + libname;
cached_result = SndFileModule.Load({ abspath.c_str(), libname });
if (cached_result) break;
}
}
return cached_result;
#endif
Expand Down

0 comments on commit 3944bbc

Please sign in to comment.