laying the groundwork for adding/removing transport masters
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user