From 6a8890125eb77dac87324e197aab09e8e098a973 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 7 Jul 2011 20:13:12 +0000 Subject: Use enum for port indices (better type-safety and self-documentation). --- plugins/eg-amp.lv2/amp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'plugins/eg-amp.lv2') diff --git a/plugins/eg-amp.lv2/amp.c b/plugins/eg-amp.lv2/amp.c index 1f2b824..1a9dd94 100644 --- a/plugins/eg-amp.lv2/amp.c +++ b/plugins/eg-amp.lv2/amp.c @@ -1,6 +1,7 @@ /* LV2 Amp Example Plugin Copyright 2006-2011 Steve Harris, David Robillard. + Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. @@ -20,10 +21,13 @@ #include "lv2/lv2plug.in/ns/lv2core/lv2.h" -#define AMP_URI "http://lv2plug.in/plugins/eg-amp" -#define AMP_GAIN 0 -#define AMP_INPUT 1 -#define AMP_OUTPUT 2 +#define AMP_URI "http://lv2plug.in/plugins/eg-amp" + +typedef enum { + AMP_GAIN = 0, + AMP_INPUT = 1, + AMP_OUTPUT = 2 +} PortIndex; typedef struct { float* gain; @@ -49,7 +53,7 @@ connect_port(LV2_Handle instance, { Amp* amp = (Amp*)instance; - switch (port) { + switch ((PortIndex)port) { case AMP_GAIN: amp->gain = data; break; -- cgit v1.2.1