Re: [linux-audio-dev] LADSPA Update, New Project (CMT) & Help Requested

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] LADSPA Update, New Project (CMT) & Help Requested
From: David Benson (daveb_AT_idealab.com)
Date: Fri May 05 2000 - 03:56:27 EEST


> If I just want to know how many labels the plug-in has, do I really
> need to get every descriptor (plenty of mallocs and frees)?

Yes. (malloc and free are dwarfed by the time it takes to
dlopen or your system's equivalent...
obviously if the relevant strings are
accessed via a c-api this is necessary)

The real problem is that there is no way to unload a ladspa descriptor.
Even then, you should be able to make your plugin
not allocate memory when ladspa_descriptor(index) is called:

        LADSPA_Descriptor* ladspa_desriptor(int id)
        {
            static LADSPA_Descriptor plugin_1 = {
                    ....
            };
            static LADSPA_Descriptor plugin_2 = {
                    ....
            };
            if (id == 0)
                return &plugin_1;
            if (id == 1)
                return &plugin_2;
            return NULL;
        }

but I don't think any plugins are written this way.

> It would be nice to have a function which tells how many there are,
> or have the ladspa_descriptor(unsigned long Index) return the number
> of labels when Index == -1.

The current mechanism works, is equally general,
and is way faster than the call to dlopen().

> A minor thing: dlsym() on error seems to need more code than written
> in example hosts. See dlsym() manual page. My code is following:
>
> func = dlsym(dlhandle,"ladspa_descriptor");
> if (func == NULL) {
> /* check if we really got an error */
> error = dlerror(); /* save because next call to dlerror() returns NULL */
> if (error != NULL) {
> /* my error code deleted */
> }
> /* else the NULL is a valid function address */
> }

No, NULL is never a valid function address. However some architectures
allow you to export NULL as a symbol in a .so. Such a plugin would be bogus
and cause the host to crash. (Of course, the hosts stability
is always at the mercy of the plugins, so how you react to an
invalid plugin is not really relevant)

- Dave


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Fri May 05 2000 - 04:36:23 EEST