consolidate VST UI code
authorRobin Gareus <robin@gareus.org>
Tue, 15 Nov 2016 16:07:55 +0000 (17:07 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 15 Nov 2016 16:10:13 +0000 (17:10 +0100)
gtk2_ardour/linux_vst_gui_support.cc
gtk2_ardour/mac_vst_plugin_ui.mm

index fe85ea188ef5293f4fa67b9ac972f1626f0021ae..b310227403bdceab2b724bd0015dba568c405076 100644 (file)
@@ -302,31 +302,6 @@ dispatch_x_events (XEvent* event, VSTState* vstfx)
        vstfx->eventProc((void*)event);
 }
 
-static void
-maybe_set_program (VSTState* vstfx)
-{
-       if (vstfx->want_program != -1) {
-               if (vstfx->vst_version >= 2) {
-                       vstfx->plugin->dispatcher (vstfx->plugin, 67 /* effBeginSetProgram */, 0, 0, NULL, 0);
-               }
-
-               vstfx->plugin->dispatcher (vstfx->plugin, effSetProgram, 0, vstfx->want_program, NULL, 0);
-
-               if (vstfx->vst_version >= 2) {
-                       vstfx->plugin->dispatcher (vstfx->plugin, 68 /* effEndSetProgram */, 0, 0, NULL, 0);
-               }
-
-               vstfx->want_program = -1;
-       }
-
-       if (vstfx->want_chunk == 1) {
-               pthread_mutex_lock (&vstfx->state_lock);
-               vstfx->plugin->dispatcher (vstfx->plugin, 24 /* effSetChunk */, 1, vstfx->wanted_chunk_size, vstfx->wanted_chunk, 0);
-               vstfx->want_chunk = 0;
-               pthread_mutex_unlock (&vstfx->state_lock);
-       }
-}
-
 /** This is the main gui event loop for the plugin, we also need to pass
 any Xevents to all the UI callbacks plugins 'may' have registered on their
 windows, that is if they don't manage their own UIs **/
@@ -439,7 +414,7 @@ again:
                                        }
                                }
 
-                               maybe_set_program (vstfx);
+                               vststate_maybe_set_program (vstfx);
                                vstfx->want_program = -1;
                                vstfx->want_chunk = 0;
 
index a1803b6e60101be4430eb6ad0abd075a947ff0f4..5a20af8036cd91c333093e1d7decbb0d14c477ab 100644 (file)
@@ -156,26 +156,5 @@ MacVSTPluginUI::idle ()
 void
 MacVSTPluginUI::set_program ()
 {
-       VSTState* vstfx = _vst->state();
-
-       if (vstfx->want_program != -1) {
-               if (vstfx->vst_version >= 2) {
-                       vstfx->plugin->dispatcher (vstfx->plugin, 67 /* effBeginSetProgram */, 0, 0, NULL, 0);
-               }
-
-               vstfx->plugin->dispatcher (vstfx->plugin, effSetProgram, 0, vstfx->want_program, NULL, 0);
-
-               if (vstfx->vst_version >= 2) {
-                       vstfx->plugin->dispatcher (vstfx->plugin, 68 /* effEndSetProgram */, 0, 0, NULL, 0);
-               }
-
-               vstfx->want_program = -1;
-       }
-
-       if (vstfx->want_chunk == 1) {
-               pthread_mutex_lock (&vstfx->state_lock);
-               vstfx->plugin->dispatcher (vstfx->plugin, 24 /* effSetChunk */, 1, vstfx->wanted_chunk_size, vstfx->wanted_chunk, 0);
-               vstfx->want_chunk = 0;
-               pthread_mutex_unlock (&vstfx->state_lock);
-       }
+       vststate_maybe_set_program (_vst->state());
 }