Added a more specific define to disable just dynamic linking of plugins.
This commit is contained in:
parent
2b996ab467
commit
3d6d81a80a
|
@ -11,6 +11,8 @@
|
|||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
|
||||
#ifdef CAUDIO_PLATFORM_WIN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
@ -40,6 +42,8 @@ typedef struct HINSTANCE__* hInstance;
|
|||
# define DYNLIB_UNLOAD( a ) dlclose( a )
|
||||
#endif
|
||||
|
||||
#endif //! CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
class cPluginManager : public IPluginManager
|
||||
|
@ -65,10 +69,14 @@ namespace cAudio
|
|||
virtual void uninstallPlugin(IAudioPlugin* plugin);
|
||||
virtual void uninstallPlugin(const char* name);
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
void autoLoadPlugins();
|
||||
#endif
|
||||
protected:
|
||||
std::map<std::string, IAudioPlugin*> RegisteredPlugins;
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
std::map<IAudioPlugin*, DYNLIB_HANDLE> DynamicallyLoadedPlugins;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -9,15 +9,20 @@
|
|||
namespace cAudio
|
||||
{
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
typedef IAudioPlugin* (*GetPluginModule)(const char* version);
|
||||
#endif
|
||||
|
||||
cPluginManager::cPluginManager()
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
autoLoadPlugins();
|
||||
#endif
|
||||
}
|
||||
|
||||
cPluginManager::~cPluginManager()
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
std::map<IAudioPlugin*, DYNLIB_HANDLE>::iterator it;
|
||||
for(it = DynamicallyLoadedPlugins.begin(); it != DynamicallyLoadedPlugins.end(); it++)
|
||||
{
|
||||
|
@ -28,6 +33,7 @@ cPluginManager::~cPluginManager()
|
|||
//Could be an error, not reporting it for now
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cPluginManager::installPlugin(IAudioPlugin* plugin, const char* name)
|
||||
|
@ -49,6 +55,7 @@ bool cPluginManager::installPlugin(IAudioPlugin* plugin, const char* name)
|
|||
|
||||
bool cPluginManager::installPlugin(const char* filename, const char* name)
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
DYNLIB_HANDLE m_hInst = DYNLIB_LOAD(filename);
|
||||
if(m_hInst)
|
||||
{
|
||||
|
@ -66,6 +73,7 @@ bool cPluginManager::installPlugin(const char* filename, const char* name)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -113,6 +121,7 @@ void cPluginManager::uninstallPlugin(IAudioPlugin* plugin)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
std::map<IAudioPlugin*, DYNLIB_HANDLE>::iterator it2 = DynamicallyLoadedPlugins.find(plugin);
|
||||
if(it2 != DynamicallyLoadedPlugins.end())
|
||||
{
|
||||
|
@ -124,6 +133,7 @@ void cPluginManager::uninstallPlugin(IAudioPlugin* plugin)
|
|||
}
|
||||
DynamicallyLoadedPlugins.erase(it2->first);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +145,7 @@ void cPluginManager::uninstallPlugin(const char* name)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
void cPluginManager::autoLoadPlugins()
|
||||
{
|
||||
std::vector<std::string> fileList = getFilesInDirectory(".");
|
||||
|
@ -158,6 +169,7 @@ void cPluginManager::autoLoadPlugins()
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CAUDIO_API IPluginManager* getPluginManager()
|
||||
{
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
|
||||
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
//! Define enabled support for plugins as dynamic libs
|
||||
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
|
||||
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
|
||||
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
|
||||
|
@ -70,6 +75,11 @@
|
|||
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
|
||||
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
//! Define enabled support for plugins as dynamic libs
|
||||
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
|
||||
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
|
||||
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
|
||||
|
@ -130,6 +140,11 @@
|
|||
//! This define controls whether plugin support is added into the library, commenting it out will prevent any plugins from working
|
||||
#define CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
//! Define enabled support for plugins as dynamic libs
|
||||
#define CAUDIO_COMPILE_WITH_DYNAMIC_PLUGIN_SUPPORT
|
||||
#endif //CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
|
||||
//! Size of the internal buffer per source for audio data (total amount buffered is CAUDIO_SOURCE_BUFFER_SIZE * CAUDIO_SOURCE_NUM_BUFFERS)
|
||||
#define CAUDIO_SOURCE_BUFFER_SIZE ( 1024 * 64 )
|
||||
//! Number of internal buffers to cycle through per source (Note: using only 1 leads to choppy sound or premature ending of sources)
|
||||
|
|
Loading…
Reference in New Issue