Committed filthy mess of a working copy solely for moving between machines.
[ardour.git] / libs / ardour / session_state.cc
index 58f1d7c0a0aa68703d208c23fb915bceedd4de06..602ac943149fc845080a1a36035c40e4112bce43 100644 (file)
@@ -81,6 +81,7 @@
 #include <ardour/location.h>
 #include <ardour/audioregion.h>
 #include <ardour/crossfade.h>
+#include <ardour/control_protocol_manager.h>
 
 #include "i18n.h"
 #include <locale.h>
@@ -149,12 +150,13 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        state_was_pending = false;
        set_next_event ();
        outbound_mtc_smpte_frame = 0;
-       next_quarter_frame_to_send = -1;
+       next_quarter_frame_to_send = 0;
        current_block_size = 0;
        _solo_latched = true;
        _solo_model = InverseMute;
        solo_update_disabled = false;
        currently_soloing = false;
+       _have_captured = false;
        _worst_output_latency = 0;
        _worst_input_latency = 0;
        _worst_track_latency = 0;
@@ -165,7 +167,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        butler_gain_buffer = 0;
        auditioner = 0;
        mmc_control = false;
-       midi_feedback = false;
        midi_control = true;
        mmc = 0;
        post_transport_work = PostTransportWork (0);
@@ -183,7 +184,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        _master_out = 0;
        input_auto_connect = AutoConnectOption (0);
        output_auto_connect = AutoConnectOption (0);
-       _have_captured = false;
        waiting_to_start = false;
        _exporting = false;
        _gain_automation_buffer = 0;
@@ -297,13 +297,11 @@ Session::second_stage_init (bool new_session)
                return -1;
        }
 
+       /* FIXME
        if (start_midi_thread ()) {
                return -1;
        }
-
-       if (init_feedback ()) {
-               return -1;
-       }
+       */
 
        if (state_tree) {
                if (set_state (*state_tree->root())) {
@@ -340,11 +338,13 @@ Session::second_stage_init (bool new_session)
                first_time_running = _engine.Running.connect (mem_fun (*this, &Session::when_engine_running));
        }
 
-       send_full_time_code ();
+       // FIXME
+       //send_full_time_code ();
        _engine.transport_locate (0);
-       deliver_mmc (MIDI::MachineControl::cmdMmcReset, 0);
-       deliver_mmc (MIDI::MachineControl::cmdLocate, 0);
-       send_all_midi_feedback();
+       //deliver_mmc (MIDI::MachineControl::cmdMmcReset, 0);
+       //deliver_mmc (MIDI::MachineControl::cmdLocate, 0);
+
+       ControlProtocolManager::instance().set_session (*this);
 
        if (new_session) {
                _end_location_is_free = true;
@@ -765,11 +765,8 @@ Session::load_state (string snapshot_name)
                /* there is pending state from a crashed capture attempt */
 
                if (AskAboutPendingState()) {
-                       cerr << "use pending state\n";
                        state_was_pending = true;
-               } else {
-                       cerr << "do not use pending state\n";
-               }
+               } 
        } 
 
        if (!state_was_pending) {
@@ -1026,6 +1023,12 @@ Session::load_options (const XMLNode& node)
                }
        }
 
+       if ((child = find_named_node (node, "end-marker-is-free")) != 0) {
+               if ((prop = child->property ("val")) != 0) {
+                       _end_location_is_free = (prop->value() == "yes");
+               }
+       }
+
        if ((child = find_named_node (node, "layer-model")) != 0) {
                if ((prop = child->property ("val")) != 0) {
                        if (prop->value() == X_("LaterHigher")) {
@@ -1211,6 +1214,8 @@ Session::get_options () const
        child->add_property ("val", get_crossfades_active () ? "yes" : "no");
        child = opthead->add_child ("audible-click");
        child->add_property ("val", get_clicking () ? "yes" : "no");
+       child = opthead->add_child ("end-marker-is-free");
+       child->add_property ("val", _end_location_is_free ? "yes" : "no");
 
        if (click_sound.length()) {
                child = opthead->add_child ("click-sound");
@@ -2291,7 +2296,7 @@ Session::template_dir ()
 }
 
 string
-Session::template_path ()
+Session::suffixed_search_path (string suffix, bool data)
 {
        string path;
 
@@ -2299,7 +2304,12 @@ Session::template_path ()
        if (path[path.length()-1] != ':') {
                path += ':';
        }
-       path += get_system_ardour_path();
+
+       if (data) {
+               path += get_system_data_path();
+       } else {
+               path += get_system_module_path();
+       }
 
        vector<string> split_path;
        
@@ -2308,7 +2318,8 @@ Session::template_path ()
 
        for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) {
                path += *i;
-               path += "templates/";
+               path += suffix;
+               path += '/';
                
                if (distance (i, split_path.end()) != 1) {
                        path += ':';
@@ -2318,6 +2329,18 @@ Session::template_path ()
        return path;
 }
 
+string
+Session::template_path ()
+{
+       return suffixed_search_path (X_("templates"), true);
+}
+
+string
+Session::control_protocol_path ()
+{
+       return suffixed_search_path (X_("surfaces"), false);
+}
+
 int
 Session::load_connections (const XMLNode& node)
 {
@@ -2357,18 +2380,18 @@ Session::load_route_groups (const XMLNode& node, bool edit)
 {
        XMLNodeList nlist = node.children();
        XMLNodeConstIterator niter;
-       RouteGroup* route;
+       RouteGroup* rg;
 
        set_dirty();
 
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                if ((*niter)->name() == "RouteGroup") {
                        if (edit) {
-                               route = add_edit_group ("");
-                               route->set_state (**niter);
+                               rg = add_edit_group ("");
+                               rg->set_state (**niter);
                        } else {
-                               route = add_mix_group ("");
-                               route->set_state (**niter);
+                               rg = add_mix_group ("");
+                               rg->set_state (**niter);
                        }
                }
        }
@@ -3192,7 +3215,7 @@ void
 Session::set_dirty ()
 {
        bool was_dirty = dirty();
-       
+
        _state_of_the_state = StateOfTheState (_state_of_the_state | Dirty);
 
        if (!was_dirty) {