summaryrefslogtreecommitdiffstats
path: root/hosts/lv2_simple_jack_host.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-23 06:03:39 +0000
committerDavid Robillard <d@drobilla.net>2007-07-23 06:03:39 +0000
commit043e683a796e1338a8874b0e7c195292ff32b7de (patch)
treed580453b0d91ec7bdf304714ce52e9749a73db1d /hosts/lv2_simple_jack_host.c
parent64b48129d10118a9fbf11aec46fa557b5d302f31 (diff)
downloadlilv-043e683a796e1338a8874b0e7c195292ff32b7de.tar.gz
lilv-043e683a796e1338a8874b0e7c195292ff32b7de.tar.bz2
lilv-043e683a796e1338a8874b0e7c195292ff32b7de.zip
Broke API to separate input/output from type (less code repetition and SLV2 is more useful with unknown extended port types this way).
Switched enum symbol naming scheme to be more typical and future proof. Added LV2 OSC support. git-svn-id: http://svn.drobilla.net/lad/slv2@600 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'hosts/lv2_simple_jack_host.c')
-rw-r--r--hosts/lv2_simple_jack_host.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/hosts/lv2_simple_jack_host.c b/hosts/lv2_simple_jack_host.c
index d0fabc1..4b1bcc3 100644
--- a/hosts/lv2_simple_jack_host.c
+++ b/hosts/lv2_simple_jack_host.c
@@ -160,32 +160,34 @@ create_port(struct JackHost* host,
host->jack_ports[index] = NULL;
host->controls[index] = 0.0f;
- /* Get the 'class' of the port (control input, audio output, etc) */
- SLV2PortClass class = slv2_port_get_class(host->plugin, port);
+ /* Get the direction of the port (input, output) */
+ SLV2PortDirection direction = slv2_port_get_direction(host->plugin, port);
- /* Connect the port based on it's 'class' */
- switch (class) {
- case SLV2_CONTROL_INPUT:
- host->controls[index] = slv2_port_get_default_value(host->plugin, port);
- slv2_instance_connect_port(host->instance, index, &host->controls[index]);
- printf("Set %s to %f\n", symbol, host->controls[index]);
- break;
- case SLV2_CONTROL_OUTPUT:
+ /* Get the (data) type of the port (control, audio, MIDI, OSC) */
+ SLV2PortType type = slv2_port_get_type(host->plugin, port);
+
+ /* Connect control ports to controls array */
+ if (type == SLV2_PORT_TYPE_CONTROL) {
+
+ /* Set default control values for inputs */
+ if (direction == SLV2_PORT_DIRECTION_INPUT) {
+ host->controls[index] = slv2_port_get_default_value(host->plugin, port);
+ printf("Set %s to %f\n", symbol, host->controls[index]);
+ }
+
slv2_instance_connect_port(host->instance, index, &host->controls[index]);
- break;
- case SLV2_AUDIO_INPUT:
- host->jack_ports[index] = jack_port_register(host->jack_client,
- symbol, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
- break;
- case SLV2_AUDIO_OUTPUT:
- host->jack_ports[index] = jack_port_register(host->jack_client,
- symbol, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
- break;
- default:
+
+ } else if (type == SLV2_PORT_TYPE_AUDIO) {
+
+ host->jack_ports[index] = jack_port_register(host->jack_client, symbol,
+ JACK_DEFAULT_AUDIO_TYPE,
+ (direction == SLV2_PORT_DIRECTION_INPUT) ? JackPortIsInput : JackPortIsOutput, 0);
+
+ } else {
// Simple examples don't have to be robust :)
- die("ERROR: Unknown port type, aborting messily!");
+ die("ERROR: Unknown port type, aborting messily!\n");
}
-
+
free(symbol);
}