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

Lars Luthman larsl at users.sourceforge.net
Wed Jun 29 11:42:22 UTC 2005


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20050629/7811b84f/attachment.pgp>


More information about the Linux-audio-dev mailing list