summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-06-25 12:46:13 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-06-25 12:46:13 +0000
commit97d920593ffc796986107e16d7bbf88cc3184043 (patch)
treecc68f13ec1c9be69f98d30bd734e809fea30a0d1 /libs/ardour
parentf2f35e50a0e2d6e0b2c7f02b5e6c76e82643c80a (diff)
drastic rethink of the relationship between remote control ID and route order keys. unless the user explicitly switches to UserOrdered, Route::_remote_control_id is an unallocated pointer, and Route::remote_control_id() simply returns a value based on the relevant order_key() value. Also, change the key used in the Route::order_keys std::map<> from a string to an enum, since there is no evidence that we are benefitting from the theoretical benefit of using a string. Generally tidy up allocation of order keys so that the master and monitor busses always get a "special" MixerSort key value, based on the MMC ID for master (already defined within Ardour), and all other tracks/busses start at zero. Syncing keys between editor and mixer will leave the MixerSort key for the master and monitor bus alone, reflecting the fact that we display these in their own distinct parts of the GUI and they are not orderable like other tracks or busses within the mixer window
git-svn-id: svn://localhost/ardour2/branches/3.0@12923 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/route.h18
-rw-r--r--libs/ardour/ardour/session.h5
-rw-r--r--libs/ardour/ardour/types.h6
-rw-r--r--libs/ardour/enums.cc5
-rw-r--r--libs/ardour/route.cc131
-rw-r--r--libs/ardour/route_graph.cc4
-rw-r--r--libs/ardour/session.cc90
-rw-r--r--libs/ardour/session_state.cc10
8 files changed, 163 insertions, 106 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index d1248d8b03..a15937377e 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -101,8 +101,8 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
bool set_name (const std::string& str);
static void set_name_in_state (XMLNode &, const std::string &);
- int32_t order_key (std::string const &) const;
- void set_order_key (std::string const &, int32_t);
+ int32_t order_key (RouteSortOrderKey) const;
+ void set_order_key (RouteSortOrderKey, int32_t);
bool is_hidden() const { return _flags & Hidden; }
bool is_master() const { return _flags & MasterOut; }
@@ -420,19 +420,19 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
MonitorBusRemoteControlID = 319,
};
- void set_remote_control_id (uint32_t id, bool notify_class_listeners = true);
+ void set_remote_control_id (uint32_t id, bool notify_class_listeners = true);
uint32_t remote_control_id () const;
/* for things concerned about *this* route's RID */
PBD::Signal0<void> RemoteControlIDChanged;
- /* for things concerned about any route's RID changes */
+ /* for things concerned about *any* route's RID changes */
static PBD::Signal0<void> RemoteControlIDChange;
- void sync_order_keys (std::string const &);
- static PBD::Signal1<void,std::string const &> SyncOrderKeys;
+ void sync_order_keys (RouteSortOrderKey);
+ static PBD::Signal1<void,RouteSortOrderKey> SyncOrderKeys;
bool has_external_redirects() const;
@@ -518,7 +518,6 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
void silence_unlocked (framecnt_t);
ChanCount processor_max_streams;
- uint32_t _remote_control_id;
uint32_t pans_required() const;
ChanCount n_process_buffers ();
@@ -534,8 +533,9 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember,
static uint32_t order_key_cnt;
- typedef std::map<std::string, long> OrderKeys;
- OrderKeys order_keys;
+ typedef std::map<RouteSortOrderKey,int32_t> OrderKeys;
+ OrderKeys order_keys;
+ uint32_t* _remote_control_id;
void input_change_handler (IOChange, void *src);
void output_change_handler (IOChange, void *src);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 7f73d3ae77..eb84c0685e 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -235,7 +235,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
};
- void sync_order_keys (std::string const &);
+ void sync_order_keys (RouteSortOrderKey);
template<class T> void foreach_route (T *obj, void (T::*func)(Route&));
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
@@ -464,8 +464,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
void resort_routes ();
void resort_routes_using (boost::shared_ptr<RouteList>);
- void set_remote_control_ids();
-
AudioEngine & engine() { return _engine; }
AudioEngine const & engine () const { return _engine; }
@@ -1488,7 +1486,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
XMLNode& get_control_protocol_state ();
void set_history_depth (uint32_t depth);
- void sync_order_keys ();
static bool _disable_all_loaded_plugins;
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 6d05bdbbd8..713e35ebab 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -351,6 +351,12 @@ namespace ARDOUR {
PostFader
};
+ enum RouteSortOrderKey {
+ UndefinedSort,
+ EditorSort,
+ MixerSort
+ };
+
enum MonitorModel {
HardwareMonitoring, ///< JACK does monitoring
SoftwareMonitoring, ///< Ardour does monitoring
diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc
index afe92ed5f7..1ef9047f57 100644
--- a/libs/ardour/enums.cc
+++ b/libs/ardour/enums.cc
@@ -89,6 +89,7 @@ setup_enum_writer ()
AutoState _AutoState;
AutoStyle _AutoStyle;
AutoConnectOption _AutoConnectOption;
+ RouteSortOrderKey _RouteSortOrderKey;
Session::StateOfTheState _Session_StateOfTheState;
Route::Flag _Route_Flag;
Source::Flag _Source_Flag;
@@ -397,6 +398,10 @@ setup_enum_writer ()
REGISTER_CLASS_ENUM (Route, MonitorOut);
REGISTER_BITS (_Route_Flag);
+ REGISTER_ENUM (MixerSort);
+ REGISTER_ENUM (EditorSort);
+ REGISTER_BITS (_RouteSortOrderKey);
+
REGISTER_CLASS_ENUM (Source, Writable);
REGISTER_CLASS_ENUM (Source, CanRename);
REGISTER_CLASS_ENUM (Source, Broadcast);
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 83b1efce76..af30a112db 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -67,7 +67,7 @@ using namespace ARDOUR;
using namespace PBD;
uint32_t Route::order_key_cnt = 0;
-PBD::Signal1<void,string const&> Route::SyncOrderKeys;
+PBD::Signal1<void,RouteSortOrderKey> Route::SyncOrderKeys;
PBD::Signal0<void> Route::RemoteControlIDChange;
Route::Route (Session& sess, string name, Flag flg, DataType default_type)
@@ -99,14 +99,6 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _last_custom_meter_was_at_end (false)
{
processor_max_streams.reset();
- order_keys[N_("signal")] = order_key_cnt++;
-
- if (is_master()) {
- set_remote_control_id (MasterBusRemoteControlID);
- } else if (is_monitor()) {
- set_remote_control_id (MonitorBusRemoteControlID);
- }
-
}
int
@@ -203,11 +195,22 @@ Route::~Route ()
}
_processors.clear ();
+
+ delete _remote_control_id;
}
void
Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
{
+ if (Config->get_remote_model() != UserOrdered) {
+ return;
+ }
+
+ if (id < 1) {
+ error << _("Remote Control ID's start at one, not zero") << endmsg;
+ return;
+ }
+
/* force IDs for master/monitor busses and prevent
any other route from accidentally getting these IDs
(i.e. legacy sessions)
@@ -228,8 +231,11 @@ Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
id += MonitorBusRemoteControlID;
}
- if (id != _remote_control_id) {
- _remote_control_id = id;
+ if (id != remote_control_id()) {
+ if (!_remote_control_id) {
+ _remote_control_id = new uint32_t;
+ }
+ *_remote_control_id = id;
RemoteControlIDChanged ();
if (notify_class_listeners) {
RemoteControlIDChange ();
@@ -240,13 +246,27 @@ Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
uint32_t
Route::remote_control_id() const
{
- return _remote_control_id;
+ switch (Config->get_remote_model()) {
+ case MixerOrdered:
+ return order_key (MixerSort) + 1;
+ case EditorOrdered:
+ return order_key (EditorSort) + 1;
+ case UserOrdered:
+ if (_remote_control_id) {
+ return *_remote_control_id;
+ }
+ }
+
+ /* fall back to MixerSort as the default */
+
+ return order_key (MixerSort) + 1;
}
int32_t
-Route::order_key (std::string const & name) const
+Route::order_key (RouteSortOrderKey key) const
{
- OrderKeys::const_iterator i = order_keys.find (name);
+ OrderKeys::const_iterator i = order_keys.find (key);
+
if (i == order_keys.end()) {
return -1;
}
@@ -255,7 +275,7 @@ Route::order_key (std::string const & name) const
}
void
-Route::set_order_key (std::string const & name, int32_t n)
+Route::set_order_key (RouteSortOrderKey key, int32_t n)
{
bool changed = false;
@@ -265,16 +285,24 @@ Route::set_order_key (std::string const & name, int32_t n)
signal.
*/
- if (order_keys.find(name) == order_keys.end() || order_keys[name] != n) {
- order_keys[name] = n;
+ if (order_keys.find (key) == order_keys.end() || order_keys[key] != n) {
+ order_keys[key] = n;
changed = true;
}
if (Config->get_sync_all_route_ordering()) {
for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
- if (x->second != n) {
- x->second = n;
- changed = true;
+
+ /* we do not sync the signal order keys for mixer +
+ * monitor because they are considered "external" to
+ * the ordering of other routes.
+ */
+
+ if ((!is_master() && !is_monitor()) || x->first != MixerSort) {
+ if (x->second != n) {
+ x->second = n;
+ changed = true;
+ }
}
}
}
@@ -290,7 +318,7 @@ Route::set_order_key (std::string const & name, int32_t n)
* @param base Base key.
*/
void
-Route::sync_order_keys (std::string const & base)
+Route::sync_order_keys (RouteSortOrderKey base)
{
if (order_keys.empty()) {
return;
@@ -313,9 +341,17 @@ Route::sync_order_keys (std::string const & base)
bool changed = false;
for (; i != order_keys.end(); ++i) {
- if (i->second != key) {
- i->second = key;
- changed = true;
+
+ /* we do not sync the signal order keys for mixer +
+ * monitor because they are considered "external" to
+ * the ordering of other routes.
+ */
+
+ if ((!is_master() && !is_monitor()) || i->first != MixerSort) {
+ if (i->second != key) {
+ i->second = key;
+ changed = true;
+ }
}
}
@@ -1421,12 +1457,7 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
boost::shared_ptr<IOProcessor> iop;
if ((iop = boost::dynamic_pointer_cast<IOProcessor> (*i)) != 0) {
- if (iop->input()) {
- iop->input()->disconnect (this);
- }
- if (iop->output()) {
- iop->output()->disconnect (this);
- }
+ iop->disconnect ();
}
i = _processors.erase (i);
@@ -1867,9 +1898,9 @@ Route::state(bool full_state)
OrderKeys::iterator x = order_keys.begin();
while (x != order_keys.end()) {
- order_string += string ((*x).first);
+ order_string += enum_2_string ((*x).first);
order_string += '=';
- snprintf (buf, sizeof(buf), "%ld", (*x).second);
+ snprintf (buf, sizeof(buf), "%" PRId32, (*x).second);
order_string += buf;
++x;
@@ -1895,10 +1926,12 @@ Route::state(bool full_state)
node->add_child_nocopy (_mute_control->get_state ());
node->add_child_nocopy (_mute_master->get_state ());
- XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
- snprintf (buf, sizeof (buf), "%d", _remote_control_id);
- remote_control_node->add_property (X_("id"), buf);
- node->add_child_nocopy (*remote_control_node);
+ if (_remote_control_id) {
+ XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
+ snprintf (buf, sizeof (buf), "%d", *_remote_control_id);
+ remote_control_node->add_property (X_("id"), buf);
+ node->add_child_nocopy (*remote_control_node);
+ }
if (_comment.length()) {
XMLNode *cmt = node->add_child ("Comment");
@@ -2089,7 +2122,18 @@ Route::set_state (const XMLNode& node, int version)
error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
<< endmsg;
} else {
- set_order_key (remaining.substr (0, equal), n);
+ string keyname = remaining.substr (0, equal);
+ RouteSortOrderKey sk;
+
+ if (keyname == "signal") {
+ sk = MixerSort;
+ } else if (keyname == "editor") {
+ sk = EditorSort;
+ } else {
+ RouteSortOrderKey sk = (RouteSortOrderKey) string_2_enum (remaining.substr (0, equal), sk);
+ }
+
+ set_order_key (sk, n);
}
}
@@ -2285,7 +2329,18 @@ Route::set_state_2X (const XMLNode& node, int version)
error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
<< endmsg;
} else {
- set_order_key (remaining.substr (0, equal), n);
+ string keyname = remaining.substr (0, equal);
+ RouteSortOrderKey sk;
+
+ if (keyname == "signal") {
+ sk = MixerSort;
+ } else if (keyname == "editor") {
+ sk = EditorSort;
+ } else {
+ RouteSortOrderKey sk = (RouteSortOrderKey) string_2_enum (remaining.substr (0, equal), sk);
+ }
+
+ set_order_key (sk, n);
}
}
diff --git a/libs/ardour/route_graph.cc b/libs/ardour/route_graph.cc
index fbf406fd92..13264ff9fa 100644
--- a/libs/ardour/route_graph.cc
+++ b/libs/ardour/route_graph.cc
@@ -170,7 +170,7 @@ struct RouteRecEnabledComparator
if (r1->record_enabled()) {
if (r2->record_enabled()) {
/* both rec-enabled, just use signal order */
- return r1->order_key(N_("signal")) < r2->order_key(N_("signal"));
+ return r1->order_key (MixerSort) < r2->order_key (MixerSort);
} else {
/* r1 rec-enabled, r2 not rec-enabled, run r2 early */
return false;
@@ -181,7 +181,7 @@ struct RouteRecEnabledComparator
return true;
} else {
/* neither rec-enabled, use signal order */
- return r1->order_key(N_("signal")) < r2->order_key(N_("signal"));
+ return r1->order_key (MixerSort) < r2->order_key (MixerSort);
}
}
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index f6d5b2bbd1..a38f6a129a 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1515,7 +1515,7 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 signal order %2\n",
- (*i)->name(), (*i)->order_key ("signal")));
+ (*i)->name(), (*i)->order_key (MixerSort)));
}
#endif
@@ -1602,12 +1602,9 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
string port;
RouteList new_routes;
list<boost::shared_ptr<MidiTrack> > ret;
- uint32_t control_id;
cerr << "Adding MIDI track with in = " << input << " out = " << output << endl;
- control_id = next_control_id ();
-
bool const use_number = (how_many != 1) || name_template.empty () || name_template == _("MIDI");
while (how_many) {
@@ -1650,7 +1647,10 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
}
track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this));
- track->set_remote_control_id (control_id);
+
+ if (Config->get_remote_model() == UserOrdered) {
+ track->set_remote_control_id (next_control_id());
+ }
new_routes.push_back (track);
ret.push_back (track);
@@ -1839,9 +1839,6 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
string port;
RouteList new_routes;
list<boost::shared_ptr<AudioTrack> > ret;
- uint32_t control_id;
-
- control_id = next_control_id ();
bool const use_number = (how_many != 1) || name_template.empty () || name_template == _("Audio");
@@ -1892,8 +1889,9 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
track->non_realtime_input_change();
track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this));
- track->set_remote_control_id (control_id);
- ++control_id;
+ if (Config->get_remote_model() == UserOrdered) {
+ track->set_remote_control_id (next_control_id());
+ }
new_routes.push_back (track);
ret.push_back (track);
@@ -1921,33 +1919,6 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
return ret;
}
-void
-Session::set_remote_control_ids ()
-{
- RemoteModel m = Config->get_remote_model();
- bool emit_signal = false;
-
- boost::shared_ptr<RouteList> r = routes.reader ();
-
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if (MixerOrdered == m) {
- int32_t order = (*i)->order_key(N_("signal"));
- (*i)->set_remote_control_id (order+1, false);
- emit_signal = true;
- } else if (EditorOrdered == m) {
- int32_t order = (*i)->order_key(N_("editor"));
- (*i)->set_remote_control_id (order+1, false);
- emit_signal = true;
- } else if (UserOrdered == m) {
- //do nothing ... only changes to remote id's are initiated by user
- }
- }
-
- if (emit_signal) {
- Route::RemoteControlIDChange();
- }
-}
-
/** Caller must not hold process lock.
* @param name_template string to use for the start of the name, or "" to use "Bus".
*/
@@ -1958,9 +1929,6 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
uint32_t bus_id = 0;
string port;
RouteList ret;
- uint32_t control_id;
-
- control_id = next_control_id ();
bool const use_number = (how_many != 1) || name_template.empty () || name_template == _("Bus");
@@ -2002,8 +1970,9 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
if (route_group) {
route_group->add (bus);
}
- bus->set_remote_control_id (control_id);
- ++control_id;
+ if (Config->get_remote_model() == UserOrdered) {
+ bus->set_remote_control_id (next_control_id());
+ }
bus->add_internal_return ();
@@ -2390,7 +2359,7 @@ Session::remove_route (boost::shared_ptr<Route> route)
route->drop_references ();
- sync_order_keys (N_("session"));
+ sync_order_keys (UndefinedSort);
Route::RemoteControlIDChange(); /* EMIT SIGNAL */
@@ -3481,7 +3450,7 @@ Session::RoutePublicOrderSorter::operator() (boost::shared_ptr<Route> a, boost::
if (b->is_monitor()) {
return false;
}
- return a->order_key(N_("signal")) < b->order_key(N_("signal"));
+ return a->order_key (MixerSort) < b->order_key (MixerSort);
}
bool
@@ -4182,7 +4151,7 @@ Session::add_automation_list(AutomationList *al)
}
void
-Session::sync_order_keys (std::string const & base)
+Session::sync_order_keys (RouteSortOrderKey base)
{
if (deletion_in_progress()) {
return;
@@ -4200,10 +4169,6 @@ Session::sync_order_keys (std::string const & base)
}
Route::SyncOrderKeys (base); // EMIT SIGNAL
-
- /* this might not do anything */
-
- set_remote_control_ids ();
}
/** @return true if there is at least one record-enabled track, otherwise false */
@@ -4781,7 +4746,32 @@ Session::session_name_is_legal (const string& path)
uint32_t
Session::next_control_id () const
{
- return ntracks() + nbusses() + 1;
+ int subtract = 0;
+
+ /* the master and monitor bus remote ID's occupy a different
+ * "namespace" than regular routes. their existence doesn't
+ * affect normal (low) numbered routes.
+ */
+
+ if (_master_out) {
+ subtract++;
+ }
+
+ if (_monitor_out) {
+ subtract++;
+ }
+
+ /* remote control IDs are based either on this
+ value, or signal order, which is zero-based. so we have
+ to ensure consistency of zero-based-ness for both
+ sources of the number.
+
+ we actually add 1 to the value to form an actual
+ remote control ID, which is 1-based.
+ */
+
+ cerr << "Next control ID will be " << ntracks() + (nbusses() - subtract) << endl;
+ return ntracks() + (nbusses() - subtract);
}
bool
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 9ea202ee67..1509a757eb 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -3109,11 +3109,13 @@ Session::controllable_by_descriptor (const ControllableDescriptor& desc)
}
case ControllableDescriptor::RemoteControlID:
+ cerr << "RID " << desc.rid() << endl;
r = route_by_remote_id (desc.rid());
break;
}
if (!r) {
+ cerr << "no controllable with no route\n";
return c;
}
@@ -3196,11 +3198,15 @@ Session::controllable_by_descriptor (const ControllableDescriptor& desc)
--send;
}
+ cerr << "Look for send " << send << endl;
+
boost::shared_ptr<Processor> p = r->nth_send (send);
if (p) {
boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
boost::shared_ptr<Amp> a = s->amp();
+
+ cerr << " looked for send " << send << " got " << s << " amp = " << a << endl;
if (a) {
c = s->amp()->gain_control();
@@ -3551,14 +3557,12 @@ Session::config_changed (std::string p, bool ours)
} else {
switch_to_sync_source (config.get_sync_source());
}
- } else if (p == "remote-model") {
- set_remote_control_ids ();
} else if (p == "denormal-model") {
setup_fpu ();
} else if (p == "history-depth") {
set_history_depth (Config->get_history_depth());
} else if (p == "sync-all-route-ordering") {
- sync_order_keys ("session");
+ sync_order_keys (UndefinedSort);
} else if (p == "initial-program-change") {
if (MIDI::Manager::instance()->mmc()->output_port() && Config->get_initial_program_change() >= 0) {