From 37d9ec34c86bb18f95e35987b8b62bd4d275787c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2019 13:46:06 -0600 Subject: add ::usable() method to TransportMaster objects to allow GUI to show their usability after backend/engine changes --- gtk2_ardour/transport_masters_dialog.cc | 15 +++++++++++++++ gtk2_ardour/transport_masters_dialog.h | 2 ++ libs/ardour/ardour/transport_master.h | 11 +++++++++++ libs/ardour/engine_slave.cc | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/gtk2_ardour/transport_masters_dialog.cc b/gtk2_ardour/transport_masters_dialog.cc index bbf846e688..dcc97e6201 100644 --- a/gtk2_ardour/transport_masters_dialog.cc +++ b/gtk2_ardour/transport_masters_dialog.cc @@ -86,6 +86,8 @@ TransportMastersWidget::TransportMastersWidget () TransportMasterManager::instance().Added.connect (add_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context()); TransportMasterManager::instance().Removed.connect (remove_connection, invalidator (*this), boost::bind (&TransportMastersWidget::rebuild, this), gui_context()); + AudioEngine::instance()->Running.connect (engine_running_connection, invalidator (*this), boost::bind (&TransportMastersWidget::update_usability, this), gui_context()); + rebuild (); } @@ -244,6 +246,19 @@ TransportMastersWidget::rebuild () r->prop_change (all_change); } + + update_usability (); +} + +void +TransportMastersWidget::update_usability () +{ + for (vector::iterator r= rows.begin(); r != rows.end(); ++r) { + const bool usable = (*r)->tm->usable(); + (*r)->use_button.set_sensitive (usable); + (*r)->collect_button.set_sensitive (usable); + (*r)->request_options.set_sensitive (usable); + } } TransportMastersWidget::Row::Row (TransportMastersWidget& p) diff --git a/gtk2_ardour/transport_masters_dialog.h b/gtk2_ardour/transport_masters_dialog.h index eb9689490a..695bfc9a9f 100644 --- a/gtk2_ardour/transport_masters_dialog.h +++ b/gtk2_ardour/transport_masters_dialog.h @@ -143,11 +143,13 @@ class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr PBD::ScopedConnection current_connection; PBD::ScopedConnection add_connection; PBD::ScopedConnection remove_connection; + PBD::ScopedConnection engine_running_connection; void rebuild (); void clear (); void current_changed (boost::shared_ptr old_master, boost::shared_ptr new_master); void add_master (); + void update_usability (); public: bool idle_remove (Row*); diff --git a/libs/ardour/ardour/transport_master.h b/libs/ardour/ardour/transport_master.h index ee986f7a9e..3dcfe4cd8f 100644 --- a/libs/ardour/ardour/transport_master.h +++ b/libs/ardour/ardour/transport_master.h @@ -231,6 +231,16 @@ class LIBARDOUR_API TransportMaster : public PBD::Stateful { */ virtual bool ok() const = 0; + /** + * reports to ARDOUR whether it is possible to use this slave + * + * @return - true if the slave can be used. + * + * Only the JACK ("Engine") slave is ever likely to return false, + * if JACK is not being used for the Audio/MIDI backend. + */ + virtual bool usable() const { return true; } + /** * reports to ARDOUR whether the slave is in the process of starting * to roll @@ -626,6 +636,7 @@ class LIBARDOUR_API Engine_TransportMaster : public TransportMaster void reset (bool with_position); bool locked() const; bool ok() const; + bool usable() const; samplecnt_t update_interval () const; samplecnt_t resolution () const { return 1; } bool requires_seekahead () const { return false; } diff --git a/libs/ardour/engine_slave.cc b/libs/ardour/engine_slave.cc index d00a2a1bfe..8fdd78a1e8 100644 --- a/libs/ardour/engine_slave.cc +++ b/libs/ardour/engine_slave.cc @@ -47,6 +47,12 @@ Engine_TransportMaster::init () { } +bool +Engine_TransportMaster::usable () const +{ + return AudioEngine::instance()->current_backend_name() == X_("JACK"); +} + void Engine_TransportMaster::check_backend() { -- cgit v1.2.3