mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-23 07:06:23 +01:00
vst-scanner app: properly init and use libpbd's Transmitter
This commit is contained in:
parent
ccb7a99b17
commit
d85d05d574
2 changed files with 82 additions and 34 deletions
|
|
@ -3,6 +3,10 @@
|
|||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
#include "pbd/pbd.h"
|
||||
#include "pbd/transmitter.h"
|
||||
#include "pbd/receiver.h"
|
||||
|
||||
#include "ardour/filesystem_paths.h"
|
||||
#ifdef LXVST_SUPPORT
|
||||
#include "ardour/linux_vst_support.h"
|
||||
|
|
@ -23,36 +27,89 @@
|
|||
#endif
|
||||
#include "../ardour/filesystem_paths.cc"
|
||||
#include "../ardour/directory_names.cc"
|
||||
#include "../pbd/error.cc"
|
||||
#include "../pbd/basename.cc"
|
||||
#include "../pbd/search_path.cc"
|
||||
#include "../pbd/transmitter.cc"
|
||||
#include "../pbd/whitespace.cc"
|
||||
|
||||
|
||||
#ifdef LXVST_SUPPORT
|
||||
void
|
||||
vstfx_destroy_editor (VSTState* /*vstfx*/) { }
|
||||
#endif
|
||||
|
||||
using namespace PBD;
|
||||
|
||||
class DummyReceiver : public Receiver {
|
||||
protected:
|
||||
void receive (Transmitter::Channel chn, const char * str) {
|
||||
const char *prefix = "";
|
||||
switch (chn) {
|
||||
case Transmitter::Error:
|
||||
prefix = "[ERROR]: ";
|
||||
break;
|
||||
case Transmitter::Info:
|
||||
/* ignore */
|
||||
return;
|
||||
case Transmitter::Warning:
|
||||
prefix = "[WARNING]: ";
|
||||
break;
|
||||
case Transmitter::Fatal:
|
||||
prefix = "[FATAL]: ";
|
||||
break;
|
||||
case Transmitter::Throw:
|
||||
abort ();
|
||||
}
|
||||
|
||||
std::cerr << prefix << str << std::endl;
|
||||
|
||||
if (chn == Transmitter::Fatal) {
|
||||
::exit (1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DummyReceiver dummy_receiver;
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s <vst>\n", argv[0]);
|
||||
char *dllpath = NULL;
|
||||
if (argc == 3 && !strcmp("-f", argv[1])) {
|
||||
dllpath = argv[2];
|
||||
if (strstr (dllpath, ".so" ) || strstr(dllpath, ".dll")) {
|
||||
vstfx_remove_infofile(dllpath);
|
||||
vstfx_un_blacklist(dllpath);
|
||||
}
|
||||
|
||||
}
|
||||
else if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s [-f] <vst>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
dllpath = argv[1];
|
||||
}
|
||||
|
||||
char *dllpath = argv[1];
|
||||
PBD::init();
|
||||
|
||||
dummy_receiver.listen_to (error);
|
||||
dummy_receiver.listen_to (info);
|
||||
dummy_receiver.listen_to (fatal);
|
||||
dummy_receiver.listen_to (warning);
|
||||
|
||||
std::vector<VSTInfo *> *infos = 0;
|
||||
|
||||
if (0) { }
|
||||
#ifdef LXVST_SUPPORT
|
||||
if (strstr (dllpath, ".so")) {
|
||||
else if (strstr (dllpath, ".so")) {
|
||||
infos = vstfx_get_info_lx(dllpath);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
if (strstr (dllpath, ".dll")) {
|
||||
else if (strstr (dllpath, ".dll")) {
|
||||
infos = vstfx_get_info_fst(dllpath);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fprintf(stderr, "'%s' is not a supported VST plugin.\n", dllpath);
|
||||
}
|
||||
|
||||
PBD::cleanup();
|
||||
|
||||
if (!infos || infos->empty()) {
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -60,4 +117,3 @@ int main (int argc, char **argv) {
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue