(FULL) not-yet-complete JACK session management patch (TODO: get program name, vary...
[ardour.git] / libs / ardour / session_state.cc
index 4c0dcfd72d51735c5d7b91fe9ba0581327b00d8a..22a9100b319e602d65e27010bf02d51ea7fcad30 100644 (file)
@@ -270,10 +270,8 @@ Session::first_stage_init (string fullpath, string snapshot_name)
 
        /* These are all static "per-class" signals */
 
-       RegionFactory::CheckNewRegion.connect_same_thread (*this, boost::bind (&Session::add_region, this, _1));
        SourceFactory::SourceCreated.connect_same_thread (*this, boost::bind (&Session::add_source, this, _1));
        PlaylistFactory::PlaylistCreated.connect_same_thread (*this, boost::bind (&Session::add_playlist, this, _1, _2));
-       Processor::ProcessorCreated.connect_same_thread (*this, boost::bind (&Session::add_processor, this, _1));
        AutomationList::AutomationListCreated.connect_same_thread (*this, boost::bind (&Session::add_automation_list, this, _1));
        Controllable::Destroyed.connect_same_thread (*this, boost::bind (&Session::remove_controllable, this, _1));
        IO::PortCountChanged.connect_same_thread (*this, boost::bind (&Session::ensure_buffers, this, _1));
@@ -727,6 +725,35 @@ Session::remove_state (string snapshot_name)
        sys::remove (xml_path);
 }
 
+#ifdef HAVE_JACK_SESSION
+void
+Session::jack_session_event( jack_session_event_t * event )
+{
+       if (save_state ("jacksession_snap")) {
+                event->flags = JackSessionSaveError; 
+       } else {
+                sys::path xml_path (_session_dir->root_path());
+                xml_path /= legalize_for_path ("jacksession_snap") + statefile_suffix;
+                
+                string cmd ("PROG_NAME -U ");
+                cmd += event->client_uuid;
+                cmd += ' \"';
+                cmd += xml_path.to_string();
+                cmd += '\"';
+                
+                event->command_line = strdup (cmd.c_str());
+       }
+
+       jack_session_reply (_engine.jack(), event);
+
+       if (event->type == JackSessionSaveAndQuit) {
+                // TODO: make ardour quit.
+       }
+
+       jack_session_event_free( event );
+}
+#endif
+
 int
 Session::save_state (string snapshot_name, bool pending)
 {