replace fixed-point linear interpolation with double-based version, thereby removing...
[ardour.git] / libs / ardour / audioengine.cc
index 3e1ba8b2d9decda1ac82b08f2174b8056658fa85..7533a1ed8f71ce9ad9f500363655b76d772b626c 100644 (file)
 
 #include "midi++/jack.h"
 
+#include "ardour/amp.h"
+#include "ardour/audio_port.h"
 #include "ardour/audioengine.h"
 #include "ardour/buffer.h"
-#include "ardour/port.h"
-#include "ardour/audio_port.h"
-#include "ardour/midi_port.h"
-#include "ardour/session.h"
+#include "ardour/buffer_set.h"
 #include "ardour/cycle_timer.h"
-#include "ardour/utils.h"
+#include "ardour/delivery.h"
 #include "ardour/event_type_map.h"
+#include "ardour/internal_return.h"
 #include "ardour/io.h"
-#include "ardour/amp.h"
+#include "ardour/meter.h"
+#include "ardour/midi_port.h"
+#include "ardour/port.h"
 #include "ardour/port_set.h"
-#include "ardour/buffer_set.h"
-
+#include "ardour/session.h"
 #include "ardour/timestamps.h"
+#include "ardour/utils.h"
 
 #include "i18n.h"
 
@@ -178,7 +180,7 @@ AudioEngine::start ()
                jack_set_sync_callback (_jack, _jack_sync_callback, this);
                jack_set_freewheel_callback (_jack, _freewheel_callback, this);
 
-               if (Config->get_jack_time_master()) {
+               if (session && session->config.get_jack_time_master()) {
                        jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
                }
 
@@ -329,6 +331,7 @@ int
 AudioEngine::process_callback (nframes_t nframes)
 {
        // CycleTimer ct ("AudioEngine::process");
+
        Glib::Mutex::Lock tm (_process_lock, Glib::TRY_LOCK);
 
        /// The number of frames that will have been processed when we've finished
@@ -357,10 +360,11 @@ AudioEngine::process_callback (nframes_t nframes)
                return 0;
        }
 
-       /* tell all IO objects that we're starting a new cycle */
+       /* tell all relevant objects that we're starting a new cycle */
 
-       IO::CycleStart (nframes);
+       Delivery::CycleStart (nframes);
        Port::set_port_offset (0);
+       InternalReturn::CycleStart (nframes);
 
        /* tell all Ports that we're starting a new cycle */
 
@@ -518,7 +522,7 @@ AudioEngine::meter_thread ()
                if (g_atomic_int_get(&m_meter_exit)) {
                        break;
                }
-               IO::update_meters ();
+               Metering::update_meters ();
        }
 }
 
@@ -713,9 +717,7 @@ AudioEngine::connect (const string& source, const string& destination)
        }
        
        if (ret > 0) {
-               error << string_compose(_("AudioEngine: connection already exists: %1 (%2) to %3 (%4)"), 
-                                       source, s, destination, d) 
-                     << endmsg;
+               /* already exists - no error, no warning */
        } else if (ret < 0) {
                error << string_compose(_("AudioEngine: cannot connect %1 (%2) to %3 (%4)"), 
                                        source, s, destination, d) 
@@ -821,10 +823,15 @@ AudioEngine::frames_per_cycle ()
 Port *
 AudioEngine::get_port_by_name (const string& portname)
 {
-       assert (portname.find_first_of (':') != string::npos);
+       string s;
+       if (portname.find_first_of (':') == string::npos) {
+               s = make_port_name_non_relative (portname);
+       } else {
+               s = portname;
+       }
        
        Glib::Mutex::Lock lm (_process_lock);
-       return get_port_by_name_locked (portname);
+       return get_port_by_name_locked (s);
 }
 
 Port *
@@ -1090,8 +1097,8 @@ AudioEngine::transport_state ()
 int
 AudioEngine::reset_timebase ()
 {
-       if (_jack) {
-               if (Config->get_jack_time_master()) {
+       if (_jack && session) {
+               if (session->config.get_jack_time_master()) {
                        return jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
                } else {
                        return jack_release_timebase (_jack);
@@ -1154,8 +1161,6 @@ AudioEngine::remove_connections_for (Port& port)
 }
 
 
-#ifdef HAVE_JACK_CLIENT_OPEN
-
 static void 
 ardour_jack_error (const char* msg) 
 {
@@ -1186,22 +1191,6 @@ AudioEngine::connect_to_jack (string client_name)
        return 0;
 }
 
-#else
-
-int
-AudioEngine::connect_to_jack (string client_name)
-{
-       jack_client_name = client_name;
-
-       if ((_jack = jack_client_new (client_name.c_str())) == 0) {
-               return -1;
-       }
-
-       return 0;
-}
-
-#endif /* HAVE_JACK_CLIENT_OPEN */
-
 int 
 AudioEngine::disconnect_from_jack ()
 {
@@ -1285,7 +1274,7 @@ AudioEngine::reconnect_to_jack ()
        jack_set_sync_callback (_jack, _jack_sync_callback, this);
        jack_set_freewheel_callback (_jack, _freewheel_callback, this);
        
-       if (Config->get_jack_time_master()) {
+       if (session && session->config.get_jack_time_master()) {
                jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
        }