free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.77k stars 100 forks source link

There are no documented invariants for clap_plugin_entry::deinit() #116

Closed robbert-vdh closed 2 years ago

robbert-vdh commented 2 years ago

It would make sense to me that calling this function is only ever valid after init() has returned true:

https://github.com/free-audio/clap/blob/55ee06f776669b94d63247a9c1dcb7dfa6056587/include/clap/entry.h#L33-L46

And as a related question, are plugins supposed to do reference counting in init()/deinit()? Can I call init() more than once? (and then call deinit() the same number of times afterwards)

abique commented 2 years ago

So deinit() says that no more calls must be made into the DSO once it is called. So you're not allowed to call it twice.

Same for init(), the host must call it only once, because init() may overwrite data that are in use by a previously created plugin instance.

abique commented 2 years ago

Ah regarding deinit(), I'm not sure if should be called if init() returned false.

robbert-vdh commented 2 years ago

Yeah it seemed logical to me that you wouldn't be able to do it (how can you deinitialize something that hasn't been initialized?). But @tim-janik thought otherwise, hence this issue.

abique commented 2 years ago

I'd say that if init() failed, then the host must not call deinit() nor any other clap related symbols from the DSO.