full compilation and linking (coding not finished, will not run)
[ardour.git] / libs / ardour / session.cc
index 75303251d83138d824ee32b574063e389159779c..e1634db536ed980a8ea424e16f80ff3a415c27f0 100644 (file)
@@ -133,12 +133,14 @@ Session::Session (AudioEngine &eng,
        : _engine (eng)
        , _target_transport_speed (0.0)
        , _requested_return_frame (-1)
+       , _under_nsm_control (false)
        , _session_dir (new SessionDirectory(fullpath))
        , state_tree (0)
        , _state_of_the_state (Clean)
        , _butler (new Butler (*this))
        , _post_transport_work (0)
        , _send_timecode_update (false)
+       , ltc_enc_buf(0)
        , _all_route_group (new RouteGroup (*this, "all"))
        , routes (new RouteList)
        , _total_free_4k_blocks (0)
@@ -344,8 +346,8 @@ Session::when_engine_running ()
 
        BootMessage (_("Set block size and sample rate"));
 
-       set_block_size (_engine.frames_per_cycle());
-       set_frame_rate (_engine.frame_rate());
+       set_block_size (_engine.samples_per_cycle());
+       set_frame_rate (_engine.sample_rate());
 
        BootMessage (_("Using configuration"));
 
@@ -1597,7 +1599,7 @@ Session::find_route_name (string const & base, uint32_t& id, char* name, size_t
                }
 
                ++id;
-
+               
        } while (id < (UINT_MAX-1));
 
        return false;
@@ -1614,7 +1616,7 @@ Session::count_existing_track_channels (ChanCount& in, ChanCount& out)
 
        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
                 boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
-               if (tr && !tr->is_hidden()) {
+               if (tr && !tr->is_auditioner()) {
                        in  += tr->n_inputs();
                        out += tr->n_outputs();
                }
@@ -2036,12 +2038,13 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
 }
 
 RouteList
-Session::new_route_from_template (uint32_t how_many, const std::string& template_path)
+Session::new_route_from_template (uint32_t how_many, const std::string& template_path, const std::string& name_base)
 {
        RouteList ret;
        uint32_t control_id;
        XMLTree tree;
        uint32_t number = 0;
+       const uint32_t being_added = how_many;
 
        if (!tree.read (template_path.c_str())) {
                return ret;
@@ -2061,13 +2064,29 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
                node_copy.remove_property_recursively (X_("id"));
 
                try {
-                       string const route_name = node_copy.property(X_("name"))->value ();
-                       
-                       /* generate a new name by adding a number to the end of the template name */
                        char name[32];
-                       if (!find_route_name (route_name.c_str(), ++number, name, sizeof(name), true)) {
-                               fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
-                               /*NOTREACHED*/
+
+                       if (!name_base.empty()) {
+
+                               /* if we're adding more than one routes, force
+                                * all the names of the new routes to be
+                                * numbered, via the final parameter.
+                                */
+
+                               if (!find_route_name (name_base.c_str(), ++number, name, sizeof(name), (being_added > 1))) {
+                                       fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
+                                       /*NOTREACHDE*/
+                               }
+
+                       } else {
+
+                               string const route_name  = node_copy.property(X_("name"))->value ();
+                       
+                               /* generate a new name by adding a number to the end of the template name */
+                               if (!find_route_name (route_name.c_str(), ++number, name, sizeof(name), true)) {
+                                       fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
+                                       /*NOTREACHED*/
+                               }
                        }
 
                        /* set this name in the XML description that we are about to use */
@@ -2228,7 +2247,7 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
                */
 
                if (!r->has_order_key (EditorSort)) {
-                       if (r->is_hidden()) {
+                       if (r->is_auditioner()) {
                                /* use an arbitrarily high value */
                                r->set_order_key (EditorSort, UINT_MAX);
                                r->set_order_key (MixerSort, UINT_MAX);
@@ -2453,7 +2472,7 @@ Session::route_listen_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
                        /* new listen: disable all other listen */
                        boost::shared_ptr<RouteList> r = routes.reader ();
                        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-                               if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
+                               if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
                                        continue;
                                }
                                (*i)->set_listen (false, this);
@@ -2535,7 +2554,7 @@ Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_p
                /* new solo: disable all other solos, but not the group if its solo-enabled */
 
                for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-                       if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden() ||
+                       if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner() ||
                            (leave_group_alone && ((*i)->route_group() == rg))) {
                                continue;
                        }
@@ -2555,7 +2574,7 @@ Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_p
                bool via_sends_only;
                bool in_signal_flow;
 
-               if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden() ||
+               if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner() ||
                    (leave_group_alone && ((*i)->route_group() == rg))) {
                        continue;
                }
@@ -2644,11 +2663,11 @@ Session::update_route_solo_state (boost::shared_ptr<RouteList> r)
        }
 
        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-               if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_hidden() && (*i)->self_soloed()) {
+               if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_auditioner() && (*i)->self_soloed()) {
                        something_soloed = true;
                }
 
-               if (!(*i)->is_hidden() && (*i)->listening_via_monitor()) {
+               if (!(*i)->is_auditioner() && (*i)->listening_via_monitor()) {
                        if (Config->get_solo_control_is_listen_control()) {
                                listeners++;
                        } else {
@@ -4603,7 +4622,7 @@ Session::post_playback_latency ()
        boost::shared_ptr<RouteList> r = routes.reader ();
 
        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-               if (!(*i)->is_hidden() && ((*i)->active())) {
+               if (!(*i)->is_auditioner() && ((*i)->active())) {
                        _worst_track_latency = max (_worst_track_latency, (*i)->update_signal_latency ());
                }
        }
@@ -4709,7 +4728,7 @@ Session::update_latency_compensation (bool force_whole_graph)
        boost::shared_ptr<RouteList> r = routes.reader ();
 
        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-               if (!(*i)->is_hidden() && ((*i)->active())) {
+               if (!(*i)->is_auditioner() && ((*i)->active())) {
                        framecnt_t tl;
                        if ((*i)->signal_latency () != (tl = (*i)->update_signal_latency ())) {
                                some_track_latency_changed = true;