wavedata-based plugins fail if reloaded with different SR
Plugins (like e.g. "sawtooth") that load wavedata using the "wdatutil" store the sample rate in global/static variables. When an Lv2 host calls lilv_plugin_instantiate
, then lilv_instance_free
and then again lilv_plugin_instantiate
, but the second instantiate uses a different sample rate, the code will crash.
This behavior is explained in a code comment in wdatuil.c. The comment says that it should not cause any trouble. However, it is common that an Lv2 host needs to re-instantiate a plugin with different SR (e.g. WAV files use 44100 Hz, but the system's SR can be different, so if a DAW switches from playback to record, this leads to crashes).
A solution is probably to eliminate such global/static variables like sample_rate
in the code generated from wdatutil.c
. On IRC, you also proposed "removing the magic shared library constructors".