aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pluginhost~/Makefile2
-rw-r--r--pluginhost~/handlers_pd.c19
-rw-r--r--pluginhost~/jload.c3
-rw-r--r--pluginhost~/ph_common.c276
-rw-r--r--pluginhost~/ph_common.h3
5 files changed, 161 insertions, 142 deletions
diff --git a/pluginhost~/Makefile b/pluginhost~/Makefile
index a3c00b6..393b1ae 100644
--- a/pluginhost~/Makefile
+++ b/pluginhost~/Makefile
@@ -119,7 +119,7 @@ ifeq ($(UNAME),Darwin)
SOURCES += $(SOURCES_iphoneos)
# Starting with Xcode 4.0, the PowerPC compiler is not installed by default
ifeq ($(wildcard /usr/llvm-gcc-4.2/libexec/gcc/powerpc*), )
- FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=10.5
+ FAT_FLAGS = -arch i386 -mmacosx-version-min=10.5
else
FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
endif
diff --git a/pluginhost~/handlers_pd.c b/pluginhost~/handlers_pd.c
index e19b91b..4604a07 100644
--- a/pluginhost~/handlers_pd.c
+++ b/pluginhost~/handlers_pd.c
@@ -64,7 +64,7 @@
#define TYPE_STRING_SIZE 20
#define OSC_ADDR_MAX 8192
-#if DEBUG == 1
+#ifdef DEBUG
#define CHECKSUM_PATCH_FILES_ON_LOAD 1
#endif
@@ -411,25 +411,26 @@ static void ph_ladspa_describe(const char * pcFullFilename,
static void ph_show(ph *x, unsigned int i, bool toggle)
{
- /* TODO:OSC */
-/*
+ ph_instance *instance = &x->instances[i];
+ t_int argc = 2;
+ t_atom argv[argc];
+
if(instance->ui_target){
+ SETSYMBOL(argv+1, gensym(""));
if (instance->ui_hidden && toggle) {
- lo_send(instance->ui_target,
- instance->ui_osc_show_path, "");
+ SETSYMBOL(argv, gensym(instance->ui_osc_show_path));
instance->ui_hidden = 0;
}
else if (!instance->ui_hidden && !toggle) {
- instance->ui_osc_hide_path, "");
+ SETSYMBOL(argv, gensym(instance->ui_osc_hide_path));
instance->ui_hidden = 1;
}
+ ph_instance_send_osc(x->message_out, instance, argc, argv);
}
else if(toggle){
instance->ui_show = 1;
- ph_load_gui(x, instance);
-
+ ph_load_gui(x, i);
}
- */
}
static t_int ph_configure_buffer(ph *x, char *key,
diff --git a/pluginhost~/jload.c b/pluginhost~/jload.c
index 1672b91..38ab4a3 100644
--- a/pluginhost~/jload.c
+++ b/pluginhost~/jload.c
@@ -137,7 +137,8 @@ loadLADSPAPluginLibrary(const char * pcPluginFilename) {
void * pvPluginHandle;
- pvPluginHandle = dlopenLADSPA(pcPluginFilename, RTLD_NOW);
+ pvPluginHandle = dlopenLADSPA(pcPluginFilename, RTLD_NOW |
+ RTLD_LOCAL);
if (!pvPluginHandle) {
fprintf(stderr,
"Failed to load plugin \"%s\": %s\n",
diff --git a/pluginhost~/ph_common.c b/pluginhost~/ph_common.c
index b81e276..e85f6fa 100644
--- a/pluginhost~/ph_common.c
+++ b/pluginhost~/ph_common.c
@@ -43,7 +43,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h> /* for exit() */
-#include <sys/types.h> /* for fork() */
+//#include <sys/types.h> /* for fork() */
+#include <unistd.h>
#include <signal.h> /* for kill() */
#include <dirent.h> /* for readdir() */
#include <dlfcn.h> /* for dlsym() */
@@ -408,96 +409,6 @@ static void ph_init_programs(ph *x, unsigned int i)
}
}
-/* TODO:OSC */
-#if 0
-static void ph_load_gui(ph *x, int instance)
-{
- t_int err = 0;
- char *gui_path;
- struct dirent *dir_entry = NULL;
- char *gui_base;
- size_t baselen;
- DIR *dp;
- char *gui_str;
-
- gui_base = (char *)malloc((baselen = sizeof(char) * (strlen(x->plugin_full_path) - strlen(".so"))) + 1);
-
- strncpy(gui_base, x->plugin_full_path, baselen);
- gui_base[baselen] = '\0';
-
- /* don't use strndup - GNU only */
- /* gui_base = strndup(x->plugin_full_path, baselen);*/
- ph_debug_post("gui_base: %s", gui_base);
-
-
- gui_str = (char *)malloc(sizeof(char) * (strlen("channel 00") + 1));
- sprintf (gui_str,"channel %02d", instance);
-
- ph_debug_post("GUI name string, %s", gui_str);
-
-
- if(!(dp = opendir(gui_base))){
- post("pluginhost~: unable to find GUI in %s, continuing without...", gui_base);
- return;
- }
- else {
- while((dir_entry = readdir(dp))){
- if (dir_entry->d_name[0] == '.') continue;
- if (strchr(dir_entry->d_name, '_')){
- if (strstr(dir_entry->d_name, "gtk") ||
- strstr(dir_entry->d_name, "qt") ||
- strstr(dir_entry->d_name, "text"))
- break;
- }
- }
- ph_debug_post("GUI filename: %s", dir_entry->d_name);
-
- }
-
- gui_path = (char *)malloc(sizeof(char) * (strlen(gui_base) + strlen("/") +
- strlen(dir_entry->d_name) + 1));
-
- sprintf(gui_path, "%s/%s", gui_base, dir_entry->d_name);
-
- free(gui_base);
- ph_debug_post("gui_path: %s", gui_path);
-
-
- /* osc_url_base was of the form:
- * osc.udp://127.0.0.1:9997/dssi
- */
- osc_url = (char *)malloc
- (sizeof(char) * (strlen(x->osc_url_base) +
- strlen(instance->osc_url_path) + 2));
-
- sprintf(osc_url, "%s/%s", x->osc_url_base,
- instance->osc_url_path);
- post("pluginhost~: instance %d URL: %s",instance, osc_url);
- ph_debug_post("Trying to open GUI!");
-
-
- instance->gui_pid = fork();
- if (instance->gui_pid == 0){
- err = execlp(gui_path, gui_path, osc_url, dir_entry->d_name,
- x->descriptor->LADSPA_Plugin->Label, gui_str, NULL);
- perror("exec failed");
- exit(1); /* terminates the process */
- }
-
- ph_debug_post("errorcode = %d", err);
-
-
- free(gui_path);
- free(osc_url);
- free(gui_str);
- if(dp){
-
- ph_debug_post("directory handle closed = %d", closedir(dp));
-
- }
-}
-#endif
-
static t_int ph_configure_buffer_free(ph *x)
{
ph_configure_pair *curr, *prev;
@@ -587,25 +498,26 @@ static void osc_setup(ph *x, unsigned int i)
{
ph_instance *instance = &x->instances[i];
+ assert(x->plugin_basename);
+
if(i == 0){
x->osc_port = OSC_PORT;
}
instance->osc_url_path = malloc(sizeof(char) *
(strlen(x->plugin_basename) +
strlen(x->descriptor->LADSPA_Plugin->Label) +
- //strlen("chan00") + 3));
- 6 + 3));
+ strlen("chan00") + 3));
+ //6 + 3));
sprintf(instance->osc_url_path, "%s/%s/chan%02d", x->plugin_basename,
x->descriptor->LADSPA_Plugin->Label, i);
ph_debug_post("OSC Path is: %s", instance->osc_url_path);
-
}
/* ==================================== */
void ph_debug_post(const char *fmt, ...)
{
-#if DEBUG == 1
+#ifdef DEBUG
unsigned int currpos;
char newfmt[DEBUG_STRING_SIZE];
char result[DEBUG_STRING_SIZE];
@@ -762,15 +674,18 @@ char *ph_send_configure(ph *x, const char *key, const char *value,
{
char *debug;
+ ph_instance *instance = &x->instances[i];
+ t_atom argv[3];
+ t_int argc = 3;
+
debug = x->descriptor->configure(x->instance_handles[i], key, value);
- /* TODO:OSC */
- /* if(instance->ui_target != NULL && x->is_dssi) {
- lo_send(instance->ui_target,
- instance->ui_osc_configure_path,
- "ss", key, value);
- }
- */
+ if(instance->ui_target != NULL && x->is_dssi) {
+ SETSYMBOL(argv, gensym(instance->ui_osc_configure_path));
+ SETSYMBOL(argv+1, gensym(key));
+ SETSYMBOL(argv+2, gensym(value));
+ ph_instance_send_osc(x->message_out, instance, argc, argv);
+ }
ph_query_programs(x, i);
return debug;
@@ -787,13 +702,102 @@ void ph_instance_send_osc(t_outlet *outlet, ph_instance *instance,
}
+void ph_load_gui(ph *x, unsigned int i)
+{
+ t_int err = 0;
+ char *gui_path = NULL;
+ struct dirent *dir_entry = NULL;
+ char *gui_base = NULL;
+ size_t baselen;
+ DIR *dp = NULL;
+ char *gui_str = NULL;
+ char *osc_url = NULL;
+ ph_instance *instance = &x->instances[i];
+
+ gui_base = (char *)malloc((baselen = sizeof(char) * (strlen(x->plugin_full_path) - strlen(".so"))) + 1);
+
+ strncpy(gui_base, x->plugin_full_path, baselen);
+ gui_base[baselen] = '\0';
+
+ /* don't use strndup - GNU only */
+ /* gui_base = strndup(x->plugin_full_path, baselen);*/
+ ph_debug_post("gui_base: %s", gui_base);
+
+
+ gui_str = (char *)malloc(sizeof(char) * (strlen("channel 00") + 1));
+ sprintf (gui_str,"channel %02d", i);
+
+ ph_debug_post("GUI name string, %s", gui_str);
+
+
+ if(!(dp = opendir(gui_base))){
+ post("pluginhost~: unable to find GUI in %s, continuing without...", gui_base);
+ return;
+ }
+ else {
+ while((dir_entry = readdir(dp))){
+ if (dir_entry->d_name[0] == '.') continue;
+ if (strchr(dir_entry->d_name, '_')){
+ if (strstr(dir_entry->d_name, "gtk") ||
+ strstr(dir_entry->d_name, "qt") ||
+ strstr(dir_entry->d_name, "text"))
+ break;
+ }
+ }
+ ph_debug_post("GUI filename: %s", dir_entry->d_name);
+
+ }
+
+ gui_path = (char *)malloc(sizeof(char) * (strlen(gui_base) + strlen("/") +
+ strlen(dir_entry->d_name) + 1));
+
+ sprintf(gui_path, "%s/%s", gui_base, dir_entry->d_name);
+
+ free(gui_base);
+ ph_debug_post("gui_path: %s", gui_path);
+
+
+ /* osc_url_base was of the form:
+ * osc.udp://127.0.0.1:9997/dssi
+ */
+ osc_url = (char *)malloc
+ (sizeof(char) * (strlen(x->osc_url_base) +
+ strlen(instance->osc_url_path) + 2));
+
+ sprintf(osc_url, "%s/%s", x->osc_url_base,
+ instance->osc_url_path);
+ post("pluginhost~: instance %d URL: %s",instance, osc_url);
+ ph_debug_post("Trying to open GUI!");
+
+
+ instance->gui_pid = fork();
+ if (instance->gui_pid == 0){
+ err = execlp(gui_path, gui_path, osc_url, dir_entry->d_name,
+ x->descriptor->LADSPA_Plugin->Label, gui_str, NULL);
+ perror("exec failed");
+ exit(1); /* terminates the process */
+ }
+
+ ph_debug_post("errorcode = %d", err);
+
+
+ free(gui_path);
+ free(osc_url);
+ free(gui_str);
+ if(dp){
+ ph_debug_post("directory handle closed = %d", closedir(dp));
+ }
+}
+
void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
{
- char *plugin_basename = NULL,
- *plugin_full_path = NULL,
- *tmpstr,
- *plugin_label,
- plugin_dir[MAXPDSTRING];
+ char *plugin_basename = NULL;
+ char *plugin_full_path = NULL;
+ char *tmpstr = NULL;
+ char *plugin_label = NULL;
+ LADSPA_Descriptor_Function ladspa_desc_func = NULL;
+ DSSI_Descriptor_Function dssi_desc_func = NULL;
+ char plugin_dir[MAXPDSTRING];
ph_debug_post("argc = %d", argc);
@@ -856,7 +860,9 @@ void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
tmpstr = &plugin_dir[pathlen];
sprintf(tmpstr, "/%s", plugin_basename);
tmpstr = plugin_dir;
+ ph_debug_post("plugin full path is %s", tmpstr);
x->plugin_handle = loadLADSPAPluginLibrary(tmpstr);
+ ph_debug_post("plugin handle address: %p", x->plugin_handle);
} else {
/* try to load as is: this will work if plugin_full_path is an
* absolute path, or the name of a library that is in DSSI_PATH
@@ -873,7 +879,7 @@ void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
tmpstr = strdup(plugin_full_path);
/* Don't bother working out the plugin name if we used canvas_open()
* to get the path */
- if(plugin_basename == NULL){
+ if(fd < 0){
if(!strstr(tmpstr, ".so")){
pd_error(x, "invalid plugin path, must end in .so");
return x;
@@ -886,16 +892,34 @@ void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
ph_debug_post("plugin basename = %s", x->plugin_basename);
}
free(tmpstr);
- if((x->desc_func = (DSSI_Descriptor_Function)dlsym(x->plugin_handle,
- "dssi_descriptor"))){
+ dssi_desc_func = (DSSI_Descriptor_Function)dlsym(x->plugin_handle,
+ "dssi_descriptor");
+
+ if(!dssi_desc_func){
+ pd_error(x, "Couldn't get DSSI descriptor function: %s\n",
+ dlerror());
+
+ ladspa_desc_func = (LADSPA_Descriptor_Function)dlsym(x->plugin_handle,
+ "ladspa_descriptor");
+
+ if(!ladspa_desc_func){
+ pd_error(x, "Couldn't get LADSPA descriptor function: %s\n",
+ dlerror());
+ }
+ }
+
+ if(dssi_desc_func){
x->is_dssi = true;
- x->descriptor = (DSSI_Descriptor *)x->desc_func(0);
+ x->descriptor = (DSSI_Descriptor *)dssi_desc_func(0);
}
- else if((x->desc_func =
- (DSSI_Descriptor_Function)dlsym(x->plugin_handle,
- "ladspa_descriptor"))){
+ else if(ladspa_desc_func){
x->is_dssi = false;
- x->descriptor = ladspa_to_dssi((LADSPA_Descriptor *)x->desc_func(0));
+ x->descriptor = ladspa_to_dssi((LADSPA_Descriptor *)ladspa_desc_func(0));
+ }
+
+ if(!x->descriptor){
+ pd_error(x, "error: couldn't get plugin descriptor");
+ return x;
}
if(argc >= 2) {
@@ -906,15 +930,10 @@ void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
ph_debug_post("n_instances = %d", x->n_instances);
- x->instances = (ph_instance *)malloc(sizeof(ph_instance) *
+ x->instances = (ph_instance *)malloc(sizeof(ph_instance) *
x->n_instances);
- if(!x->descriptor){
- pd_error(x, "error: couldn't get plugin descriptor");
- return x;
- }
-
- ph_debug_post("%s loaded successfully!",
+ ph_debug_post("%s loaded successfully!",
x->descriptor->LADSPA_Plugin->Label);
x->port_info = (ph_port_info *)malloc
@@ -946,10 +965,9 @@ void *ph_load_plugin(ph *x, t_int argc, t_atom *argv)
if(x->is_dssi){
for(i = 0;i < x->n_instances; i++)
osc_setup(x, i);
-#if LOADGUI
+
for(i = 0;i < x->n_instances; i++)
ph_load_gui(x, i);
-#endif
for(i = 0;i < x->n_instances; i++)
ph_init_programs(x, i);
@@ -1053,13 +1071,11 @@ void ph_free_plugin(ph *x)
while(i--){
ph_instance *instance = &x->instances[i];
- /* TODO:OSC */
- /*
- if(instance->gui_pid){
- ph_debug_post("Killing GUI process PID = %d", instance->gui_pid);
+ if(instance->gui_pid){
+ ph_debug_post("Killing GUI process PID = %d", instance->gui_pid);
- kill(instance->gui_pid, SIGINT);
- } */
+ kill(instance->gui_pid, SIGINT);
+ }
if (instance->plugin_pgms) {
for (n = 0; n < instance->plugin_pgm_count; n++) {
free((void *)instance->plugin_pgms[n].Name);
diff --git a/pluginhost~/ph_common.h b/pluginhost~/ph_common.h
index 641c555..bed5751 100644
--- a/pluginhost~/ph_common.h
+++ b/pluginhost~/ph_common.h
@@ -58,6 +58,7 @@ typedef struct _ph_instance {
int ui_show;
t_atom ui_target[UI_TARGET_ELEMS]; /* host, port */
uint8_t perf_buffer[DX7_PERFORMANCE_SIZE];
+ pid_t gui_pid;
int *plugin_port_ctlin_numbers; /*not sure if this should go here?*/
@@ -127,7 +128,6 @@ typedef struct _ph {
unsigned long *plugin_ctlin_port_numbers;
unsigned char channel_map[128];
- DSSI_Descriptor_Function desc_func;
DSSI_Descriptor *descriptor;
LADSPA_Handle *instance_handles;
@@ -149,6 +149,7 @@ void ph_debug_post(const char *fmt, ...);
void ph_quit_plugin(ph *x);
void ph_init_plugin(ph *x);
void ph_free_plugin(ph *x);
+void ph_load_gui(ph *x, unsigned int i);
void ph_query_programs(ph *x, unsigned int i);
void ph_program_change(ph *x, unsigned int i);
void ph_instance_send_osc(t_outlet *outlet, ph_instance *instance,