Fix stub LV2 persist implementation.
[ardour.git] / libs / ardour / audioengine.cc
index 301b3e3ce23e944ab6a6113fa0056430fe8c3d22..32ebe1643edecfe579c0387953d7df058d45092b 100644 (file)
@@ -76,7 +76,7 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
        _running = false;
        _has_run = false;
        last_monitor_check = 0;
-       monitor_check_interval = max_frames;
+       monitor_check_interval = INT32_MAX;
        _processed_frames = 0;
        _usecs_per_cycle = 0;
        _jack = 0;
@@ -243,7 +243,6 @@ AudioEngine::start ()
                         error << _("Cannot create temporary MIDI port to determine MIDI buffer size") << endmsg;
                 } else {
                         _raw_buffer_sizes[DataType::MIDI] = jack_midi_max_event_size (jack_port_get_buffer(midi_port, blocksize));
-                        cerr << "MIDI port buffers = " << _raw_buffer_sizes[DataType::MIDI] << endl;
                         jack_port_unregister (_priv_jack, midi_port);
                 }
        }
@@ -266,6 +265,10 @@ AudioEngine::stop (bool forever)
                }
        }
 
+        if (forever) {
+                stop_metering_thread ();
+        }
+
        return _running ? -1 : 0;
 }
 
@@ -413,7 +416,7 @@ AudioEngine::split_cycle (nframes_t offset)
 }
 
 void
-AudioEngine::finish_process_cycle (int status)
+AudioEngine::finish_process_cycle (int /* status*/ )
 {
         GET_PRIVATE_JACK_POINTER(_jack);
         jack_cycle_signal (_jack, 0);
@@ -460,8 +463,8 @@ AudioEngine::process_callback (nframes_t nframes)
 
        /* handle wrap around of total frames counter */
 
-       if (max_frames - _processed_frames < nframes) {
-               next_processed_frames = nframes - (max_frames - _processed_frames);
+       if (max_framepos - _processed_frames < nframes) {
+               next_processed_frames = nframes - (max_framepos - _processed_frames);
        } else {
                next_processed_frames = _processed_frames + nframes;
        }
@@ -844,8 +847,6 @@ AudioEngine::unregister_port (Port& port)
 int
 AudioEngine::connect (const string& source, const string& destination)
 {
-       /* caller must hold process lock */
-
        int ret;
 
        if (!_running) {
@@ -861,8 +862,8 @@ AudioEngine::connect (const string& source, const string& destination)
        string d = make_port_name_non_relative (destination);
 
 
-       Port* src = get_port_by_name_locked (s);
-       Port* dst = get_port_by_name_locked (d);
+       Port* src = get_port_by_name (s);
+       Port* dst = get_port_by_name (d);
 
        if (src) {
                ret = src->connect (d);
@@ -887,8 +888,6 @@ AudioEngine::connect (const string& source, const string& destination)
 int
 AudioEngine::disconnect (const string& source, const string& destination)
 {
-       /* caller must hold process lock */
-
        int ret;
 
        if (!_running) {
@@ -903,8 +902,8 @@ AudioEngine::disconnect (const string& source, const string& destination)
        string s = make_port_name_non_relative (source);
        string d = make_port_name_non_relative (destination);
 
-       Port* src = get_port_by_name_locked (s);
-       Port* dst = get_port_by_name_locked (d);
+       Port* src = get_port_by_name (s);
+       Port* dst = get_port_by_name (d);
 
        if (src) {
                        ret = src->disconnect (d);
@@ -971,30 +970,22 @@ Port *
 AudioEngine::get_port_by_name (const string& portname)
 {
        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 (s);
-}
-
-Port *
-AudioEngine::get_port_by_name_locked (const string& portname)
-{
-       /* caller must hold process lock */
 
        if (!_running) {
                if (!_has_run) {
-                       fatal << _("get_port_by_name_locked() called before engine was started") << endmsg;
+                       fatal << _("get_port_by_name() called before engine was started") << endmsg;
                        /*NOTREACHED*/
                } else {
                        return 0;
                }
        }
 
+       if (portname.find_first_of (':') == string::npos) {
+               s = make_port_name_non_relative (portname);
+       } else {
+               s = portname;
+       }
+
        if (portname.substr (0, jack_client_name.length ()) != jack_client_name) {
                /* not an ardour: port */
                return 0;
@@ -1474,19 +1465,18 @@ AudioEngine::is_realtime () const
        return jack_is_realtime (_priv_jack);
 }
 
-pthread_t
-AudioEngine::create_process_thread (boost::function<void()> f, size_t stacksize)
+int
+AudioEngine::create_process_thread (boost::function<void()> f, pthread_t* thread, size_t stacksize)
 {
         GET_PRIVATE_JACK_POINTER_RET (_jack, 0);
-        pthread_t thread;
         ThreadData* td = new ThreadData (this, f, stacksize);
 
-        if (jack_client_create_thread (_priv_jack, &thread, jack_client_real_time_priority (_priv_jack), 
+        if (jack_client_create_thread (_priv_jack, thread, jack_client_real_time_priority (_priv_jack), 
                                        jack_is_realtime (_priv_jack), _start_process_thread, td)) {
                 return -1;
         } 
 
-        return thread;
+        return 0;
 }
 
 void*