- allow dynamic loading of all sound related libraries without providing any SDK at all.

The needed headers are now included in the repo, which for these libraries is possible thanks to a stable ABI (at least on Windows, the other platforms still need to be checked but the headers only add, never remove or change existing content.)
The big advantage of this setup is that it allows building the project on Windows without any necessary setup - all that needs to be provided is the DLLs from the binary package.
This still requires some fixes for macOS and Linux. On MacOS the proper library names are missing and the ones for Linux are not verified. Both platforms should work, though, if the dynamic loading is disabled.
This commit is contained in:
Christoph Oelckers 2017-04-17 17:05:09 +02:00
commit 7405f541e8
16 changed files with 4203 additions and 146 deletions

View file

@ -38,8 +38,42 @@
#include "mpg123_decoder.h"
#include "files.h"
#include "except.h"
#include "i_module.h"
#include "cmdlib.h"
#ifdef HAVE_MPG123
FModule MPG123Module{"MPG123"};
#include "mpgload.h"
#ifdef _WIN32
#define MPG123LIB "libmpg123-0.dll"
#elif defined(__APPLE__)
#define MPG123LIB ""
#else
#define MPG123LIB "libmpg123.so.1"
#endif
bool IsMPG123Present()
{
#if !defined DYN_MPG123
return true;
#else
static bool cached_result = false;
static bool done = false;
if (!done)
{
done = true;
cached_result = MPG123Module.Load({NicePath("$PROGDIR/" MPG123LIB), MPG123LIB});
}
return cached_result;
#endif
}
static bool inited = false;
@ -84,18 +118,9 @@ bool MPG123Decoder::open(FileReader *reader)
{
if(!inited)
{
#ifdef _MSC_VER
__try {
#endif
if(mpg123_init() != MPG123_OK)
return false;
inited = true;
#ifdef _MSC_VER
} __except (CheckException(GetExceptionCode())) {
// this means that the delay loaded decoder DLL was not found.
return false;
}
#endif
if (!IsMPG123Present()) return false;
if(mpg123_init() != MPG123_OK) return false;
inited = true;
}
Reader = reader;