Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginHostAdapter.cpp @ 32:13eae6cc6bac
* Add a function to look up the Vamp plugin path for the current platform.
* Add make install stage and pkgconfig files.
(This bit is rather Linux-specific.)
author | cannam |
---|---|
date | Mon, 31 Jul 2006 16:12:37 +0000 |
parents | c29eccb892f1 |
children | 154f86cb8c99 |
comparison
equal
deleted
inserted
replaced
31:0e7aa8fabd76 | 32:13eae6cc6bac |
---|---|
53 | 53 |
54 PluginHostAdapter::~PluginHostAdapter() | 54 PluginHostAdapter::~PluginHostAdapter() |
55 { | 55 { |
56 // std::cerr << "PluginHostAdapter::~PluginHostAdapter (plugin = " << m_descriptor->name << ")" << std::endl; | 56 // std::cerr << "PluginHostAdapter::~PluginHostAdapter (plugin = " << m_descriptor->name << ")" << std::endl; |
57 if (m_handle) m_descriptor->cleanup(m_handle); | 57 if (m_handle) m_descriptor->cleanup(m_handle); |
58 } | |
59 | |
60 std::vector<std::string> | |
61 PluginHostAdapter::getPluginPath() | |
62 { | |
63 std::vector<std::string> path; | |
64 std::string envPath; | |
65 | |
66 char *cpath = getenv("VAMP_PATH"); | |
67 if (cpath) envPath = cpath; | |
68 | |
69 #ifdef _WIN32 | |
70 #define PATH_SEPARATOR ';' | |
71 #define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins" | |
72 #else | |
73 #define PATH_SEPARATOR ':' | |
74 #ifdef __APPLE__ | |
75 #define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/Vamp/:$HOME/Library/Audio/Plug-Ins/Vamp" | |
76 #else | |
77 #define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp" | |
78 #endif | |
79 #endif | |
80 | |
81 if (envPath == "") { | |
82 envPath = DEFAULT_VAMP_PATH; | |
83 char *chome = getenv("HOME"); | |
84 if (chome) { | |
85 std::string home(chome); | |
86 std::string::size_type f; | |
87 while ((f = envPath.find("$HOME")) != std::string::npos && | |
88 f < envPath.length()) { | |
89 envPath.replace(f, 5, home); | |
90 } | |
91 } | |
92 #ifdef _WIN32 | |
93 char *cpfiles = getenv("ProgramFiles"); | |
94 if (!cpfiles) cpfiles = "C:\\Program Files"; | |
95 std::string pfiles(cpfiles); | |
96 std::string::size_type f; | |
97 while ((f = envPath.find("%ProgramFiles%")) != std::string::npos && | |
98 f < envPath.length()) { | |
99 envPath.replace(f, 14, pfiles); | |
100 } | |
101 #endif | |
102 } | |
103 | |
104 std::string::size_type index = 0, newindex = 0; | |
105 | |
106 while ((newindex = envPath.find(PATH_SEPARATOR, index)) < envPath.size()) { | |
107 path.push_back(envPath.substr(index, newindex - index)); | |
108 index = newindex + 1; | |
109 } | |
110 | |
111 path.push_back(envPath.substr(index)); | |
112 | |
113 return path; | |
58 } | 114 } |
59 | 115 |
60 bool | 116 bool |
61 PluginHostAdapter::initialise(size_t channels, | 117 PluginHostAdapter::initialise(size_t channels, |
62 size_t stepSize, | 118 size_t stepSize, |