diff options
author | Stefan Kost <ensonic@users.sf.net> | 2010-01-31 22:21:42 +0200 |
---|---|---|
committer | Stefan Kost <ensonic@users.sf.net> | 2010-01-31 22:25:52 +0200 |
commit | 165847218302194d993e42822f4307cb5518a03d (patch) | |
tree | d24bdd7993d587a1b46cacd31c7a2bb06e4d289c | |
parent | 6bff8711d0e087e8b20507dd92c25850cdff3c18 (diff) |
lv2: simpify property registration
Avoid type cheking casts for each property. Use a running index.
-rw-r--r-- | ext/lv2/gstlv2.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/ext/lv2/gstlv2.c b/ext/lv2/gstlv2.c index cfc2f69b2..2dc157ec4 100644 --- a/ext/lv2/gstlv2.c +++ b/ext/lv2/gstlv2.c | |||
@@ -476,7 +476,8 @@ gst_lv2_class_init (GstLV2Class * klass, SLV2Plugin lv2plugin) | |||
476 | { | 476 | { |
477 | GObjectClass *gobject_class; | 477 | GObjectClass *gobject_class; |
478 | GstSignalProcessorClass *gsp_class; | 478 | GstSignalProcessorClass *gsp_class; |
479 | gint i; | 479 | GParamSpec *p; |
480 | gint i, ix; | ||
480 | 481 | ||
481 | GST_DEBUG ("class_init %p", klass); | 482 | GST_DEBUG ("class_init %p", klass); |
482 | 483 | ||
@@ -493,27 +494,23 @@ gst_lv2_class_init (GstLV2Class * klass, SLV2Plugin lv2plugin) | |||
493 | 494 | ||
494 | klass->plugin = lv2plugin; | 495 | klass->plugin = lv2plugin; |
495 | 496 | ||
496 | /* register properties */ | 497 | /* properties have an offset of 1 */ |
498 | ix = 1; | ||
497 | 499 | ||
498 | for (i = 0; i < gsp_class->num_control_in; i++) { | 500 | /* register properties */ |
499 | GParamSpec *p; | ||
500 | 501 | ||
502 | for (i = 0; i < gsp_class->num_control_in; i++, ix++) { | ||
501 | p = gst_lv2_class_get_param_spec (klass, | 503 | p = gst_lv2_class_get_param_spec (klass, |
502 | g_array_index (klass->control_in_ports, GstLV2Port, i).index); | 504 | g_array_index (klass->control_in_ports, GstLV2Port, i).index); |
503 | 505 | ||
504 | /* properties have an offset of 1 */ | 506 | g_object_class_install_property (gobject_class, ix, p); |
505 | g_object_class_install_property (G_OBJECT_CLASS (klass), i + 1, p); | ||
506 | } | 507 | } |
507 | 508 | ||
508 | for (i = 0; i < gsp_class->num_control_out; i++) { | 509 | for (i = 0; i < gsp_class->num_control_out; i++, ix++) { |
509 | GParamSpec *p; | ||
510 | |||
511 | p = gst_lv2_class_get_param_spec (klass, | 510 | p = gst_lv2_class_get_param_spec (klass, |
512 | g_array_index (klass->control_out_ports, GstLV2Port, i).index); | 511 | g_array_index (klass->control_out_ports, GstLV2Port, i).index); |
513 | 512 | ||
514 | /* properties have an offset of 1, and we already added num_control_in */ | 513 | g_object_class_install_property (gobject_class, ix, p); |
515 | g_object_class_install_property (G_OBJECT_CLASS (klass), | ||
516 | gsp_class->num_control_in + i + 1, p); | ||
517 | } | 514 | } |
518 | } | 515 | } |
519 | 516 | ||