diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/debug.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/route.h | 11 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 1 | ||||
-rw-r--r-- | libs/ardour/debug.cc | 1 | ||||
-rw-r--r-- | libs/ardour/enums.cc | 2 | ||||
-rw-r--r-- | libs/ardour/route.cc | 124 | ||||
-rw-r--r-- | libs/ardour/session.cc | 89 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 8 |
9 files changed, 99 insertions, 142 deletions
diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h index b9ecabd309..5c72c9236f 100644 --- a/libs/ardour/ardour/debug.h +++ b/libs/ardour/ardour/debug.h @@ -59,6 +59,7 @@ namespace PBD { extern uint64_t Layering; extern uint64_t TempoMath; extern uint64_t TempoMap; + extern uint64_t OrderKeys; } } diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index a15937377e..695e151dbb 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -101,8 +101,10 @@ 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 (RouteSortOrderKey) const; - void set_order_key (RouteSortOrderKey, int32_t); + uint32_t order_key (RouteSortOrderKey) const; + bool has_order_key (RouteSortOrderKey) const; + void set_order_key (RouteSortOrderKey, uint32_t); + void sync_order_keys (RouteSortOrderKey); bool is_hidden() const { return _flags & Hidden; } bool is_master() const { return _flags & MasterOut; } @@ -286,7 +288,6 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, PBD::Signal0<void> meter_change; PBD::Signal0<void> signal_latency_changed; PBD::Signal0<void> initial_delay_changed; - PBD::Signal0<void> order_key_changed; /** Emitted with the process lock held */ PBD::Signal0<void> io_changed; @@ -430,8 +431,6 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, /* for things concerned about *any* route's RID changes */ static PBD::Signal0<void> RemoteControlIDChange; - - void sync_order_keys (RouteSortOrderKey); static PBD::Signal1<void,RouteSortOrderKey> SyncOrderKeys; bool has_external_redirects() const; @@ -533,7 +532,7 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, static uint32_t order_key_cnt; - typedef std::map<RouteSortOrderKey,int32_t> OrderKeys; + typedef std::map<RouteSortOrderKey,uint32_t> OrderKeys; OrderKeys order_keys; uint32_t* _remote_control_id; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 518a99d961..a132a4a5e8 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -806,8 +806,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void send_mmc_locate (framepos_t); int send_full_time_code (framepos_t); - PBD::Signal0<void> RouteOrderKeyChanged; - bool step_editing() const { return (_step_editors > 0); } void request_suspend_timecode_transmission (); @@ -1503,8 +1501,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void setup_midi_machine_control (); - void route_order_key_changed (); - void step_edit_status_change (bool); uint32_t _step_editors; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 713e35ebab..595ee38369 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -352,7 +352,6 @@ namespace ARDOUR { }; enum RouteSortOrderKey { - UndefinedSort, EditorSort, MixerSort }; diff --git a/libs/ardour/debug.cc b/libs/ardour/debug.cc index a0fc09a2ad..db0f409d11 100644 --- a/libs/ardour/debug.cc +++ b/libs/ardour/debug.cc @@ -56,5 +56,6 @@ uint64_t PBD::DEBUG::MidiTrackers = PBD::new_debug_bit ("miditrackers"); uint64_t PBD::DEBUG::Layering = PBD::new_debug_bit ("layering"); uint64_t PBD::DEBUG::TempoMath = PBD::new_debug_bit ("tempomath"); uint64_t PBD::DEBUG::TempoMap = PBD::new_debug_bit ("tempomap"); +uint64_t PBD::DEBUG::OrderKeys = PBD::new_debug_bit ("orderkeys"); diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 1ef9047f57..042b10adb5 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -400,7 +400,7 @@ setup_enum_writer () REGISTER_ENUM (MixerSort); REGISTER_ENUM (EditorSort); - REGISTER_BITS (_RouteSortOrderKey); + REGISTER (_RouteSortOrderKey); REGISTER_CLASS_ENUM (Source, Writable); REGISTER_CLASS_ENUM (Source, CanRename); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 62bb2d0933..2112336d8b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -247,116 +247,84 @@ uint32_t Route::remote_control_id() const { 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; } + break; + default: + break; + } + + if (is_master()) { + return MasterBusRemoteControlID; + } + + if (is_monitor()) { + return MonitorBusRemoteControlID; } - /* fall back to MixerSort as the default */ + /* order keys are zero-based, remote control ID's are one-based + */ + + switch (Config->get_remote_model()) { + case EditorOrdered: + return order_key (EditorSort) + 1; + case MixerOrdered: + default: + return order_key (MixerSort) + 1; + } +} - return order_key (MixerSort) + 1; +bool +Route::has_order_key (RouteSortOrderKey key) const +{ + return (order_keys.find (key) != order_keys.end()); } -int32_t +uint32_t Route::order_key (RouteSortOrderKey key) const { OrderKeys::const_iterator i = order_keys.find (key); if (i == order_keys.end()) { - return -1; + return 0; } return i->second; } void -Route::set_order_key (RouteSortOrderKey key, int32_t n) +Route::sync_order_keys (RouteSortOrderKey base) { - bool changed = false; + OrderKeys::iterator i = order_keys.find (base); - /* This method looks more complicated than it should, but - it's important that we don't emit order_key_changed unless - it actually has, as expensive things happen on receipt of that - signal. - */ - - if (order_keys.find (key) == order_keys.end() || order_keys[key] != n) { - order_keys[key] = n; - changed = true; + if (i == order_keys.end()) { + return; } - if (Config->get_sync_all_route_ordering()) { - for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) { + for (OrderKeys::iterator k = order_keys.begin(); k != order_keys.end(); ++k) { - /* we do not sync the signal order keys for mixer + - * monitor because they are considered "external" to - * the ordering of other routes. + if (k->first == MixerSort && (is_master() || is_monitor())) { + /* don't sync the mixer sort keys for master/monitor, + * since they are not part of the normal ordering. */ - - if ((!is_master() && !is_monitor()) || x->first != MixerSort) { - if (x->second != n) { - x->second = n; - changed = true; - } - } + + continue; + } + + if (k->first != base) { + k->second = i->second; } - } - - if (changed) { - order_key_changed (); /* EMIT SIGNAL */ - _session.set_dirty (); } } -/** Set all order keys to be the same as that for `base', if such a key - * exists in this route. - * @param base Base key. - */ void -Route::sync_order_keys (RouteSortOrderKey base) +Route::set_order_key (RouteSortOrderKey key, uint32_t n) { - if (order_keys.empty()) { - return; - } - - OrderKeys::iterator i; - int32_t key; - - if ((i = order_keys.find (base)) == order_keys.end()) { - /* key doesn't exist, use the first existing key (during session initialization) */ - i = order_keys.begin(); - key = i->second; - ++i; - } else { - /* key exists - use it and reset all others (actually, itself included) */ - key = i->second; - i = order_keys.begin(); - } - - bool changed = false; - - for (; i != order_keys.end(); ++i) { - - /* 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; - } - } - } - - if (changed) { - order_key_changed (); /* EMIT SIGNAL */ + if (order_keys.find (key) == order_keys.end() || order_keys[key] != n) { + order_keys[key] = n; + _session.set_dirty (); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 9dacdc34cb..062d07ec26 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2103,6 +2103,7 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output { ChanCount existing_inputs; ChanCount existing_outputs; + uint32_t order = next_control_id(); count_existing_track_channels (existing_inputs, existing_outputs); @@ -2133,7 +2134,6 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output r->mute_changed.connect_same_thread (*this, boost::bind (&Session::route_mute_changed, this, _1)); r->output()->changed.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2)); r->processors_changed.connect_same_thread (*this, boost::bind (&Session::route_processors_changed, this, _1)); - r->order_key_changed.connect_same_thread (*this, boost::bind (&Session::route_order_key_changed, this)); if (r->is_master()) { _master_out = r; @@ -2159,6 +2159,24 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output if (input_auto_connect || output_auto_connect) { auto_connect_route (r, existing_inputs, existing_outputs, true, input_auto_connect); } + + /* order keys are a GUI responsibility but we need to set up + reasonable defaults because they also affect the remote control + ID in most situations. + */ + + if (!r->has_order_key (EditorSort)) { + if (r->is_hidden()) { + /* use an arbitrarily high value */ + r->set_order_key (EditorSort, UINT_MAX); + r->set_order_key (MixerSort, UINT_MAX); + } else { + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("while adding, set %1 to order key %2\n", r->name(), order)); + r->set_order_key (EditorSort, order); + r->set_order_key (MixerSort, order); + order++; + } + } } if (_monitor_out && IO::connecting_legal) { @@ -2355,8 +2373,6 @@ Session::remove_route (boost::shared_ptr<Route> route) route->drop_references (); - sync_order_keys (UndefinedSort); - Route::RemoteControlIDChange(); /* EMIT SIGNAL */ /* save the new state of the world */ @@ -4096,27 +4112,6 @@ Session::add_automation_list(AutomationList *al) automation_lists[al->id()] = al; } -void -Session::sync_order_keys (RouteSortOrderKey base) -{ - if (deletion_in_progress()) { - return; - } - - if (!Config->get_sync_all_route_ordering()) { - /* leave order keys as they are */ - return; - } - - boost::shared_ptr<RouteList> r = routes.reader (); - - for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - (*i)->sync_order_keys (base); - } - - Route::SyncOrderKeys (base); // EMIT SIGNAL -} - /** @return true if there is at least one record-enabled track, otherwise false */ bool Session::have_rec_enabled_track () const @@ -4268,13 +4263,6 @@ Session::add_session_range_location (framepos_t start, framepos_t end) _locations->add (_session_range_location); } -/** Called when one of our routes' order keys has changed */ -void -Session::route_order_key_changed () -{ - RouteOrderKeyChanged (); /* EMIT SIGNAL */ -} - void Session::step_edit_status_change (bool yn) { @@ -4694,30 +4682,41 @@ Session::next_control_id () const { int subtract = 0; - /* the master and monitor bus remote ID's occupy a different - * "namespace" than regular routes. their existence doesn't + /* the monitor bus remote ID is in a different + * "namespace" than regular routes. its existence doesn't * affect normal (low) numbered routes. */ - if (_master_out) { + if (_monitor_out) { subtract++; } - if (_monitor_out) { - subtract++; + return nroutes() - subtract; +} + +void +Session::sync_order_keys (RouteSortOrderKey sort_key_changed) +{ + if (deletion_in_progress()) { + return; } - /* 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. + switch (Config->get_remote_model()) { + case MixerSort: + case EditorSort: + Route::RemoteControlIDChange (); /* EMIT SIGNAL */ + break; + default: + break; + } + + /* tell everyone that something has happened to the sort keys + and let them sync up with the change(s) */ - cerr << "Next control ID will be " << ntracks() + (nbusses() - subtract) << endl; - return ntracks() + (nbusses() - subtract); + DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("Sync Order Keys, based on %1\n", enum_2_string (sort_key_changed))); + + Route::SyncOrderKeys (sort_key_changed); /* EMIT SIGNAL */ } bool diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 40cb364d73..da6f618c11 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3060,13 +3060,11 @@ 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; } @@ -3149,16 +3147,12 @@ 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(); } @@ -3513,7 +3507,7 @@ Session::config_changed (std::string p, bool ours) } else if (p == "history-depth") { set_history_depth (Config->get_history_depth()); } else if (p == "sync-all-route-ordering") { - sync_order_keys (UndefinedSort); + /* XXX sync_order_keys (UndefinedSort); */ } else if (p == "initial-program-change") { if (MIDI::Manager::instance()->mmc()->output_port() && Config->get_initial_program_change() >= 0) { |