Create an abstraction of dynamic loading so that the format handler doesn't need to know whether LTDL is present or not (except perhaps for the purpose of disabling dynamic loading if it is missing), and so that most of the format handler's code is the same whether using dynamic or static linking. This also adds the capability to look for multiple dynamic libraries with different names (i.e. successfully load any of libsndfile-1, libsndfile, sndfile, cygsndfile, whichever one can be found). Also adds the ability to use stubs for optional functionality that might be missing from some DLLs, such as the export for sf_stop, so that sf_stop will be used if present but the DLL will load even if sf_stop is not present.
Demonstrate the use of this abstraction by making libsndfile loadable via dlopen. Also applies easily to the mp3 handler, though there are already too many patches pending on that for me to easily include it, and dlopen is already working for it, so not a high priority.
Note that libsndfile can only be opened if the sf_open_virtual function is available, since file descriptors cannot be safely passed from one DLL to another. It will work if they share the same CRT, but if they don't, it will fail with unpredictable results.
Log in to post a comment.