X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Fjackrack%2Fplugin_mgr.c;h=386cb25aca85d0e34f30ca30a86b4ca1b1341a75;hb=bedb3bc88adb6733b0dc3b2264dccdbe45dc909b;hp=b666e354031821f0b47513d0cce780293b77d0f8;hpb=b7241ba1f8be71fd66d670436db163957508eaab;p=mlt diff --git a/src/modules/jackrack/plugin_mgr.c b/src/modules/jackrack/plugin_mgr.c index b666e354..386cb25a 100644 --- a/src/modules/jackrack/plugin_mgr.c +++ b/src/modules/jackrack/plugin_mgr.c @@ -1,21 +1,26 @@ /* - * jack-ladspa-host - * - * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * JACK Rack * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Original: + * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net) * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Modification for MLT: + * Copyright (C) 2004 Ushodaya Enterprises Limited + * Author: Dan Dennedy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include @@ -29,11 +34,13 @@ #include #include #include +#include +#include #include "plugin_mgr.h" #include "plugin_desc.h" -#include "ui.h" - +#include "framework/mlt_log.h" +#include "framework/mlt_factory.h" static gboolean plugin_is_valid (const LADSPA_Descriptor * descriptor) @@ -53,14 +60,14 @@ plugin_is_valid (const LADSPA_Descriptor * descriptor) ocount++; } - if (icount == 0 || ocount == 0) + if (ocount == 0) return FALSE; return TRUE; } static void -plugin_mgr_get_object_file_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const char * filename) +plugin_mgr_get_object_file_plugins (plugin_mgr_t * plugin_mgr, const char * filename) { const char * dlerr; void * dl_handle; @@ -73,10 +80,10 @@ plugin_mgr_get_object_file_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const int err; /* open the object file */ - dl_handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL); + dl_handle = dlopen (filename, RTLD_NOW); if (!dl_handle) { - fprintf (stderr, "%s: error opening shared object file '%s': %s\n", + mlt_log_info( NULL, "%s: error opening shared object file '%s': %s\n", __FUNCTION__, filename, dlerror()); return; } @@ -90,12 +97,19 @@ plugin_mgr_get_object_file_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const dlerr = dlerror(); if (dlerr) { - fprintf (stderr, "%s: error finding ladspa_descriptor symbol in object file '%s': %s\n", + mlt_log_info( NULL, "%s: error finding ladspa_descriptor symbol in object file '%s': %s\n", __FUNCTION__, filename, dlerr); dlclose (dl_handle); return; } +#ifdef __DARWIN__ + if (!get_descriptor (0)) { + void (*constructor)(void) = dlsym (dl_handle, "_init"); + if (constructor) constructor(); + } +#endif + plugin_index = 0; while ( (descriptor = get_descriptor (plugin_index)) ) { @@ -121,7 +135,7 @@ plugin_mgr_get_object_file_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const if (exists) { - printf ("Plugin %ld exists in both '%s' and '%s'; using version in '%s'\n", + mlt_log_info( NULL, "Plugin %ld exists in both '%s' and '%s'; using version in '%s'\n", descriptor->UniqueID, other_desc->object_file, filename, other_desc->object_file); plugin_index++; continue; @@ -134,19 +148,19 @@ plugin_mgr_get_object_file_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const plugin_mgr->plugin_count++; /* print in the splash screen */ - /* printf ("Loaded plugin '%s'\n", desc->name); */ + /* mlt_log_verbose( NULL, "Loaded plugin '%s'\n", desc->name); */ } err = dlclose (dl_handle); if (err) { - fprintf (stderr, "%s: error closing object file '%s': %s\n", + mlt_log_warning( NULL, "%s: error closing object file '%s': %s\n", __FUNCTION__, filename, dlerror ()); } } static void -plugin_mgr_get_dir_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const char * dir) +plugin_mgr_get_dir_plugins (plugin_mgr_t * plugin_mgr, const char * dir) { DIR * dir_stream; struct dirent * dir_entry; @@ -157,7 +171,7 @@ plugin_mgr_get_dir_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const char * d dir_stream = opendir (dir); if (!dir_stream) { -/* fprintf (stderr, "%s: error opening directory '%s': %s\n", +/* mlt_log_warning( NULL, "%s: error opening directory '%s': %s\n", __FUNCTION__, dir, strerror (errno)); */ return; } @@ -166,7 +180,10 @@ plugin_mgr_get_dir_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const char * d while ( (dir_entry = readdir (dir_stream)) ) { + struct stat info; + if (strcmp (dir_entry->d_name, ".") == 0 || + mlt_properties_get (plugin_mgr->blacklist, dir_entry->d_name) || strcmp (dir_entry->d_name, "..") == 0) continue; @@ -181,30 +198,47 @@ plugin_mgr_get_dir_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr, const char * d strcpy (file_name + dirlen + 1, dir_entry->d_name); } - plugin_mgr_get_object_file_plugins (ui, plugin_mgr, file_name); + stat (file_name, &info); + if (S_ISDIR (info.st_mode)) + plugin_mgr_get_dir_plugins (plugin_mgr, file_name); + else + plugin_mgr_get_object_file_plugins (plugin_mgr, file_name); g_free (file_name); } err = closedir (dir_stream); if (err) - fprintf (stderr, "%s: error closing directory '%s': %s\n", + mlt_log_warning( NULL, "%s: error closing directory '%s': %s\n", __FUNCTION__, dir, strerror (errno)); } static void -plugin_mgr_get_path_plugins (ui_t * ui, plugin_mgr_t * plugin_mgr) +plugin_mgr_get_path_plugins (plugin_mgr_t * plugin_mgr) { char * ladspa_path, * dir; ladspa_path = g_strdup (getenv ("LADSPA_PATH")); +#ifdef WIN32 + if (!ladspa_path) + { + ladspa_path = malloc (strlen (mlt_environment("MLT_APPDIR")) + strlen ("\\lib\\ladspa") + 1); + strcpy (ladspa_path, mlt_environment("MLT_APPDIR")); + strcat (ladspa_path, "\\lib\\ladspa"); + } +#elif defined(__DARWIN__) && defined(RELOCATABLE) + { + ladspa_path = malloc( strlen (mlt_environment ("MLT_APPDIR")) + strlen ("/lib/ladspa") + 1 ); + strcpy (ladspa_path, mlt_environment ("MLT_APPDIR")); + strcat (ladspa_path, "/lib/ladspa" ); + } +#else if (!ladspa_path) - ladspa_path = g_strdup ("/usr/local/lib/ladspa:/usr/lib/ladspa"); + ladspa_path = g_strdup ("/usr/local/lib/ladspa:/usr/lib/ladspa:/usr/lib64/ladspa"); +#endif - dir = strtok (ladspa_path, ":"); - do - plugin_mgr_get_dir_plugins (ui, plugin_mgr, dir); - while ((dir = strtok (NULL, ":"))); + for (dir = strtok (ladspa_path, ":"); dir; dir = strtok (NULL, ":")) + plugin_mgr_get_dir_plugins (plugin_mgr, dir); g_free (ladspa_path); } @@ -221,24 +255,24 @@ plugin_mgr_sort (gconstpointer a, gconstpointer b) } plugin_mgr_t * -plugin_mgr_new (ui_t * ui) +plugin_mgr_new () { plugin_mgr_t * pm; - + char dirname[PATH_MAX]; + pm = g_malloc (sizeof (plugin_mgr_t)); pm->all_plugins = NULL; pm->plugins = NULL; pm->plugin_count = 0; - - plugin_mgr_get_path_plugins (ui, pm); + + snprintf (dirname, PATH_MAX, "%s/jackrack/blacklist.txt", mlt_environment ("MLT_DATA")); + pm->blacklist = mlt_properties_load (dirname); + plugin_mgr_get_path_plugins (pm); if (!pm->all_plugins) - { - fprintf (stderr, "No LADSPA plugins were found!\n\nCheck your LADSPA_PATH environment variable.\n"); - abort (); - } - - pm->all_plugins = g_slist_sort (pm->all_plugins, plugin_mgr_sort); + mlt_log_warning( NULL, "No LADSPA plugins were found!\n\nCheck your LADSPA_PATH environment variable.\n"); + else + pm->all_plugins = g_slist_sort (pm->all_plugins, plugin_mgr_sort); return pm; }