+
+/** If the meter point is `Custom', make a note of where the meter is.
+ * This is so that if the meter point is subsequently set to something else,
+ * and then back to custom, we can put the meter back where it was last time
+ * custom was enabled.
+ *
+ * Must be called with the _processor_lock held.
+ */
+void
+Route::maybe_note_meter_position ()
+{
+ if (_meter_point != MeterCustom) {
+ return;
+ }
+
+ _custom_meter_position_noted = true;
+ for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ if (boost::dynamic_pointer_cast<PeakMeter> (*i)) {
+ ProcessorList::iterator j = i;
+ ++j;
+ if (j != _processors.end ()) {
+ _processor_after_last_custom_meter = *j;
+ _last_custom_meter_was_at_end = false;
+ } else {
+ _last_custom_meter_was_at_end = true;
+ }
+ }
+ }
+}
+
+boost::shared_ptr<Processor>
+Route::processor_by_id (PBD::ID id) const
+{
+ Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
+ for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ if ((*i)->id() == id) {
+ return *i;
+ }
+ }
+
+ return boost::shared_ptr<Processor> ();
+}
+
+/** @return the monitoring state, or in other words what data we are pushing
+ * into the route (data from the inputs, data from disk or silence)
+ */
+MonitorState
+Route::monitoring_state () const
+{
+ return MonitoringInput;
+}
+
+/** @return what we should be metering; either the data coming from the input
+ * IO or the data that is flowing through the route.
+ */
+MeterState
+Route::metering_state () const
+{
+ return MeteringRoute;
+}
+
+bool
+Route::has_external_redirects () const
+{
+ for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+
+ /* ignore inactive processors and obviously ignore the main
+ * outs since everything has them and we don't care.
+ */
+
+ if ((*i)->active() && (*i) != _main_outs && (*i)->does_routing()) {
+ return true;;
+ }
+ }
+
+ return false;
+}
+
+boost::shared_ptr<Processor>
+Route::the_instrument () const
+{
+ Glib::Threads::RWLock::WriterLock lm (_processor_lock);
+ return the_instrument_unlocked ();
+}
+
+boost::shared_ptr<Processor>
+Route::the_instrument_unlocked () const
+{
+ for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ if (boost::dynamic_pointer_cast<PluginInsert>(*i)) {
+ if ((*i)->input_streams().n_midi() > 0 &&
+ (*i)->output_streams().n_audio() > 0) {
+ return (*i);
+ }
+ }
+ }
+ return boost::shared_ptr<Processor>();
+}
+
+
+
+void
+Route::non_realtime_locate (framepos_t pos)
+{
+ if (_pannable) {
+ _pannable->transport_located (pos);
+ }
+
+ {
+ Glib::Threads::RWLock::WriterLock lm (_processor_lock);
+
+ for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ (*i)->transport_located (pos);
+ }
+ }
+}