[SCM] calf/master: Improve LADISH level 1 integration. Doxygenize host_session a little bit.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:30 UTC 2013


The following commit has been merged in the master branch:
commit 333d8bbc6d26d31d5177683f4931d76ff2bf7e01
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Dec 26 20:26:06 2010 +0000

    Improve LADISH level 1 integration. Doxygenize host_session a little bit.
    
    Add a message to stdout after saving on SIGUSR1. Add a --state option to
    load a rack file if it exists, or to choose file name for the next save.

diff --git a/src/calf/host_session.h b/src/calf/host_session.h
index ae6d344..01e570f 100644
--- a/src/calf/host_session.h
+++ b/src/calf/host_session.h
@@ -36,9 +36,23 @@ class host_session: public main_window_owner_iface, public calf_plugins::progres
 private:
     static host_session *instance;
 public:
-    std::string client_name, input_name, output_name, midi_name, load_name;
+    /// Requested JACK client name.
+    std::string client_name;
+    /// Template for input names.
+    std::string input_name;
+    /// Template for output names.
+    std::string output_name;
+    /// Template for MIDI port names.
+    std::string midi_name;
+    /// Name of the file to load at start.
+    std::string load_name;
+    /// Use load_name as session state name - doesn't signal an error if the file doesn't exist, but uses it for saving.
+    bool only_load_if_exists;
+    /// Plugins to create on startup, in create_plugins_from_list (based on command line).
     std::vector<std::string> plugin_names;
+    /// Requested presets for the plugins in plugin_names.
     std::map<int, std::string> presets;
+    /// Selected session manager (if any).
     session_manager_iface *session_manager;
     
     // these are not saved
diff --git a/src/calf/main_win.h b/src/calf/main_win.h
index b2da016..6d17aaf 100644
--- a/src/calf/main_win.h
+++ b/src/calf/main_win.h
@@ -85,8 +85,8 @@ namespace calf_plugins {
         void open_gui(plugin_ctl_iface *plugin);    
         void create();
         void open_file();
-        void save_file();
-        void save_file_as();
+        bool save_file();
+        bool save_file_as();
         void save_file_from_sighandler();
         void show_rack_ears(bool show);
     private:
diff --git a/src/host_session.cpp b/src/host_session.cpp
index 2c1ae1b..db5862b 100644
--- a/src/host_session.cpp
+++ b/src/host_session.cpp
@@ -25,6 +25,7 @@
 #include <calf/preset.h>
 #include <calf/main_win.h>
 #include <getopt.h>
+#include <sys/stat.h>
 
 using namespace std;
 using namespace calf_utils;
@@ -43,6 +44,7 @@ host_session::host_session()
     autoconnect_midi_index = -1;
     gui_win = NULL;
     session_manager = NULL;
+    only_load_if_exists = false;
 }
 
 std::string host_session::get_next_instance_name(const std::string &effect_name)
@@ -287,15 +289,31 @@ void host_session::connect()
         char *error = open_file(load_name.c_str());
         if (error)
         {
-            GtkWidget *widget = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Cannot load '%s': %s", load_name.c_str(), error);
-            gtk_dialog_run (GTK_DIALOG (widget));
-            gtk_widget_destroy (widget);
-            
-            g_free(error);
-            load_name = "";
+            bool suppress_error = false;
+            if (only_load_if_exists)
+            {
+                struct stat s;
+                int stat_result = stat(load_name.c_str(), &s);
+                if (stat_result == -1 && errno == ENOENT)
+                    suppress_error = true;
+            }
+            // If the file is optional and it didn't exist, suppress the error
+            if (suppress_error)
+            {
+                g_free(error);
+                // keep the load_name for any later save
+            }
+            else
+            {
+                GtkWidget *widget = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Cannot load '%s': %s", load_name.c_str(), error);
+                gtk_dialog_run (GTK_DIALOG (widget));
+                gtk_widget_destroy (widget);
+                
+                g_free(error);
+                load_name = "";
+            }
         }
-        else
-            main_win->current_filename = load_name;
+        main_win->current_filename = load_name;
     }
     if (session_manager)
         session_manager->connect("calf-" + client_name);
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 9cb9c76..0ed8a6f 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -273,6 +273,7 @@ static struct option long_options[] = {
     {"load", 1, 0, 'l'},
     {"input", 1, 0, 'i'},
     {"output", 1, 0, 'o'},
+    {"state", 1, 0, 's'},
     {"connect-midi", 1, 0, 'M'},
     {0,0,0,0},
 };
@@ -280,7 +281,7 @@ static struct option long_options[] = {
 void print_help(char *argv[])
 {
     printf("JACK host for Calf effects\n"
-        "Syntax: %s [--client <name>] [--input <name>] [--output <name>] [--midi <name>] [--load <session>]\n"
+        "Syntax: %s [--client <name>] [--input <name>] [--output <name>] [--midi <name>] [--load|state <session>]\n"
         "       [--connect-midi <name|capture-index>] [--help] [--version] [!] pluginname[:<preset>] [!] ...\n", 
         argv[0]);
 }
@@ -298,7 +299,7 @@ int main(int argc, char *argv[])
 #endif
     while(1) {
         int option_index;
-        int c = getopt_long(argc, argv, "c:i:l:o:m:M:ehv", long_options, &option_index);
+        int c = getopt_long(argc, argv, "c:i:l:o:m:M:s:ehv", long_options, &option_index);
         if (c == -1)
             break;
         switch(c) {
@@ -325,6 +326,7 @@ int main(int argc, char *argv[])
                 sess.midi_name = string(optarg) + "_%d";
                 break;
             case 'l':
+            case 's':
             {
                 if (!g_path_is_absolute(optarg))
                 {
@@ -336,6 +338,7 @@ int main(int argc, char *argv[])
                 }
                 else
                     sess.load_name = optarg;
+                sess.only_load_if_exists = (c == 's');
                 break;
             }
             case 'M':
diff --git a/src/main_win.cpp b/src/main_win.cpp
index 6181aec..3a1dce9 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -578,6 +578,7 @@ gboolean main_window::on_idle(void *data)
     {
         self->save_file_on_next_idle_call = false;
         self->save_file();
+        printf("LADISH Level 1 support: file '%s' saved\n", self->current_filename.c_str());
     }
     for (std::map<plugin_ctl_iface *, plugin_strip *>::iterator i = self->plugins.begin(); i != self->plugins.end(); i++)
     {
@@ -630,20 +631,24 @@ void main_window::open_file()
     gtk_widget_destroy (dialog);
 }
 
-void main_window::save_file()
+bool main_window::save_file()
 {
-    if (!current_filename.empty()) {
-        const char *error = owner->save_file(current_filename.c_str());
-        if (error)
-            display_error(error, current_filename.c_str());
+    if (current_filename.empty())
+        return save_file_as();
+
+    const char *error = owner->save_file(current_filename.c_str());
+    if (error)
+    {
+        display_error(error, current_filename.c_str());
+        return false;
     }
-    else
-        save_file_as();
+    return true;
 }
 
-void main_window::save_file_as()
+bool main_window::save_file_as()
 {
     GtkWidget *dialog;
+    bool success = false;
     dialog = gtk_file_chooser_dialog_new ("Save File",
         toplevel,
         GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -657,11 +662,15 @@ void main_window::save_file_as()
         if (error) 
             display_error(error, filename);
         else
+        {
             current_filename = filename;
+            success = true;
+        }
         g_free (filename);
         free(error);
     }
     gtk_widget_destroy (dialog);
+    return success;
 }
 
 void main_window::display_error(const char *error, const char *filename)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list