fixes from 2.X for latency/capture alignment stuff: don't reverse route list, update...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 21 Sep 2011 17:28:13 +0000 (17:28 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 21 Sep 2011 17:28:13 +0000 (17:28 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10110 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audioengine.h
libs/ardour/ardour/session.h
libs/ardour/audio_diskstream.cc
libs/ardour/audioengine.cc
libs/ardour/session.cc

index 05ca38e43b89ba57eebf734bfd042f375c218d9f..ee2276a3bf19cdace94b9e2cc1cda0d3090baee6 100644 (file)
@@ -205,6 +205,8 @@ public:
 
        int  reset_timebase ();
 
+        void update_latencies ();
+
        /* start/stop freewheeling */
 
        int freewheel (bool onoff);
index 2dbb2f08ac3bd0f4c6a39d4df43dc9f509ce8325..e41ea5a625646a807efcebec3fd4d00de70446f5 100644 (file)
@@ -904,6 +904,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        bool                    _writable;
        bool                    _was_seamless;
 
+       void initialize_latencies ();
        void set_worst_io_latencies ();
        void set_worst_playback_latency ();
        void set_worst_capture_latency ();
index f64a32513814354250d9708775b6466cc734e8ce..9ffadfd16b39f4aaa3c68a2cead0905edf235670 100644 (file)
@@ -491,21 +491,9 @@ AudioDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool ca
                                assert(ap);
                                assert(rec_nframes <= (framecnt_t) ap->get_audio_buffer(nframes).capacity());
 
-                               Sample *bbuf = ap->get_audio_buffer (nframes).data(rec_offset);
-
-
-                                for (jack_nframes_t _xx = 0; _xx != rec_nframes; ++_xx) {
-                                        if (bbuf[_xx] != 0.0) {
-                                                cerr << name() << " @ " << transport_frame << " + " << _xx << " = " << bbuf[_xx]
-                                                     << endl;
-                                                break;
-                                        }
-                                }
-
-
+                               Sample *bbuf = ap->get_audio_buffer (nframes).data (rec_offset);
                                memcpy (chaninfo->current_capture_buffer, bbuf, sizeof (Sample) * rec_nframes);
 
-
                        } else {
 
                                framecnt_t total = chaninfo->capture_vector.len[0] + chaninfo->capture_vector.len[1];
index ae71817679323a5dd6bbcbc587e27a4164250eb7..6420b9247df8b5f1e8c36321550e55848da37bb2 100644 (file)
@@ -1522,3 +1522,12 @@ AudioEngine::ensure_monitor_input (const std::string& portname, bool yn) const
 
         jack_port_request_monitor (port, yn);
 }
+
+void
+AudioEngine::update_latencies ()
+{
+        if (jack_recompute_total_latencies) {
+                GET_PRIVATE_JACK_POINTER (_jack);
+                jack_recompute_total_latencies (_priv_jack);
+        }
+}
index d5eb687497703e99973f2f236aa89f9451ea02af..67daaae2f4800778f6ef3bce9b8254ec1b0a425d 100644 (file)
@@ -346,7 +346,7 @@ Session::when_engine_running ()
 
        /* every time we reconnect, recompute worst case output latencies */
 
-       _engine.Running.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies, this));
+       _engine.Running.connect_same_thread (*this, boost::bind (&Session::initialize_latencies, this));
 
        if (synced_to_jack()) {
                _engine.transport_stop ();
@@ -640,12 +640,14 @@ Session::when_engine_running ()
 
        _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty));
 
+        /* update latencies */
+
+        initialize_latencies ();
+
        /* hook us up to the engine */
 
        BootMessage (_("Connect to engine"));
        _engine.set_session (this);
-
-       update_latency_compensation (true);
 }
 
 void
@@ -685,8 +687,6 @@ Session::hookup_io ()
 
        /* Tell all IO objects to connect themselves together */
 
-       cerr << "Enable IO connections, state = " << _state_of_the_state << endl;
-
        IO::enable_connecting ();
        MIDI::Port::MakeConnections ();
 
@@ -4337,8 +4337,9 @@ Session::update_latency (bool playback)
 
        if (playback) {
                /* reverse the list so that we work backwards from the last route to run to the first */
+                RouteList* rl = routes.reader().get();
+                r.reset (new RouteList (*rl));
                reverse (r->begin(), r->end());
-               cerr << "\n!!! I JUST REVERSED THE ROUTE LIST (" << r->size() << ")!!!\n\n";
        }
 
        /* compute actual latency values for the given direction and store them all in per-port
@@ -4410,6 +4411,18 @@ Session::post_capture_latency ()
        }
 }
 
+void
+Session::initialize_latencies ()
+{
+        {
+                Glib::Mutex::Lock lm (_engine.process_lock());
+                update_latency (false);
+                update_latency (true);
+        }
+
+        set_worst_io_latencies ();
+}
+
 void
 Session::set_worst_io_latencies ()
 {
@@ -4489,6 +4502,19 @@ Session::update_latency_compensation (bool force_whole_graph)
        DEBUG_TRACE (DEBUG::Latency, string_compose ("worst signal processing latency: %1 (changed ? %2)\n", _worst_track_latency,
                                                     (some_track_latency_changed ? "yes" : "no")));
 
-       DEBUG_TRACE(DEBUG::Latency, "---------------------------- DONE update latency compensation\n\n")
+       DEBUG_TRACE(DEBUG::Latency, "---------------------------- DONE update latency compensation\n\n");
+       
+       if (some_track_latency_changed || force_whole_graph)  {
+               _engine.update_latencies ();
+       }
+
+
+       for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+               boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+               if (!tr) {
+                       continue;
+               }
+               tr->set_capture_offset ();
+       }
 }