summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2018-10-04 13:19:30 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2018-10-05 14:15:02 -0400
commit67ba0bd992920032cc645cb2954084f54fa59b2f (patch)
tree197fd495ad0855be7b9181816209827df33fdfdb
parentccccac7a10378de5e17f7562c1f9dc889d443f68 (diff)
laying the groundwork for adding/removing transport masters
-rw-r--r--libs/ardour/ardour/transport_master.h10
-rw-r--r--libs/ardour/ardour/transport_master_manager.h2
-rw-r--r--libs/ardour/transport_master.cc38
-rw-r--r--libs/ardour/transport_master_manager.cc17
4 files changed, 52 insertions, 15 deletions
diff --git a/libs/ardour/ardour/transport_master.h b/libs/ardour/ardour/transport_master.h
index e4fee4bba2..721b8e7a4a 100644
--- a/libs/ardour/ardour/transport_master.h
+++ b/libs/ardour/ardour/transport_master.h
@@ -155,7 +155,7 @@ class LIBARDOUR_API TransportMaster : public PBD::Stateful {
TransportMaster (SyncSource t, std::string const & name);
virtual ~TransportMaster();
- static boost::shared_ptr<TransportMaster> factory (SyncSource, std::string const &);
+ static boost::shared_ptr<TransportMaster> factory (SyncSource, std::string const &, bool removeable);
static boost::shared_ptr<TransportMaster> factory (XMLNode const &);
virtual void pre_process (pframes_t nframes, samplepos_t now, boost::optional<samplepos_t>) = 0;
@@ -337,12 +337,20 @@ class LIBARDOUR_API TransportMaster : public PBD::Stateful {
void get_current (double&, samplepos_t&, samplepos_t);
+ /* this is set at construction, and not changeable later, so it is not
+ * a property
+ */
+
+ bool removeable () const { return _removeable; }
+ void set_removeable (bool yn) { _removeable = yn; }
+
protected:
SyncSource _type;
PBD::Property<std::string> _name;
Session* _session;
sampleoffset_t _current_delta;
bool _pending_collect;
+ bool _removeable;
PBD::Property<TransportRequestType> _request_mask; /* lists transport requests still accepted when we're in control */
PBD::Property<bool> _locked;
PBD::Property<bool> _sclock_synced;
diff --git a/libs/ardour/ardour/transport_master_manager.h b/libs/ardour/ardour/transport_master_manager.h
index 4c4159cb6f..46d195bf24 100644
--- a/libs/ardour/ardour/transport_master_manager.h
+++ b/libs/ardour/ardour/transport_master_manager.h
@@ -41,7 +41,7 @@ class LIBARDOUR_API TransportMasterManager : public boost::noncopyable
typedef std::list<boost::shared_ptr<TransportMaster> > TransportMasters;
- int add (SyncSource type, std::string const & name);
+ int add (SyncSource type, std::string const & name, bool removeable = true);
int remove (std::string const & name);
void clear ();
diff --git a/libs/ardour/transport_master.cc b/libs/ardour/transport_master.cc
index 5d02eb0073..5a53976dcb 100644
--- a/libs/ardour/transport_master.cc
+++ b/libs/ardour/transport_master.cc
@@ -68,6 +68,7 @@ TransportMaster::TransportMaster (SyncSource t, std::string const & name)
, _session (0)
, _current_delta (0)
, _pending_collect (true)
+ , _removeable (false)
, _request_mask (Properties::allowed_transport_requests, TransportRequestType (0))
, _locked (Properties::locked, false)
, _sclock_synced (Properties::sclock_synced, false)
@@ -285,6 +286,7 @@ TransportMaster::get_state ()
{
XMLNode* node = new XMLNode (state_node_name);
node->set_property (X_("type"), _type);
+ node->set_property (X_("removeable"), _removeable);
add_properties (*node);
@@ -329,6 +331,7 @@ TransportMaster::factory (XMLNode const & node)
SyncSource type;
std::string name;
+ bool removeable;
if (!node.get_property (X_("type"), type)) {
return boost::shared_ptr<TransportMaster>();
@@ -338,28 +341,49 @@ TransportMaster::factory (XMLNode const & node)
return boost::shared_ptr<TransportMaster>();
}
- return factory (type, name);
+ if (!node.get_property (X_("removeable"), removeable)) {
+ /* development versions of 6.0 didn't have this property for a
+ while. Any TM listed in XML at that time was non-removeable
+ */
+ removeable = false;
+ }
+
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("xml-construct %1 name %2 removeable %3\n", enum_2_string (type), name, removeable));
+
+ return factory (type, name, removeable);
}
boost::shared_ptr<TransportMaster>
-TransportMaster::factory (SyncSource type, std::string const& name)
+TransportMaster::factory (SyncSource type, std::string const& name, bool removeable)
{
/* XXX need to count existing sources of a given type */
+ boost::shared_ptr<TransportMaster> tm;
+
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("factory-construct %1 name %2 removeable %3\n", enum_2_string (type), name, removeable));
+
switch (type) {
case MTC:
- return boost::shared_ptr<TransportMaster> (new MTC_TransportMaster (sync_source_to_string (type)));
+ tm.reset (new MTC_TransportMaster (sync_source_to_string (type)));
+ break;
case LTC:
- return boost::shared_ptr<TransportMaster> (new LTC_TransportMaster (sync_source_to_string (type)));
+ tm.reset (new LTC_TransportMaster (sync_source_to_string (type)));
+ break;
case MIDIClock:
- return boost::shared_ptr<TransportMaster> (new MIDIClock_TransportMaster (sync_source_to_string (type)));
+ tm.reset (new MIDIClock_TransportMaster (sync_source_to_string (type)));
+ break;
case Engine:
- return boost::shared_ptr<TransportMaster> (new Engine_TransportMaster (*AudioEngine::instance()));
+ tm.reset (new Engine_TransportMaster (*AudioEngine::instance()));
+ break;
default:
break;
}
- return boost::shared_ptr<TransportMaster>();
+ if (tm) {
+ tm->set_removeable (removeable);
+ }
+
+ return tm;
}
boost::shared_ptr<Port>
diff --git a/libs/ardour/transport_master_manager.cc b/libs/ardour/transport_master_manager.cc
index dee67bc6ed..95b86b4f07 100644
--- a/libs/ardour/transport_master_manager.cc
+++ b/libs/ardour/transport_master_manager.cc
@@ -57,10 +57,10 @@ TransportMasterManager::init ()
/* setup default transport masters. Most people will never need any
others
*/
- add (Engine, X_("JACK Transport"));
- add (MTC, X_("MTC"));
- add (LTC, X_("LTC"));
- add (MIDIClock, X_("MIDI Clock"));
+ add (Engine, X_("JACK Transport"), false);
+ add (MTC, X_("MTC"), false);
+ add (LTC, X_("LTC"), false);
+ add (MIDIClock, X_("MIDI Clock"), false);
} catch (...) {
return -1;
}
@@ -306,14 +306,16 @@ TransportMasterManager::init_transport_master_dll (double speed, samplepos_t pos
}
int
-TransportMasterManager::add (SyncSource type, std::string const & name)
+TransportMasterManager::add (SyncSource type, std::string const & name, bool removeable)
{
int ret = 0;
boost::shared_ptr<TransportMaster> tm;
+ DEBUG_TRACE (DEBUG::Slave, string_compose ("adding new transport master, type %1 name %2 removeable %3\n", enum_2_string (type), name, removeable));
+
{
Glib::Threads::RWLock::WriterLock lm (lock);
- tm = TransportMaster::factory (type, name);
+ tm = TransportMaster::factory (type, name, removeable);
ret = add_locked (tm);
}
@@ -353,6 +355,9 @@ TransportMasterManager::remove (std::string const & name)
for (TransportMasters::iterator t = _transport_masters.begin(); t != _transport_masters.end(); ++t) {
if ((*t)->name() == name) {
+ if (!tm->removeable()) {
+ return -1;
+ }
tm = *t;
_transport_masters.erase (t);
ret = 0;