[SCM] calf/master: + Framework: provide plugins with a mechanism to return status in form of string variables

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:28 UTC 2013


The following commit has been merged in the master branch:
commit 1eeb4d4095eec266b5089cc6c0d0a99479dc24e2
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Mon Mar 16 00:00:34 2009 +0000

    + Framework: provide plugins with a mechanism to return status in form of string variables

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 4b0be2b..e788b82 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -249,6 +249,17 @@ struct send_configure_iface
     virtual ~send_configure_iface() {}
 };
 
+/// 'may receive new status values' interface
+struct send_updates_iface
+{
+    /// Called to set configure variable
+    /// @param key variable name
+    /// @param value variable content
+    virtual void send_status(const char *key, const char *value) = 0;
+    
+    virtual ~send_updates_iface() {}
+};
+
 struct plugin_command_info;
 
 /// General information about the plugin - @todo XXXKF lacks the "new" id-label-name triple
@@ -339,6 +350,12 @@ struct plugin_ctl_iface: public virtual plugin_metadata_iface
     virtual void send_configures(send_configure_iface *)=0;
     /// Restore all state (parameters and configure vars) to default values - implemented in giface.cpp
     virtual void clear_preset();
+    /// Call a named function in a plugin - this will most likely be redesigned soon - and never used
+    /// @retval false call has failed, result contains an error message
+    virtual bool blobcall(const char *command, const std::string &request, std::string &result) { result = "Call not supported"; return false; }
+    /// Update status variables changed since last_serial
+    /// @return new last_serial
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial) { return last_serial; }
     /// Do-nothing destructor to silence compiler warning
     virtual ~plugin_ctl_iface() {}
 };
@@ -389,8 +406,10 @@ public:
     inline void execute(int cmd_no) {}
     /// DSSI configure call
     virtual char *configure(const char *key, const char *value) { return NULL; }
-    /// Send all understood configure vars
+    /// Send all understood configure vars (none by default)
     inline void send_configures(send_configure_iface *sci) {}
+    /// Send all supported status vars (none by default)
+    inline int send_status_updates(send_updates_iface *sui, int last_serial) { return last_serial; }
     /// Reset parameter values for epp:trigger type parameters (ones activated by oneshot push button instead of check box)
     inline void params_reset() {}
     /// Called after instantiating (after all the feature pointers are set - including interfaces like progress_report_iface)
diff --git a/src/calf/gui.h b/src/calf/gui.h
index d7655a2..9dbbd6e 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -51,6 +51,7 @@ struct control_base
 struct param_control: public control_base
 {    
     int param_no;
+    std::string param_variable;
     GtkWidget *label, *widget;
     int in_change;
     
@@ -140,11 +141,12 @@ struct label_param_control: public param_control
 };
 
 /// Display-only control: value text
-struct value_param_control: public param_control
+struct value_param_control: public param_control, public send_updates_iface
 {
     virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
     virtual void get() {}
     virtual void set();
+    virtual void send_status(const char *key, const char *value);
 };
 
 /// Display-only control: volume meter
@@ -296,7 +298,7 @@ struct filechooser_param_control: public param_control, public send_configure_if
 
 class plugin_gui_window;
 
-class plugin_gui: public send_configure_iface
+class plugin_gui: public send_configure_iface, public send_updates_iface
 {
 protected:
     int param_count;
@@ -307,6 +309,7 @@ protected:
     control_container *top_container;
     std::map<std::string, int> param_name_map;
     int ignore_stack;
+    int last_status_serial_no;
 public:
     plugin_gui_window *window;
     GtkWidget *container;
@@ -324,7 +327,10 @@ public:
     void refresh(int param_no, param_control *originator = NULL);
     void xml_element_start(const char *element, const char *attributes[]);
     void set_param_value(int param_no, float value, param_control *originator = NULL);
+    /// Called on change of configure variable
     void send_configure(const char *key, const char *value);
+    /// Called on change of status variable
+    void send_status(const char *key, const char *value);
     void on_idle();
     ~plugin_gui();
     static void xml_element_start(void *data, const char *element, const char *attributes[]);
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index fdf557d..3223eb8 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -360,6 +360,9 @@ public:
     virtual void send_configures(send_configure_iface *sci) {
         Module::send_configures(sci);
     }
+    virtual int send_status_updates(send_updates_iface *sui, int last_serial) { 
+        return Module::send_status_updates(sui, last_serial);
+    }
 };
 
 extern jack_host_base *create_jack_host(const char *name, const std::string &instance_name, calf_plugins::progress_report_iface *priface);
diff --git a/src/gui.cpp b/src/gui.cpp
index 8274886..746de21 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -221,21 +221,43 @@ GtkWidget *label_param_control::create(plugin_gui *_gui, int _param_no)
 
 GtkWidget *value_param_control::create(plugin_gui *_gui, int _param_no)
 {
-    gui = _gui, param_no = _param_no;
-    parameter_properties &props = get_props();
+    gui = _gui;
+    param_no = _param_no;
+    
     widget = gtk_label_new ("");
-    gtk_label_set_width_chars (GTK_LABEL (widget), props.get_char_count());
+    if (param_no != -1)
+    {
+        parameter_properties &props = get_props();
+        gtk_label_set_width_chars (GTK_LABEL (widget), props.get_char_count());
+    }
+    else
+    {
+        require_attribute("key");
+        require_int_attribute("width");
+        param_variable = attribs["key"];
+        gtk_label_set_width_chars (GTK_LABEL (widget), get_int("width"));        
+    }
     gtk_misc_set_alignment (GTK_MISC (widget), get_float("align-x", 0.5), get_float("align-y", 0.5));
     return widget;
 }
 
 void value_param_control::set()
 {
+    if (param_no == -1)
+        return;
     _GUARD_CHANGE_
     parameter_properties &props = get_props();
     gtk_label_set_text (GTK_LABEL (widget), props.to_string(gui->plugin->get_param_value(param_no)).c_str());    
 }
 
+void value_param_control::send_status(const char *key, const char *value)
+{
+    if (key == param_variable)
+    {
+        gtk_label_set_text (GTK_LABEL (widget), value);    
+    }
+}
+
 // VU meter
 
 GtkWidget *vumeter_param_control::create(plugin_gui *_gui, int _param_no)
@@ -605,9 +627,15 @@ line_graph_param_control::~line_graph_param_control()
 /******************************** GUI proper ********************************/
 
 plugin_gui::plugin_gui(plugin_gui_window *_window)
-: window(_window)
+: last_status_serial_no(0)
+, window(_window)
 {
-    
+    ignore_stack = 0;
+    top_container = NULL;
+    current_control = NULL;
+    param_count = 0;
+    container = NULL;
+    effect_name = NULL;
 }
 
 static void window_destroyed(GtkWidget *window, gpointer data)
@@ -944,6 +972,7 @@ GtkWidget *plugin_gui::create_from_xml(plugin_ctl_iface *_plugin, const char *xm
     }
     
     XML_ParserFree(parser);
+    last_status_serial_no = plugin->send_status_updates(this, 0);
     return GTK_WIDGET(top_container->container);
 }
 
@@ -959,29 +988,42 @@ void plugin_gui::send_configure(const char *key, const char *value)
     }
 }
 
+void plugin_gui::send_status(const char *key, const char *value)
+{
+    // XXXKF this should really be replaced by a separate list of SUI-capable param controls
+    for (unsigned int i = 0; i < params.size(); i++)
+    {
+        assert(params[i] != NULL);
+        send_updates_iface *sui = dynamic_cast<send_updates_iface *>(params[i]);
+        if (sui)
+            sui->send_status(key, value);
+    }
+}
+
 void plugin_gui::on_idle()
 {
     for (unsigned int i = 0; i < params.size(); i++)
     {
-        parameter_properties &props = *plugin->get_param_props(params[i]->param_no);
-        bool is_output = (props.flags & PF_PROP_OUTPUT) != 0;
-        if (is_output) {
-            params[i]->set();
+        if (params[i]->param_no != -1)
+        {
+            parameter_properties &props = *plugin->get_param_props(params[i]->param_no);
+            bool is_output = (props.flags & PF_PROP_OUTPUT) != 0;
+            if (is_output) {
+                params[i]->set();
+            }
         }
         params[i]->on_idle();
     }    
+    last_status_serial_no = plugin->send_status_updates(this, last_status_serial_no);
     // XXXKF iterate over par2ctl, too...
 }
 
 void plugin_gui::refresh()
 {
     for (unsigned int i = 0; i < params.size(); i++)
-    {
         params[i]->set();
-        send_configure_iface *sci = dynamic_cast<send_configure_iface *>(params[i]);
-        if (sci)
-            plugin->send_configures(sci);
-    }
+    plugin->send_configures(this);
+    last_status_serial_no = plugin->send_status_updates(this, last_status_serial_no);
 }
 
 void plugin_gui::refresh(int param_no, param_control *originator)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list