comparison src/knownplugins.cpp @ 34:6905d8b146f6 plugin-path-config

Toward supporting separate environment variables for 32-bit plugins on a 64-bit system (otherwise we try to load both from the same helpers)
author Chris Cannam
date Wed, 06 Jun 2018 13:49:23 +0100
parents c1081e8d26a7
children 4154894d638c
comparison
equal deleted inserted replaced
33:cf18645ff411 34:6905d8b146f6
43 PluginCandidates::LogCallback *cb) : 43 PluginCandidates::LogCallback *cb) :
44 m_candidates(helperExecutableName), 44 m_candidates(helperExecutableName),
45 m_helperExecutableName(helperExecutableName) 45 m_helperExecutableName(helperExecutableName)
46 { 46 {
47 m_candidates.setLogCallback(cb); 47 m_candidates.setLogCallback(cb);
48 48
49 m_known = { 49 std::string variableSuffix = "";
50 { 50 if (is32bit()) {
51 VampPlugin, 51 variableSuffix = "_32";
52 { 52 }
53 "vamp", 53
54 expandConventionalPath(VampPlugin, "VAMP_PATH"), 54 m_known[VampPlugin] = {
55 "vampGetPluginDescriptor" 55 "vamp",
56 }, 56 "VAMP_PATH" + variableSuffix,
57 }, { 57 expandConventionalPath(VampPlugin, "VAMP_PATH" + variableSuffix),
58 LADSPAPlugin, 58 "vampGetPluginDescriptor"
59 { 59 };
60 "ladspa", 60
61 expandConventionalPath(LADSPAPlugin, "LADSPA_PATH"), 61 m_known[LADSPAPlugin] = {
62 "ladspa_descriptor" 62 "ladspa",
63 }, 63 "LADSPA_PATH" + variableSuffix,
64 }, { 64 expandConventionalPath(LADSPAPlugin, "LADSPA_PATH" + variableSuffix),
65 DSSIPlugin, 65 "ladspa_descriptor"
66 { 66 };
67 "dssi", 67
68 expandConventionalPath(DSSIPlugin, "DSSI_PATH"), 68 m_known[DSSIPlugin] = {
69 "dssi_descriptor" 69 "dssi",
70 } 70 "DSSI_PATH" + variableSuffix,
71 } 71 expandConventionalPath(DSSIPlugin, "DSSI_PATH" + variableSuffix),
72 "dssi_descriptor"
72 }; 73 };
73 74
74 for (const auto &k: m_known) { 75 for (const auto &k: m_known) {
75 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor); 76 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor);
76 } 77 }
78 }
79
80 std::vector<KnownPlugins::PluginType>
81 KnownPlugins::getKnownPluginTypes() const
82 {
83 std::vector<PluginType> kt;
84
85 for (const auto &k: m_known) {
86 kt.push_back(k.first);
87 }
88
89 return kt;
77 } 90 }
78 91
79 bool 92 bool
80 KnownPlugins::is32bit() const 93 KnownPlugins::is32bit() const
81 { 94 {
126 string path; 139 string path;
127 140
128 char *cpath = getenv(var.c_str()); 141 char *cpath = getenv(var.c_str());
129 if (cpath) path = cpath; 142 if (cpath) path = cpath;
130 143
131 #ifdef _WIN32
132 bool is32 = is32bit();
133 #endif
134
135 if (path == "") { 144 if (path == "") {
136 145
137 path = getDefaultPath(type); 146 path = getDefaultPath(type);
138 147
139 if (path != "") { 148 if (path != "") {
147 } 156 }
148 } 157 }
149 158
150 #ifdef _WIN32 159 #ifdef _WIN32
151 const char *pfiles = 0; 160 const char *pfiles = 0;
152 if (is32) { 161 const char *pfiles32 = 0;
153 pfiles = getenv("ProgramFiles(x86)"); 162
154 } 163 pfiles = getenv("ProgramFiles");
155 if (!pfiles) { 164 if (!pfiles) {
156 pfiles = getenv("ProgramFiles"); 165 pfiles = "C:\\Program Files";
157 } 166 }
158 if (!pfiles) { 167
159 if (is32) { 168 pfiles32 = getenv("ProgramFiles(x86)");
160 pfiles = "C:\\Program Files (x86)"; 169 if (!pfiles32) {
161 } else { 170 pfiles32 = "C:\\Program Files (x86)";
162 pfiles = "C:\\Program Files"; 171 }
163 } 172
164 }
165 string::size_type f; 173 string::size_type f;
166 while ((f = path.find("%ProgramFiles%")) != string::npos && 174 while ((f = path.find("%ProgramFiles%")) != string::npos &&
167 f < path.length()) { 175 f < path.length()) {
168 path.replace(f, 14, pfiles); 176 if (is32bit()) {
177 path.replace(f, 14, pfiles32);
178 } else {
179 path.replace(f, 14, pfiles);
180 }
169 } 181 }
170 #endif 182 #endif
171 } 183 }
172 } 184 }
173 185