tweak a-fluidsynth reinit strategy.
authorRobin Gareus <robin@gareus.org>
Wed, 24 Aug 2016 11:01:40 +0000 (13:01 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 24 Aug 2016 11:05:47 +0000 (13:05 +0200)
reset synth in offline thread, queue panic on deactivate to be
called in run() after first re-activate.

Initial activation does not warrant a panic.

libs/plugins/a-fluidsynth.lv2/a-fluidsynth.c

index 11015b5ba14e34dc6ed6cfbd18c0243adbc9fbef..79f5586e3f867b15f6d9dffcfb3213412228dac1 100644 (file)
@@ -281,7 +281,7 @@ instantiate (const LV2_Descriptor*     descriptor,
 
        /* initialize plugin state */
 
-       self->panic = true;
+       self->panic = false;
        self->inform_ui = false;
        self->initialized = false;
        self->reinit_in_progress = false;
@@ -327,7 +327,7 @@ connect_port (LV2_Handle instance,
 }
 
 static void
-activate (LV2_Handle instance)
+deactivate (LV2_Handle instance)
 {
        AFluidSynth* self = (AFluidSynth*)instance;
        self->panic = true;
@@ -352,8 +352,6 @@ run (LV2_Handle instance, uint32_t n_samples)
        } else if (self->panic) {
                fluid_synth_all_notes_off (self->synth, -1);
                fluid_synth_all_sounds_off (self->synth, -1);
-               //fluid_synth_reset_reverb (self->synth);
-               //fluid_synth_reset_chorus (self->synth);
                self->panic = false;
        }
 
@@ -506,6 +504,13 @@ work (LV2_Handle                  instance,
        }
 
        self->initialized = load_sf2 (self, self->queue_sf2_file_path);
+
+       if (self->initialized) {
+               fluid_synth_all_notes_off (self->synth, -1);
+               fluid_synth_all_sounds_off (self->synth, -1);
+               self->panic = false;
+       }
+
        respond (handle, 1, "");
        return LV2_WORKER_SUCCESS;
 }
@@ -519,7 +524,6 @@ work_response (LV2_Handle  instance,
        self->reinit_in_progress = false;
        self->queue_reinit = false;
        self->inform_ui = true;
-       self->panic = true;
 
        if (self->initialized) {
                strcpy (self->current_sf2_file_path, self->queue_sf2_file_path);
@@ -607,9 +611,9 @@ static const LV2_Descriptor descriptor = {
        AFS_URN,
        instantiate,
        connect_port,
-       activate,
-       run,
        NULL,
+       run,
+       deactivate,
        cleanup,
        extension_data
 };