Skip to content

Commit

Permalink
VSTPlugin-Linux.cpp: Add Support for various other types of plugins
Browse files Browse the repository at this point in the history
See Github Issue obsproject#11 about plugins where OBS doesn't show an interface. Fixed.

Also added some pathing code... but have no idea if it works. Sorry.
  • Loading branch information
c3r1c3 committed Jan 27, 2017
1 parent 32d87dd commit 67b7d8c
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions linux/VSTPlugin-linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,49 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
AEffect* VSTPlugin::loadEffect() {
AEffect *plugin = nullptr;

wchar_t *wpath;
os_utf8_to_wcs_ptr(pluginPath.c_str(), 0, &wpath);
soHandle = LoadLibraryW(wpath);
// Why is this a (non-portable) wide char?
wchar_t *wpath = NULL;

// We need to convert the above wide char to a 'normal' char
// 4096 elements should be enough to contain it... I hope.
// We also initialize the array with NULLs to prevent issues
// down the road.
char charPath[4096] = {NULL};
uint32_t wcs_returnValue;
//os_utf8_to_wcs_ptr(pluginPath.c_str(), 0, &wpath);
wcs_returnValue = wcstombs(charPath, wpath, sizeof(charPath));

// Now check for errors in the conversion before trying to open
// the file/path.
if (wcs_returnValue < 4) {
wprintf(L"Path conversion error from '%s'", wpath);
printf(", to '%s'\n", charPath);
return nullptr;
}

soHandle = os_dlopen(charPath);
bfree(wpath);
bfree(charPath);
if(soHandle == nullptr) {
printf("Failed trying to load VST from '%s', error %d\n",
pluginPath, GetLastError());
pluginPath.c_str(), errno);
return nullptr;
}

vstPluginMain mainEntryPoint =
(vstPluginMain)GetProcAddress(soHandle, "VSTPluginMain");
(vstPluginMain)(soHandle, "VSTPluginMain");

if (mainEntryPoint == nullptr) {
mainEntryPoint =
(vstPluginMain)os_dlsym(soHandle, "VstPluginMain()");
}

if (mainEntryPoint == nullptr) {
mainEntryPoint = (vstPluginMain)os_dlsym(soHandle, "main");
}

if (!mainEntryPoint) {
if (mainEntryPoint == nullptr) {
printf("Couldn't get a pointer to plugin's main()");
return nullptr;
}

Expand Down

0 comments on commit 67b7d8c

Please sign in to comment.