From 4c7e5dbc74981dfe1c1d277a633cb2cce0d6036b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 5 Oct 2018 12:35:10 -0400 Subject: move away from "sync source" concepts --- libs/ardour/ardour/rc_configuration_vars.h | 2 -- libs/ardour/ardour/session.h | 2 +- libs/ardour/ardour/transport_master.h | 2 ++ libs/ardour/ardour/utils.h | 3 -- libs/ardour/session_ltc.cc | 3 +- libs/ardour/session_state.cc | 2 +- libs/ardour/session_transport.cc | 5 +++ libs/ardour/transport_master.cc | 53 ++++++++++++++++++++++++++-- libs/ardour/transport_master_manager.cc | 4 +++ libs/ardour/utils.cc | 56 ------------------------------ libs/surfaces/control_protocol/basic_ui.cc | 2 +- 11 files changed, 66 insertions(+), 68 deletions(-) diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index d806844547..452a0822cc 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -74,8 +74,6 @@ CONFIG_VARIABLE (int, mtc_qf_speed_tolerance, "mtc-qf-speed-tolerance", 5) CONFIG_VARIABLE (bool, timecode_sync_frame_rate, "timecode-sync-frame-rate", true) #ifdef USE_TRACKS_CODE_FEATURES CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", MTC) -#else -CONFIG_VARIABLE (SyncSource, sync_source, "sync-source", Engine) #endif CONFIG_VARIABLE (bool, send_ltc, "send-ltc", false) CONFIG_VARIABLE (bool, ltc_send_continuously, "ltc-send-continuously", true) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 6e7ec93dec..455a1d6337 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -718,7 +718,7 @@ public: static PBD::Signal1 EndTimeChanged; void request_sync_source (boost::shared_ptr); - bool synced_to_engine() const { return config.get_external_sync() && Config->get_sync_source() == Engine; } + bool synced_to_engine() const; double engine_speed() const { return _engine_speed; } double actual_speed() const { diff --git a/libs/ardour/ardour/transport_master.h b/libs/ardour/ardour/transport_master.h index 721b8e7a4a..c70757647b 100644 --- a/libs/ardour/ardour/transport_master.h +++ b/libs/ardour/ardour/transport_master.h @@ -344,6 +344,8 @@ class LIBARDOUR_API TransportMaster : public PBD::Stateful { bool removeable () const { return _removeable; } void set_removeable (bool yn) { _removeable = yn; } + std::string display_name (bool sh/*ort*/ = true) const; + protected: SyncSource _type; PBD::Property _name; diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 3e5ff1b1a1..5f11328d7f 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -75,9 +75,6 @@ LIBARDOUR_API bool path_is_paired (std::string path, std::string& pair_base); LIBARDOUR_API void compute_equal_power_fades (ARDOUR::samplecnt_t nframes, float* in, float* out); -LIBARDOUR_API const char* sync_source_to_string (ARDOUR::SyncSource src, bool sh = false); -LIBARDOUR_API ARDOUR::SyncSource string_to_sync_source (std::string str); - LIBARDOUR_API const char* edit_mode_to_string (ARDOUR::EditMode); LIBARDOUR_API ARDOUR::EditMode string_to_edit_mode (std::string); diff --git a/libs/ardour/session_ltc.cc b/libs/ardour/session_ltc.cc index a6a1c6bd7b..c2cd0ef681 100644 --- a/libs/ardour/session_ltc.cc +++ b/libs/ardour/session_ltc.cc @@ -26,6 +26,7 @@ #include "ardour/io.h" #include "ardour/session.h" #include "ardour/transport_master.h" +#include "ardour/transport_master_manager.h" #include "pbd/i18n.h" @@ -183,7 +184,7 @@ Session::ltc_tx_send_time_code_for_cycle (samplepos_t start_sample, samplepos_t return; } - SyncSource sync_src = Config->get_sync_source(); + SyncSource sync_src = TransportMasterManager::instance().current()->type(); if (engine().freewheeling() || !Config->get_send_ltc() /* TODO * decide which time-sources we can generated LTC from. diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0c974fcc84..34a6a43480 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -4098,7 +4098,7 @@ Session::config_changed (std::string p, bool ours) first_file_data_format_reset = false; } else if (p == "external-sync") { - request_sync_source (TransportMasterManager::instance().master_by_type (Config->get_sync_source())); + request_sync_source (TransportMasterManager::instance().current()); } else if (p == "denormal-model") { setup_fpu (); } else if (p == "history-depth") { diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index cf10cf11c7..b87a77c417 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -92,6 +92,11 @@ Session::should_ignore_transport_request (TransportRequestSource src, TransportR return false; } +bool +Session::synced_to_engine() const { + return config.get_external_sync() && TransportMasterManager::instance().current()->type() == Engine; +} + void Session::request_sync_source (boost::shared_ptr tm) { diff --git a/libs/ardour/transport_master.cc b/libs/ardour/transport_master.cc index 5a53976dcb..7e797a3715 100644 --- a/libs/ardour/transport_master.cc +++ b/libs/ardour/transport_master.cc @@ -364,13 +364,13 @@ TransportMaster::factory (SyncSource type, std::string const& name, bool removea switch (type) { case MTC: - tm.reset (new MTC_TransportMaster (sync_source_to_string (type))); + tm.reset (new MTC_TransportMaster (name)); break; case LTC: - tm.reset (new LTC_TransportMaster (sync_source_to_string (type))); + tm.reset (new LTC_TransportMaster (name)); break; case MIDIClock: - tm.reset (new MIDIClock_TransportMaster (sync_source_to_string (type))); + tm.reset (new MIDIClock_TransportMaster (name)); break; case Engine: tm.reset (new Engine_TransportMaster (*AudioEngine::instance())); @@ -386,6 +386,52 @@ TransportMaster::factory (SyncSource type, std::string const& name, bool removea return tm; } +/** @param sh Return a short version of the string */ +std::string +TransportMaster::display_name (bool sh) const +{ + + switch (_type) { + case Engine: + /* no other backends offer sync for now ... deal with this if we + * ever have to. + */ + return S_("SyncSource|JACK"); + + case MTC: + if (sh) { + if (name().length() <= 4) { + return name(); + } + return S_("SyncSource|MTC"); + } else { + return name(); + } + + case MIDIClock: + if (sh) { + if (name().length() <= 4) { + return name(); + } + return S_("SyncSource|M-Clk"); + } else { + return name(); + } + + case LTC: + if (sh) { + if (name().length() <= 4) { + return name(); + } + return S_("SyncSource|LTC"); + } else { + return name(); + } + } + /* GRRRR .... stupid, stupid gcc - you can't get here from there, all enum values are handled */ + return S_("SyncSource|JACK"); +} + boost::shared_ptr TransportMasterViaMIDI::create_midi_port (std::string const & port_name) { @@ -437,3 +483,4 @@ TimecodeTransportMaster::set_fr2997 (bool yn) PropertyChanged (Properties::fr2997); } } + diff --git a/libs/ardour/transport_master_manager.cc b/libs/ardour/transport_master_manager.cc index 95b86b4f07..7912b82218 100644 --- a/libs/ardour/transport_master_manager.cc +++ b/libs/ardour/transport_master_manager.cc @@ -340,6 +340,10 @@ TransportMasterManager::add_locked (boost::shared_ptr tm) } } + if (_session) { + tm->set_session (_session); + } + _transport_masters.push_back (tm); return 0; } diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 6a59d1b79b..dd893f399d 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -444,62 +444,6 @@ ARDOUR::edit_mode_to_string (EditMode mode) } } -SyncSource -ARDOUR::string_to_sync_source (string str) -{ - if (str == _("MIDI Timecode") || str == _("MTC")) { - return MTC; - } - - if (str == _("MIDI Clock")) { - return MIDIClock; - } - - if (str == _("JACK")) { - return Engine; - } - - if (str == _("LTC")) { - return LTC; - } - - fatal << string_compose (_("programming error: unknown sync source string \"%1\""), str) << endmsg; - abort(); /*NOTREACHED*/ - return Engine; -} - -/** @param sh Return a short version of the string */ -const char* -ARDOUR::sync_source_to_string (SyncSource src, bool sh) -{ - switch (src) { - case Engine: - /* no other backends offer sync for now ... deal with this if we - * ever have to. - */ - return S_("SyncSource|JACK"); - - case MTC: - if (sh) { - return S_("SyncSource|MTC"); - } else { - return _("MIDI Timecode"); - } - - case MIDIClock: - if (sh) { - return S_("SyncSource|M-Clk"); - } else { - return _("MIDI Clock"); - } - - case LTC: - return S_("SyncSource|LTC"); - } - /* GRRRR .... stupid, stupid gcc - you can't get here from there, all enum values are handled */ - return S_("SyncSource|JACK"); -} - float ARDOUR::meter_falloff_to_float (MeterFalloff falloff) { diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 7836eef319..3ffe334be4 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -210,7 +210,7 @@ BasicUI::transport_play (bool from_last_start) #if 0 if (session->config.get_external_sync()) { - switch (Config->get_sync_source()) { + switch (TransportMasterManager::instance().current().type()) { case Engine: break; default: -- cgit v1.2.3