On Wed, Jun 29, 2005 at 01:57:58PM +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.
This is a *horribly complicated* way of doing something that could be
so simple. You need just one malloc() [1] and one free [2], and the
whole of init() including all the strdup() calls can be replaced by
some static declarations.
If you want to see some examples of this, get any of the plugins at
<users.skynet.be/solaris/linuxaudio> and have a look at one of the
*_if.cc files. The plugins are C++, but to convert this to C would be
trivial, and most of the *_if.cc is plain C anyway.
[1] in instantiate(), to allocate a struct that contains all the data
for one instance, i.e. port pointers and any state that must be kept
between calls to run().
[2] in cleanup(), to release the same.
--
FA