Fixes: delete unused creaed objects whenn errors occurs or plugin in unloaded.

pull/2/head
Holger Wirtz 6 years ago
parent e142881822
commit bcff44c0a3
  1. 6
      src/Makefile
  2. 23
      src/dexed.cpp
  3. 1
      src/msfa/controllers.h

@ -1,8 +1,8 @@
BUNDLE=dexed.lv2
TARGET=dexed.so
#DEBUG=1
#FILETRACE=1
DEBUG=1
FILETRACE=1
INSTALL_DIR=/zynthian/zynthian-plugins/lv2
INSTALL_MYPLUGINS_DIR=/zynthian/zynthian-my-plugins/lv2
@ -88,7 +88,7 @@ $(BUNDLE): manifest.ttl Dexed.ttl modgui.ttl presets.ttl dexed.so
dexed.so: $(OBJ) dexed.o
$(CXX) dexed.o $(OBJ) $(LDFLAGS) -o dexed.so
dexed.o: Makefile dexed.cpp dexed.h dexed_ttl.h
dexed.o: Makefile dexed.cpp dexed.h dexed_ttl.h msfa/controllers.h
$(CXX) $(CXXFLAGS) -Wall -c dexed.cpp
trace.o: Makefile trace.c trace.h

@ -49,24 +49,30 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
Env::init_sr(rate);
fx.init(rate);
if((engineMkI=new EngineMkI)==NULL)
if(!(engineMkI=new EngineMkI))
{
TRACE("Cannot not create engine EngineMkI");
exit(400);
}
if((engineOpl=new EngineOpl)==NULL)
if(!(engineOpl=new EngineOpl))
{
if(engineMkI)
delete(engineMkI);
TRACE("Cannot not create engine EngineOpl");
exit(401);
}
if((engineMsfa=new FmCore)==NULL)
if(!(engineMsfa=new FmCore))
{
if(engineMkI)
delete(engineMkI);
if(engineOpl)
delete(engineOpl);
TRACE("Cannot create engine FmCore");
exit(402);
}
for(i=0; i<MAX_ACTIVE_NOTES; i++) {
if((voices[i].dx7_note = new Dx7Note)==NULL)
if(!(voices[i].dx7_note = new Dx7Note))
{
TRACE("Cannot create DX7Note [%d]",i);
exit(403);
@ -97,7 +103,7 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
bufsize_=256;
if((outbuf_=new float[bufsize_])==NULL)
if(!(outbuf_=new float[bufsize_]))
{
TRACE("Cannot create outbuf_ buffer");
exit(404);
@ -144,6 +150,13 @@ Dexed::~Dexed()
voices[note].live = false;
}
if(engineMsfa)
delete(engineMkI);
if(engineOpl)
delete(engineMkI);
if(engineMkI)
delete(engineMkI);
TRACE("Bye");
TRACE("--------------------------------------------------------------------------------");
}

@ -65,6 +65,7 @@ class Controllers {
void applyMod(int cc, FmMod &mod) {
float range = 0.01 * mod.range;
uint8_t total = cc * range;
TRACE("amp[%d]|pitch[%d]|eg[%d] %d",mod.amp,mod.pitch,mod.eg,total);
if(mod.amp)
amp_mod = max(amp_mod, total);

Loading…
Cancel
Save