LTC: break out xrun and latency callbacks.
authorRobin Gareus <robin@gareus.org>
Mon, 29 Oct 2012 17:29:34 +0000 (17:29 +0000)
committerRobin Gareus <robin@gareus.org>
Mon, 29 Oct 2012 17:29:34 +0000 (17:29 +0000)
prepare to call get_connected_latency_range() only if needed.

git-svn-id: svn://localhost/ardour2/branches/3.0@13366 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/slave.h
libs/ardour/ltc_slave.cc
libs/ardour/session_ltc.cc

index f864bee636e6200f63fa8dd717a8e9e9d1cee1ae..48d9ac516236f6f7995107b30f7788de40903e0f 100644 (file)
@@ -356,6 +356,7 @@ public:
        bool detect_ltc_fps(int, bool);
        bool equal_ltc_frame_time(LTCFrame *a, LTCFrame *b);
        void reset();
+       void resync_xrun();
        void resync_latency();
 
        Session&       session;
index 4f6f77ce1fb3843385f84de7f3bae06bcfed0924..f176c206a31f6220cdb1a1d2007a4c4f703c6750 100644 (file)
@@ -61,7 +61,8 @@ LTC_Slave::LTC_Slave (Session& s)
 
        decoder = ltc_decoder_create((int) frames_per_ltc_frame, 128 /*queue size*/);
        reset();
-       session.Xrun.connect_same_thread (port_connections, boost::bind (&LTC_Slave::resync_latency, this));
+       resync_latency();
+       session.Xrun.connect_same_thread (port_connections, boost::bind (&LTC_Slave::resync_xrun, this));
        session.engine().GraphReordered.connect_same_thread (port_connections, boost::bind (&LTC_Slave::resync_latency, this));
 }
 
@@ -94,10 +95,17 @@ LTC_Slave::ok() const
        return true;
 }
 
+void
+LTC_Slave::resync_xrun()
+{
+       DEBUG_TRACE (DEBUG::LTC, "LTC resync_xrun()\n");
+       engine_dll_initstate = 0;
+}
+
 void
 LTC_Slave::resync_latency()
 {
-       DEBUG_TRACE (DEBUG::LTC, "LTC resync()\n");
+       DEBUG_TRACE (DEBUG::LTC, "LTC resync_latency()\n");
        engine_dll_initstate = 0;
 
        if (session.ltc_output_io()) { /* check if Port exits */
@@ -115,7 +123,6 @@ LTC_Slave::reset()
        transport_direction = 0;
        ltc_speed = 0;
        engine_dll_initstate = 0;
-       resync_latency();
 }
 
 void
@@ -378,6 +385,9 @@ LTC_Slave::speed_and_position (double& speed, framepos_t& pos)
         * ..but first fix jack2 issue with re-computing latency
         * in the correct order. Until then, querying it in the
         * process-callback is the only way to get the current value
+        *
+        * update: fix for this issue is known -- common/JackEngine.cpp
+        * but not yet applied to jack2 git.
         */
        ltcport->get_connected_latency_range(ltc_slave_latency, false);
 #endif
index b7044d28a42014d83c7be39e851ad97231b86fdc..d14756c0ba063e524fc68d0b6cd610a1d1fbe40a 100644 (file)
@@ -58,7 +58,8 @@ Session::ltc_tx_initialize()
        ltc_enc_buf = (ltcsnd_sample_t*) calloc((nominal_frame_rate() / 23), sizeof(ltcsnd_sample_t));
        ltc_speed = 0;
        ltc_tx_reset();
-       Xrun.connect_same_thread (*this, boost::bind (&Session::ltc_tx_resync_latency, this));
+       ltc_tx_resync_latency();
+       Xrun.connect_same_thread (*this, boost::bind (&Session::ltc_tx_reset, this));
        engine().GraphReordered.connect_same_thread (*this, boost::bind (&Session::ltc_tx_resync_latency, this));
 }
 
@@ -92,7 +93,6 @@ Session::ltc_tx_reset()
        ltc_buf_off = 0;
        ltc_enc_byte = 0;
        ltc_enc_cnt = 0;
-       ltc_tx_resync_latency();
 }
 
 void
@@ -160,6 +160,9 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
         * ..but first fix jack2 issue with re-computing latency
         * in the correct order. Until then, querying it in the
         * process-callback is the only way to get the current value
+        *
+        * update: fix for this issue is known -- common/JackEngine.cpp
+        * but not yet applied to jack2 git.
         */
        ltcport->get_connected_latency_range(ltc_out_latency, true);
 #endif