NO-OP: a ToDo comment for discussion
[ardour.git] / libs / ardour / audioengine.cc
index 03c13e38fd61a6114b650d4e28844b4a1a0cd85c..83919bbe6a17b7d56acd78db318251b9cbc15047 100644 (file)
@@ -190,6 +190,7 @@ int
 AudioEngine::process_callback (pframes_t nframes)
 {
        Glib::Threads::Mutex::Lock tm (_process_lock, Glib::Threads::TRY_LOCK);
+       Port::set_speed_ratio (1.0);
 
        PT_TIMING_REF;
        PT_TIMING_CHECK (1);
@@ -348,8 +349,7 @@ AudioEngine::process_callback (pframes_t nframes)
        if (_session == 0) {
 
                if (!_freewheeling) {
-                       PortManager::cycle_start (nframes);
-                       PortManager::cycle_end (nframes);
+                       PortManager::silence_outputs (nframes);
                }
 
                _processed_samples = next_processed_samples;
@@ -357,13 +357,26 @@ AudioEngine::process_callback (pframes_t nframes)
                return 0;
        }
 
+       if (!_freewheeling || Freewheel.empty()) {
+               // TODO: Run a list of slaves here
+               // - multiple TC slaves (how_many_dsp_threads() in parallel)
+               //   (note this can be multiple slaves of each type. e.g.
+               //    3 LTC slaves on different ports, 2 MTC..)
+               // - GUI can display all slaves, user picks one.
+               // - active "slave" is a session property.
+               // - here we ask the session about the active slave
+               //   and get playback speed (for this cycle) here.
+               // - Internal Transport is-a Slave too (!)
+               Port::set_speed_ratio (_session->engine_speed ()); // HACK
+       }
+
        /* tell all relevant objects that we're starting a new cycle */
 
        InternalSend::CycleStart (nframes);
 
        /* tell all Ports that we're starting a new cycle */
 
-       PortManager::cycle_start (nframes);
+       PortManager::cycle_start (nframes, _session);
 
        /* test if we are freewheeling and there are freewheel signals connected.
         * ardour should act normally even when freewheeling unless /it/ is
@@ -373,11 +386,23 @@ AudioEngine::process_callback (pframes_t nframes)
        if (_freewheeling && !Freewheel.empty()) {
                Freewheel (nframes);
        } else {
-               _session->process (nframes);
+               if (Port::cycle_nframes () <= nframes) {
+                       _session->process (Port::cycle_nframes ());
+               } else {
+                       pframes_t remain = Port::cycle_nframes ();
+                       while (remain > 0) {
+                               pframes_t nf = std::min (remain, nframes);
+                               _session->process (nf);
+                               remain -= nf;
+                               if (remain > 0) {
+                                       split_cycle (nf);
+                               }
+                       }
+               }
        }
 
        if (_freewheeling) {
-               PortManager::cycle_end (nframes);
+               PortManager::cycle_end (nframes, _session);
                return 0;
        }
 
@@ -419,7 +444,7 @@ AudioEngine::process_callback (pframes_t nframes)
 
        if (session_remove_pending && session_removal_countdown) {
 
-               PortManager::fade_out (session_removal_gain, session_removal_gain_step, nframes);
+               PortManager::cycle_end_fade_out (session_removal_gain, session_removal_gain_step, nframes, _session);
 
                if (session_removal_countdown > nframes) {
                        session_removal_countdown -= nframes;
@@ -428,10 +453,10 @@ AudioEngine::process_callback (pframes_t nframes)
                }
 
                session_removal_gain -= (nframes * session_removal_gain_step);
+       } else {
+               PortManager::cycle_end (nframes, _session);
        }
 
-       PortManager::cycle_end (nframes);
-
        _processed_samples = next_processed_samples;
 
        PT_TIMING_CHECK (2);