-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharedLibrary.h
104 lines (88 loc) · 2.78 KB
/
SharedLibrary.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef SHARED_LIBRARY_H
#define SHARED_LIBRARY_H
#include <dlfcn.h>
#include "logging_macros.h"
#include <cstring>
#include <string>
#include <set>
#include "string.h"
#include <vector>
#include "ladspa.h"
#include "lv2.h"
#include "lv2/worker/worker.h"
#include "lv2/state/state.h"
#include "lv2/log/log.h"
#include "lv2/options/options.h"
#include "lv2/ui/ui.h"
#include "lv2/data-access/data-access.h"
#include <jni.h>
#include <map>
#include "lilv/lilv.h"
typedef struct {
LV2_Feature map_feature;
LV2_Feature unmap_feature;
LV2_State_Make_Path make_path;
LV2_Feature make_path_feature;
LV2_Worker_Schedule sched;
LV2_Feature sched_feature;
LV2_Worker_Schedule ssched;
LV2_Feature state_sched_feature;
LV2_Log_Log llog;
LV2_Feature log_feature;
LV2_Options_Option options[7];
LV2_Feature options_feature;
LV2_Feature safe_restore_feature;
LV2UI_Request_Value request_value;
LV2_Feature request_value_feature;
LV2_Extension_Data_Feature ext_data;
} LV2Features;
struct CmpStr
{
bool operator()(const char *a, const char *b) const
{
return std::strcmp(a, b) < 0;
}
};
class SharedLibrary {
public:
typedef enum {
LADSPA,
LV2,
LILV
} PluginType ;
std::string mainActivityClassName ;
LilvPlugin* plugin = nullptr ;
LilvInstance* instance = nullptr;
std::string lv2_config_path ;
//! feature storage
std::vector<LV2_Feature> m_features;
//! pointers to m_features, required for lilv_plugin_instantiate
std::vector<const LV2_Feature*> m_featurePointers;
//! features + data, ordered by URI
std::map<const char*, void*, CmpStr> m_featureByUri;
std::set<const char*, CmpStr> m_supportedFeatureURIs;
const LV2_Feature* const* featurePointers() const
{
return m_featurePointers.data();
}
std::string LIBRARY_PATH ;
JavaVM * vm ;
SharedLibrary(char * plugin_file, PluginType type = LADSPA);
PluginType type = LADSPA ; // by default
std::string so_file ;
std::vector<const LADSPA_Descriptor *> descriptors;
std::vector<const LV2_Descriptor *> lv2_descriptors;
LV2Features features ;
const LV2_Feature** feature_list;
int total_plugins = 0 ;
void * dl_handle = NULL;
unsigned long sampleRate ;
LADSPA_Descriptor_Function descriptorFunction ;
LV2_Descriptor_Function lv2DescriptorFunction ;
void setSampleRate(unsigned long _sampleRate);
char *load();
bool plugin_is_valid(const LADSPA_Descriptor *descriptor);
void unload();
void setLibraryPath(std::string path);
};
#endif // SHARED_LIBRARY_H