comparison src/knownplugins.cpp @ 19:c80c55cabfcd

Untabify
author Chris Cannam
date Tue, 01 Nov 2016 15:16:08 +0000
parents 45ad9f91f977
children c1081e8d26a7
comparison
equal deleted inserted replaced
18:7eff522b23ae 19:c80c55cabfcd
44 m_candidates(helperExecutableName) 44 m_candidates(helperExecutableName)
45 { 45 {
46 m_candidates.setLogCallback(cb); 46 m_candidates.setLogCallback(cb);
47 47
48 m_known = { 48 m_known = {
49 { 49 {
50 VampPlugin, 50 VampPlugin,
51 { 51 {
52 "vamp", 52 "vamp",
53 expandConventionalPath(VampPlugin, "VAMP_PATH"), 53 expandConventionalPath(VampPlugin, "VAMP_PATH"),
54 "vampGetPluginDescriptor" 54 "vampGetPluginDescriptor"
55 }, 55 },
56 }, { 56 }, {
57 LADSPAPlugin, 57 LADSPAPlugin,
58 { 58 {
59 "ladspa", 59 "ladspa",
60 expandConventionalPath(LADSPAPlugin, "LADSPA_PATH"), 60 expandConventionalPath(LADSPAPlugin, "LADSPA_PATH"),
61 "ladspa_descriptor" 61 "ladspa_descriptor"
62 }, 62 },
63 }, { 63 }, {
64 DSSIPlugin, 64 DSSIPlugin,
65 { 65 {
66 "dssi", 66 "dssi",
67 expandConventionalPath(DSSIPlugin, "DSSI_PATH"), 67 expandConventionalPath(DSSIPlugin, "DSSI_PATH"),
68 "dssi_descriptor" 68 "dssi_descriptor"
69 } 69 }
70 } 70 }
71 }; 71 };
72 72
73 for (const auto &k: m_known) { 73 for (const auto &k: m_known) {
74 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor); 74 m_candidates.scan(k.second.tag, k.second.path, k.second.descriptor);
75 } 75 }
76 } 76 }
77 77
78 string 78 string
79 KnownPlugins::getDefaultPath(PluginType type) 79 KnownPlugins::getDefaultPath(PluginType type)
81 switch (type) { 81 switch (type) {
82 82
83 #if defined(_WIN32) 83 #if defined(_WIN32)
84 84
85 case VampPlugin: 85 case VampPlugin:
86 return "%ProgramFiles%\\Vamp Plugins"; 86 return "%ProgramFiles%\\Vamp Plugins";
87 case LADSPAPlugin: 87 case LADSPAPlugin:
88 return "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins"; 88 return "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins";
89 case DSSIPlugin: 89 case DSSIPlugin:
90 return "%ProgramFiles%\\DSSI Plugins"; 90 return "%ProgramFiles%\\DSSI Plugins";
91 91
92 #elif defined(__APPLE__) 92 #elif defined(__APPLE__)
93 93
94 case VampPlugin: 94 case VampPlugin:
95 return "$HOME/Library/Audio/Plug-Ins/Vamp:/Library/Audio/Plug-Ins/Vamp"; 95 return "$HOME/Library/Audio/Plug-Ins/Vamp:/Library/Audio/Plug-Ins/Vamp";
96 case LADSPAPlugin: 96 case LADSPAPlugin:
97 return "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA"; 97 return "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA";
98 case DSSIPlugin: 98 case DSSIPlugin:
99 return "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI"; 99 return "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI";
100 100
101 #else /* Linux, BSDs, etc */ 101 #else /* Linux, BSDs, etc */
102 102
103 case VampPlugin: 103 case VampPlugin:
104 return "$HOME/vamp:$HOME/.vamp:/usr/local/lib/vamp:/usr/lib/vamp"; 104 return "$HOME/vamp:$HOME/.vamp:/usr/local/lib/vamp:/usr/lib/vamp";
105 case LADSPAPlugin: 105 case LADSPAPlugin:
106 return "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa"; 106 return "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa";
107 case DSSIPlugin: 107 case DSSIPlugin:
108 return "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi"; 108 return "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi";
109 #endif 109 #endif
110 } 110 }
111 111
112 throw logic_error("unknown or unhandled plugin type"); 112 throw logic_error("unknown or unhandled plugin type");
113 } 113 }
123 123
124 if (path == "") { 124 if (path == "") {
125 125
126 path = getDefaultPath(type); 126 path = getDefaultPath(type);
127 127
128 if (path != "") { 128 if (path != "") {
129 129
130 char *home = getenv("HOME"); 130 char *home = getenv("HOME");
131 if (home) { 131 if (home) {
132 string::size_type f; 132 string::size_type f;
133 while ((f = path.find("$HOME")) != string::npos && 133 while ((f = path.find("$HOME")) != string::npos &&
134 f < path.length()) { 134 f < path.length()) {
135 path.replace(f, 5, home); 135 path.replace(f, 5, home);
136 } 136 }
137 } 137 }
138 138
139 #ifdef _WIN32 139 #ifdef _WIN32
140 const char *pfiles = getenv("ProgramFiles"); 140 const char *pfiles = getenv("ProgramFiles");
141 if (!pfiles) pfiles = "C:\\Program Files"; 141 if (!pfiles) pfiles = "C:\\Program Files";
142 { 142 {
143 string::size_type f; 143 string::size_type f;
144 while ((f = path.find("%ProgramFiles%")) != string::npos && 144 while ((f = path.find("%ProgramFiles%")) != string::npos &&
145 f < path.length()) { 145 f < path.length()) {
146 path.replace(f, 14, pfiles); 146 path.replace(f, 14, pfiles);
147 } 147 }
148 } 148 }
149 #endif 149 #endif
150 } 150 }
151 } 151 }
152 152
153 string::size_type index = 0, newindex = 0; 153 string::size_type index = 0, newindex = 0;
154 154
155 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) { 155 while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) {
156 pathList.push_back(path.substr(index, newindex - index).c_str()); 156 pathList.push_back(path.substr(index, newindex - index).c_str());
157 index = newindex + 1; 157 index = newindex + 1;
158 } 158 }
159 159
160 pathList.push_back(path.substr(index)); 160 pathList.push_back(path.substr(index));
161 161
162 return pathList; 162 return pathList;
166 KnownPlugins::getFailureReport() const 166 KnownPlugins::getFailureReport() const
167 { 167 {
168 vector<PluginCandidates::FailureRec> failures; 168 vector<PluginCandidates::FailureRec> failures;
169 169
170 for (auto t: getKnownPluginTypes()) { 170 for (auto t: getKnownPluginTypes()) {
171 auto ff = m_candidates.getFailedLibrariesFor(getTagFor(t)); 171 auto ff = m_candidates.getFailedLibrariesFor(getTagFor(t));
172 failures.insert(failures.end(), ff.begin(), ff.end()); 172 failures.insert(failures.end(), ff.begin(), ff.end());
173 } 173 }
174 174
175 if (failures.empty()) return ""; 175 if (failures.empty()) return "";
176 176
177 int n = int(failures.size()); 177 int n = int(failures.size());
179 179
180 ostringstream os; 180 ostringstream os;
181 181
182 os << "<ul>"; 182 os << "<ul>";
183 for (auto f: failures) { 183 for (auto f: failures) {
184 os << "<li>" + f.library; 184 os << "<li>" + f.library;
185 if (f.message != "") { 185 if (f.message != "") {
186 os << "<br><i>" + f.message + "</i>"; 186 os << "<br><i>" + f.message + "</i>";
187 } else { 187 } else {
188 os << "<br><i>unknown error</i>"; 188 os << "<br><i>unknown error</i>";
189 } 189 }
190 os << "</li>"; 190 os << "</li>";
191 191
192 if (n > 10) { 192 if (n > 10) {
193 if (++i == 5) { 193 if (++i == 5) {
194 os << "<li>(... and " << (n - i) << " further failures)</li>"; 194 os << "<li>(... and " << (n - i) << " further failures)</li>";
195 break; 195 break;
196 } 196 }
197 } 197 }
198 } 198 }
199 os << "</ul>"; 199 os << "</ul>";
200 200
201 return os.str(); 201 return os.str();
202 } 202 }