[SCM] calf/master: Implement LADISH level 1.

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


The following commit has been merged in the master branch:
commit c4bf666d5bfd222fd31c9a9f04e061e5764099a3
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sat May 1 17:37:16 2010 +0100

    Implement LADISH level 1.
    
    The SIGUSR1 handler sets a flag which causes Save function to be called from the
    idle handler called from the main loop.

diff --git a/src/calf/host_session.h b/src/calf/host_session.h
index aeffc18..ffc6827 100644
--- a/src/calf/host_session.h
+++ b/src/calf/host_session.h
@@ -31,8 +31,11 @@ namespace calf_plugins {
 
 class main_window;
 
-struct host_session: public main_window_owner_iface, public calf_plugins::progress_report_iface, public session_client_iface
+class host_session: public main_window_owner_iface, public calf_plugins::progress_report_iface, public session_client_iface
 {
+private:
+    static host_session *instance;
+public:
     std::string client_name, input_name, output_name, midi_name;
     std::vector<std::string> plugin_names;
     std::map<int, std::string> presets;
@@ -66,6 +69,9 @@ struct host_session: public main_window_owner_iface, public calf_plugins::progre
     /// Implementation of progress_report_iface function
     void report_progress(float percentage, const std::string &message);
     
+    /// Set handler for SIGUSR1 that LADISH uses to invoke Save function
+    void set_ladish_handler();
+    
     /// Implementation of open file functionality (TODO)
     virtual char *open_file(const char *name);
     /// Implementation of save file functionality
@@ -75,6 +81,9 @@ struct host_session: public main_window_owner_iface, public calf_plugins::progre
     virtual void load(session_load_iface *);
     /// Save to session manager
     virtual void save(session_save_iface *);
+    
+    /// SIGUSR1 handler
+    static void sigusr1handler(int signum);
 };
 
 };
diff --git a/src/calf/main_win.h b/src/calf/main_win.h
index 5422d9a..d19c0f9 100644
--- a/src/calf/main_win.h
+++ b/src/calf/main_win.h
@@ -60,6 +60,7 @@ namespace calf_plugins {
         std::string current_filename;
 
     protected:
+        volatile bool save_file_on_next_idle_call;
         plugin_strip *create_strip(plugin_ctl_iface *plugin);
         void update_strip(plugin_ctl_iface *plugin);
         static gboolean on_idle(void *data);
@@ -83,6 +84,7 @@ namespace calf_plugins {
         void open_file();
         void save_file();
         void save_file_as();
+        void save_file_from_sighandler();
     private:
         static const GtkActionEntry actions[];
         static void on_open_action(GtkWidget *widget, main_window *main);
diff --git a/src/host_session.cpp b/src/host_session.cpp
index 9d94a01..307a6ba 100644
--- a/src/host_session.cpp
+++ b/src/host_session.cpp
@@ -32,6 +32,8 @@ using namespace calf_plugins;
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+host_session *host_session::instance = NULL;
+
 host_session::host_session()
 {
     client_name = "calf";
@@ -448,3 +450,19 @@ void host_session::save(session_save_iface *stream)
     }
 }
 
+void host_session::sigusr1handler(int signum)
+{
+    instance->main_win->save_file_from_sighandler();
+}
+
+void host_session::set_ladish_handler()
+{
+    instance = this;
+    
+    struct sigaction sa;
+    sa.sa_handler = sigusr1handler;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_RESTART;
+    sigaction(SIGUSR1, &sa, NULL);
+    
+}
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 7f53bdc..b3cb0b1 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -359,7 +359,9 @@ int main(int argc, char *argv[])
         sess.open();
         sess.connect();
         sess.client.activate();
+        sess.set_ladish_handler();
         gtk_main();
+        
         sess.close();
         // this is now done on preset add
         // save_presets(get_preset_filename().c_str());
diff --git a/src/main_win.cpp b/src/main_win.cpp
index bb7abdd..7cc3c4f 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -517,6 +517,11 @@ static inline float LVL(float value)
 gboolean main_window::on_idle(void *data)
 {
     main_window *self = (main_window *)data;
+    if (self->save_file_on_next_idle_call)
+    {
+        self->save_file_on_next_idle_call = false;
+        self->save_file();
+    }
     for (std::map<plugin_ctl_iface *, plugin_strip *>::iterator i = self->plugins.begin(); i != self->plugins.end(); i++)
     {
         if (i->second)
@@ -540,6 +545,11 @@ gboolean main_window::on_idle(void *data)
     return TRUE;
 }
 
+void main_window::save_file_from_sighandler()
+{
+    save_file_on_next_idle_call = true;
+}
+
 void main_window::open_file()
 {
     GtkWidget *dialog;

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list