Re: [linux-audio-dev] help with multiple control ports

From: Lars Luthman <larsl@email-addr-hidden>
Date: Wed Jun 29 2005 - 14:42:22 EEST

On Wed, 2005-06-29 at 13:57 +0300, Artemio wrote:
> I have a problem with creating a plugin with more than one control
> port. In the attachment you'll find "booster-simple.c" which has one
> "Gain" port and my attempt to add a second port in "booster.c". For
> some reason the latter cannot be used - the sources seem to be
> correct, it compiles fine, but then if I test with "applyplugin" it
> segfaults and other hosts complain about a malloc() error and hang.

From booster.c:

#define BOOSTER_INPUT1 0
#define BOOSTER_OUTPUT1 1
#define BOOSTER_INPUT2 2
#define BOOSTER_OUTPUT2 3
#define BOOSTER_GAIN 4
#define BOOSTER_ASYMMETRY 5

...

g_psMonoDescriptor->PortCount = 4;
piPortDescriptors = (LADSPA_PortDescriptor *)calloc(4,
sizeof(LADSPA_PortDescriptor));
g_psMonoDescriptor->PortDescriptors
      = (const LADSPA_PortDescriptor *)piPortDescriptors;
          
piPortDescriptors[BOOSTER_GAIN] = LADSPA_PORT_INPUT|LADSPA_PORT_CONTROL;
piPortDescriptors[BOOSTER_ASYMMETRY] =
    LADSPA_PORT_INPUT|LADSPA_PORT_CONTROL;
piPortDescriptors[BOOSTER_INPUT1] = LADSPA_PORT_INPUT|LADSPA_PORT_AUDIO;
piPortDescriptors[BOOSTER_OUTPUT1] =
    LADSPA_PORT_OUTPUT|LADSPA_PORT_AUDIO;

First you set the PortCount to 4 and allocate an array of 4
LADSPA_PortDescriptor variables, and then you try to access index
BOOSTER_GAIN and BOOSTER_ASYMMETRY in the array, which are defined as 4
and 5. That is bound to cause all sorts of problems.

-- 
Lars Luthman
PGP key:     http://www.d.kth.se/~d00-llu/pgp_key.php
Fingerprint: FCA7 C790 19B9 322D EB7A  E1B3 4371 4650 04C7 7E2E

Received on Thu Jul 7 16:16:10 2005

This archive was generated by hypermail 2.1.8 : Thu Jul 07 2005 - 16:16:11 EEST