a few more if (_mmc) tests
[ardour.git] / libs / ardour / session.cc
index 94945b95c27f9457839bdfdfde4b0cb4d0788b1e..ea48f9c60fbb7a9f22cde0dee50a26aa77b2681c 100644 (file)
@@ -99,6 +99,7 @@
 #include "ardour/graph.h"
 
 #include "midi++/jack.h"
+#include "midi++/mmc.h"
 
 #include "i18n.h"
 
@@ -135,8 +136,7 @@ Session::Session (AudioEngine &eng,
        : _engine (eng),
          _target_transport_speed (0.0),
          _requested_return_frame (-1),
-         mmc (0),
-         _mmc_port (default_mmc_port),
+         _mmc (0),
          _mtc_port (default_mtc_port),
          _midi_port (default_midi_port),
          _midi_clock_port (default_midi_clock_port),
@@ -305,7 +305,7 @@ Session::destroy ()
 
        Crossfade::set_buffer_size (0);
 
-       delete mmc;
+       delete _mmc;
 
        /* not strictly necessary, but doing it here allows the shared_ptr debugging to work */
        playlists.reset ();
@@ -441,7 +441,7 @@ Session::when_engine_running ()
                snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1);
 
                shared_ptr<Bundle> c (new Bundle (buf, true));
-               c->add_channel (_("mono"));
+               c->add_channel (_("mono"), DataType::AUDIO);
                c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
 
                add_bundle (c);
@@ -454,9 +454,9 @@ Session::when_engine_running ()
                        char buf[32];
                        snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2);
                        shared_ptr<Bundle> c (new Bundle (buf, true));
-                       c->add_channel (_("L"));
+                       c->add_channel (_("L"), DataType::AUDIO);
                        c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
-                       c->add_channel (_("R"));
+                       c->add_channel (_("R"), DataType::AUDIO);
                        c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1));
 
                        add_bundle (c);
@@ -470,7 +470,7 @@ Session::when_engine_running ()
                snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1);
 
                shared_ptr<Bundle> c (new Bundle (buf, false));
-               c->add_channel (_("mono"));
+               c->add_channel (_("mono"), DataType::AUDIO);
                c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
 
                add_bundle (c);
@@ -484,9 +484,9 @@ Session::when_engine_running ()
                        snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2);
 
                        shared_ptr<Bundle> c (new Bundle (buf, false));
-                       c->add_channel (_("L"));
+                       c->add_channel (_("L"), DataType::AUDIO);
                        c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
-                       c->add_channel (_("R"));
+                       c->add_channel (_("R"), DataType::AUDIO);
                        c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1));
 
                        add_bundle (c);
@@ -961,7 +961,9 @@ Session::enable_record ()
        if (g_atomic_int_get (&_record_status) != Recording) {
                g_atomic_int_set (&_record_status, Recording);
                _last_record_location = _transport_frame;
-               deliver_mmc(MIDI::MachineControl::cmdRecordStrobe, _last_record_location);
+                if (_mmc) {
+                        _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
+                }
 
                if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
                        
@@ -987,19 +989,15 @@ Session::disable_record (bool rt_context, bool force)
 
                if ((!Config->get_latched_record_enable () && !play_loop) || force) {
                        g_atomic_int_set (&_record_status, Disabled);
+                        if (_mmc) {
+                                _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit));
+                        }
                } else {
                        if (rs == Recording) {
                                g_atomic_int_set (&_record_status, Enabled);
                        }
                }
 
-               // FIXME: timestamp correct? [DR]
-               // FIXME FIXME FIXME: rt_context?  this must be called in the process thread.
-               // does this /need/ to be sent in all cases?
-               if (rt_context) {
-                       deliver_mmc (MIDI::MachineControl::cmdRecordExit, _transport_frame);
-               }
-
                if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
 
                        boost::shared_ptr<RouteList> rl = routes.reader ();
@@ -1053,7 +1051,9 @@ Session::maybe_enable_record ()
                        enable_record ();
                }
        } else {
-               deliver_mmc (MIDI::MachineControl::cmdRecordPause, _transport_frame);
+                if (_mmc) {
+                        _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause));
+                }
                RecordStateChanged (); /* EMIT SIGNAL */
        }
 
@@ -1317,9 +1317,7 @@ Session::resort_routes ()
                return;
        }
 
-
        {
-
                RCUWriter<RouteList> writer (routes);
                shared_ptr<RouteList> r = writer.get_copy ();
                resort_routes_using (r);
@@ -1381,7 +1379,7 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
        RouteSorter cmp;
        r->sort (cmp);
 
-       route_graph->rechain( r );
+       route_graph->rechain (r);
 
 #ifndef NDEBUG
         DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
@@ -2081,7 +2079,7 @@ Session::remove_route (shared_ptr<Route> route)
 
                /* writer goes out of scope, forces route list update */
        }
-        
+
         update_route_solo_state ();
        update_session_range_location_marker ();
 
@@ -2105,6 +2103,11 @@ Session::remove_route (shared_ptr<Route> route)
        update_latency_compensation (false, false);
        set_dirty();
 
+        /* flush references out of the graph
+         */
+
+        route_graph->clear_other_chain ();
+
        /* get rid of it from the dead wood collection in the route list manager */
 
        /* XXX i think this is unsafe as it currently stands, but i am not sure. (pd, october 2nd, 2006) */