diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-02-15 19:55:14 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-02-15 19:55:14 +0000 |
commit | 1c3f709bf75d86462b4441470d5108cdc049301b (patch) | |
tree | 9246d3b43955d61a35b780fcd19b8df7f7bec1ed | |
parent | 01c253b61b3130d13f9e30f17683e0f8a93b4696 (diff) |
part two of new JACK latency API support - should fix broken compilation
git-svn-id: svn://localhost/ardour2/branches/3.0@8864 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/port.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 4 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 38 | ||||
-rw-r--r-- | libs/ardour/port.cc | 12 | ||||
-rw-r--r-- | libs/ardour/route.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session.cc | 7 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 2 | ||||
-rw-r--r-- | libs/ardour/wscript | 3 |
9 files changed, 53 insertions, 22 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 390c0bbda6..b63bcfc65f 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -318,6 +318,11 @@ _ the regular process() call to session->process() is not made. int jack_bufsize_callback (pframes_t); int jack_sample_rate_callback (pframes_t); +#ifdef HAVE_JACK_NEW_LATENCY + static void _latency_callback (jack_latency_callback_mode_t, void*); + void jack_latency_callback (jack_latency_callback_mode_t); +#endif + int connect_to_jack (std::string client_name, std::string session_uuid); static void halted (void *); diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 45256a61fe..21d26397b3 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -99,8 +99,10 @@ public: void request_monitor_input (bool); void set_latency (framecnt_t); +#ifdef HAVE_JACK_NEW_LATENCY void get_connected_latency_range (jack_latency_range_t& range, jack_latency_callback_mode_t mode) const; void set_latency_range (jack_latency_range_t& range, jack_latency_callback_mode_t mode) const; +#endif virtual void reset (); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 293d9d391f..d6b35aa998 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1361,6 +1361,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void reset_jack_connection (jack_client_t* jack); void process_rtop (SessionEvent*); +#ifdef HAVE_JACK_NEW_LATENCY + void update_latency (bool playback); +#endif + XMLNode& state(bool); /* click track */ diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index f6557fbc4f..5ac4e2140e 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -25,6 +25,7 @@ #include <sstream> #include <glibmm/timer.h> +#include <jack/weakjack.h> #include <jack/jack.h> #include <jack/thread.h> @@ -153,19 +154,6 @@ _thread_init_callback (void * /*arg*/) MIDI::Port::set_process_thread (pthread_self()); } -typedef void (*_JackInfoShutdownCallback)(jack_status_t code, const char* reason, void *arg); - -static void (*on_info_shutdown)(jack_client_t*, _JackInfoShutdownCallback, void *); -extern void jack_on_info_shutdown (jack_client_t*, _JackInfoShutdownCallback, void *) __attribute__((weak)); - -static void check_jack_symbols () __attribute__((constructor)); - -void check_jack_symbols () -{ - /* use weak linking to see if we really have various late-model JACK function */ - on_info_shutdown = jack_on_info_shutdown; -} - static void ardour_jack_error (const char* msg) { @@ -204,7 +192,7 @@ AudioEngine::start () _processed_frames = 0; last_monitor_check = 0; - if (on_info_shutdown) { + if (jack_on_info_shutdown) { jack_on_info_shutdown (_priv_jack, halted_info, this); } else { jack_on_shutdown (_priv_jack, halted, this); @@ -220,6 +208,11 @@ AudioEngine::start () if( jack_set_session_callback ) jack_set_session_callback (_priv_jack, _session_callback, this); #endif +#if HAVE_JACK_NEW_LATENCY + if (jack_set_latency_callback) { + jack_set_latency_callback (_priv_jack, _latency_callback, this); + } +#endif jack_set_sync_callback (_priv_jack, _jack_sync_callback, this); jack_set_freewheel_callback (_priv_jack, _freewheel_callback, this); jack_set_port_registration_callback (_priv_jack, _registration_callback, this); @@ -396,6 +389,12 @@ AudioEngine::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* a } void +AudioEngine::_latency_callback (jack_latency_callback_mode_t mode, void* arg) +{ + return static_cast<AudioEngine *> (arg)->jack_latency_callback (mode); +} + +void AudioEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg) { AudioEngine* ae = static_cast<AudioEngine*> (arg); @@ -619,6 +618,17 @@ AudioEngine::jack_sample_rate_callback (pframes_t nframes) return 0; } +void +AudioEngine::jack_latency_callback (jack_latency_callback_mode_t mode) +{ + cerr << "JACK LATENCY CALLBACK\n"; + if (_session) { + _session->update_latency (mode == JackPlaybackLatency); + } else { + cerr << "NO SESSION\n"; + } +} + int AudioEngine::_bufsize_callback (pframes_t nframes, void *arg) { diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index 7d6abbdb04..607c029432 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -221,8 +221,8 @@ Port::reset () void Port::recompute_total_latency () const { -#if !HAVE_JACK_NEW_LATENCY -#ifdef HAVE_JACK_RECOMPUTE_LATENCY +#ifndef HAVE_JACK_NEW_LATENCY +#ifdef HAVE_JACK_RECOMPUTE_LATENCY jack_client_t* jack = _engine->jack(); if (!jack) { @@ -237,7 +237,7 @@ Port::recompute_total_latency () const void Port::set_latency_range (jack_latency_range_t& range, jack_latency_callback_mode_t mode) const { -#if HAVE_JACK_NEW_LATENCY +#ifdef HAVE_JACK_NEW_LATENCY if (!jack_port_set_latency_range) { return; } @@ -249,7 +249,7 @@ Port::set_latency_range (jack_latency_range_t& range, jack_latency_callback_mode void Port::get_connected_latency_range (jack_latency_range_t& range, jack_latency_callback_mode_t mode) const { -#if HAVE_JACK_NEW_LATENCY +#ifdef HAVE_JACK_NEW_LATENCY if (!jack_port_get_latency_range) { return; } @@ -293,7 +293,7 @@ Port::get_connected_latency_range (jack_latency_range_t& range, jack_latency_cal framecnt_t Port::total_latency () const { -#if !HAVE_JACK_NEW_LATENCY +#ifndef HAVE_JACK_NEW_LATENCY jack_client_t* jack = _engine->jack(); if (!jack) { @@ -369,7 +369,7 @@ Port::request_monitor_input (bool yn) void Port::set_latency (framecnt_t n) { -#if !HAVE_JACK_NEW_LATENCY +#ifndef HAVE_JACK_NEW_LATENCY jack_port_set_latency (_jack_port, n); #endif } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 0ef0fc8bba..e96275871b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3643,6 +3643,7 @@ Route::set_latency_ranges (jack_latency_callback_mode_t mode) const void Route::update_port_latencies (const PortSet& ports, jack_latency_callback_mode_t mode, framecnt_t our_latency) const { +#ifdef HAVE_JACK_NEW_LATENCY /* iterate over all connected ports and get the latency range they represent */ @@ -3661,4 +3662,5 @@ Route::update_port_latencies (const PortSet& ports, jack_latency_callback_mode_t p->set_latency_range (range, mode); } +#endif } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index da18b61681..28822ef6f9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4234,3 +4234,10 @@ Session::unknown_processors () const return p; } +#ifdef HAVE_JACK_NEW_LATENCY +void +Session::update_latency (bool playback) +{ + DEBUG_TRACE (DEBUG::Latency, "JACK latency callback\n"); +} +#endif diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 7d58a97e77..acf2443bbb 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1525,7 +1525,7 @@ Session::update_latency_compensation (bool with_stop, bool abort) framecnt_t track_latency = (*i)->update_total_latency (); if (old_latency != track_latency) { -#if !HAVE_JACK_NEW_LATENCY +#ifndef HAVE_JACK_NEW_LATENCY (*i)->input()->update_port_total_latencies (); (*i)->output()->update_port_total_latencies (); #endif diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 88983dcc05..5ee0c91190 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -274,8 +274,9 @@ def configure(conf): linkflags = ['-ljack'], msg = 'Checking for new JACK latency API', define_name = 'HAVE_JACK_NEW_LATENCY', + uselib_store = "JACK_NEW_LATENCY", okmsg = 'present') - + if flac_supported(): conf.define ('HAVE_FLAC', 1) if ogg_supported(): |