initial check in of VBAP implementation (not coupled to any existing ardour objects...
[ardour.git] / libs / ardour / audioengine.cc
index 3453deea5c700db8ab027651c05e823b0bfd5223..5f619d8392d26f02c83671870056ae0356fad6b6 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;
 }
 
@@ -401,7 +404,7 @@ AudioEngine::split_cycle (nframes_t offset)
 {
        /* caller must hold process lock */
 
-       Port::increment_port_offset (offset);
+       AudioPort::increment_port_offset (offset);
 
        /* tell all Ports that we're going to start a new (split) cycle */
 
@@ -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;
        }
@@ -484,7 +487,7 @@ AudioEngine::process_callback (nframes_t nframes)
        /* tell all relevant objects that we're starting a new cycle */
 
        Delivery::CycleStart (nframes);
-       Port::set_port_offset (0);
+       AudioPort::set_port_offset (0);
        InternalReturn::CycleStart (nframes);
 
        /* tell all Ports that we're starting a new cycle */
@@ -1474,19 +1477,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*