2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "pbd/xml++.h"
26 #include "pbd/enumwriter.h"
27 #include "pbd/memento_command.h"
28 #include "pbd/stacktrace.h"
30 #include "evoral/Curve.hpp"
32 #include "ardour/amp.h"
33 #include "ardour/audio_port.h"
34 #include "ardour/audioengine.h"
35 #include "ardour/buffer.h"
36 #include "ardour/buffer_set.h"
37 #include "ardour/configuration.h"
38 #include "ardour/cycle_timer.h"
39 #include "ardour/debug.h"
40 #include "ardour/delivery.h"
41 #include "ardour/dB.h"
42 #include "ardour/internal_send.h"
43 #include "ardour/internal_return.h"
44 #include "ardour/ladspa_plugin.h"
45 #include "ardour/meter.h"
46 #include "ardour/mix.h"
47 #include "ardour/panner.h"
48 #include "ardour/plugin_insert.h"
49 #include "ardour/port.h"
50 #include "ardour/port_insert.h"
51 #include "ardour/processor.h"
52 #include "ardour/profile.h"
53 #include "ardour/route.h"
54 #include "ardour/route_group.h"
55 #include "ardour/send.h"
56 #include "ardour/session.h"
57 #include "ardour/timestamps.h"
58 #include "ardour/utils.h"
63 using namespace ARDOUR
;
66 uint32_t Route::order_key_cnt
= 0;
67 PBD::Signal1
<void,string
const&> Route::SyncOrderKeys
;
68 PBD::Signal0
<void> Route::RemoteControlIDChange
;
70 Route::Route (Session
& sess
, string name
, Flag flg
, DataType default_type
)
71 : SessionObject (sess
, name
)
72 , AutomatableControls (sess
)
74 , _solo_control (new SoloControllable (X_("solo"), *this))
75 , _mute_master (new MuteMaster (sess
, name
))
76 , _default_type (default_type
)
81 /* add standard processors other than amp (added by ::init()) */
83 _meter
.reset (new PeakMeter (_session
));
84 _meter
->set_display_to_user (false);
85 add_processor (_meter
, PostFader
);
87 if (_flags
& ControlOut
) {
88 /* where we listen to tracks */
89 _intreturn
.reset (new InternalReturn (_session
));
90 add_processor (_intreturn
, PreFader
);
93 _main_outs
.reset (new Delivery (_session
, _output
, _mute_master
, _name
, Delivery::Main
));
94 add_processor (_main_outs
, PostFader
);
96 /* now that we have _meter, its safe to connect to this */
98 Metering::Meter
.connect_same_thread (*this, (boost::bind (&Route::meter
, this)));
101 Route::Route (Session
& sess
, const XMLNode
& node
, DataType default_type
)
102 : SessionObject (sess
, "toBeReset")
103 , AutomatableControls (sess
)
104 , _solo_control (new SoloControllable (X_("solo"), *this))
105 , _mute_master (new MuteMaster (sess
, "toBeReset"))
106 , _default_type (default_type
)
110 _set_state (node
, Stateful::loading_state_version
, false);
112 /* now that we have _meter, its safe to connect to this */
114 Metering::Meter
.connect_same_thread (*this, (boost::bind (&Route::meter
, this)));
121 _soloed_by_others
= 0;
125 processor_max_streams
.reset();
127 order_keys
[N_("signal")] = order_key_cnt
++;
129 _meter_point
= MeterPostFader
;
132 _have_internal_generator
= false;
133 _declickable
= false;
134 _pending_declick
= true;
135 _remote_control_id
= 0;
136 _in_configure_processors
= false;
137 _mute_points
= MuteMaster::AllPoints
;
140 _denormal_protection
= false;
142 /* add standard controls */
144 add_control (_solo_control
);
145 add_control (_mute_master
);
147 /* input and output objects */
149 _input
.reset (new IO (_session
, _name
, IO::Input
, _default_type
));
150 _output
.reset (new IO (_session
, _name
, IO::Output
, _default_type
));
152 _input
->changed
.connect_same_thread (*this, boost::bind (&Route::input_change_handler
, this, _1
, _2
));
153 _output
->changed
.connect_same_thread (*this, boost::bind (&Route::output_change_handler
, this, _1
, _2
));
155 /* add amp processor */
157 _amp
.reset (new Amp (_session
, _mute_master
));
158 add_processor (_amp
, PostFader
);
163 DEBUG_TRACE (DEBUG::Destruction
, string_compose ("route %1 destructor\n", _name
));
165 /* don't use clear_processors here, as it depends on the session which may
166 be half-destroyed by now */
168 Glib::RWLock::WriterLock
lm (_processor_lock
);
169 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
170 (*i
)->drop_references ();
173 _processors
.clear ();
177 Route::set_remote_control_id (uint32_t id
)
179 if (id
!= _remote_control_id
) {
180 _remote_control_id
= id
;
181 RemoteControlIDChanged ();
182 RemoteControlIDChange ();
187 Route::remote_control_id() const
189 return _remote_control_id
;
193 Route::order_key (std::string
const & name
) const
195 OrderKeys::const_iterator i
= order_keys
.find (name
);
196 if (i
== order_keys
.end()) {
204 Route::set_order_key (std::string
const & name
, long n
)
206 order_keys
[name
] = n
;
208 if (Config
->get_sync_all_route_ordering()) {
209 for (OrderKeys::iterator x
= order_keys
.begin(); x
!= order_keys
.end(); ++x
) {
214 _session
.set_dirty ();
217 /** Set all order keys to be the same as that for `base', if such a key
218 * exists in this route.
219 * @param base Base key.
222 Route::sync_order_keys (std::string
const & base
)
224 if (order_keys
.empty()) {
228 OrderKeys::iterator i
;
231 if ((i
= order_keys
.find (base
)) == order_keys
.end()) {
232 /* key doesn't exist, use the first existing key (during session initialization) */
233 i
= order_keys
.begin();
237 /* key exists - use it and reset all others (actually, itself included) */
239 i
= order_keys
.begin();
242 for (; i
!= order_keys
.end(); ++i
) {
248 Route::ensure_track_or_route_name(string name
, Session
&session
)
250 string newname
= name
;
252 while (session
.route_by_name (newname
) != NULL
) {
253 newname
= bump_name_once (newname
);
261 Route::inc_gain (gain_t fraction
, void *src
)
263 _amp
->inc_gain (fraction
, src
);
267 Route::set_gain (gain_t val
, void *src
)
269 if (src
!= 0 && _route_group
&& src
!= _route_group
&& _route_group
->active_property (RouteGroup::Gain
)) {
271 if (_route_group
->is_relative()) {
273 gain_t usable_gain
= _amp
->gain();
274 if (usable_gain
< 0.000001f
) {
275 usable_gain
= 0.000001f
;
279 if (delta
< 0.000001f
) {
283 delta
-= usable_gain
;
288 gain_t factor
= delta
/ usable_gain
;
291 factor
= _route_group
->get_max_factor(factor
);
292 if (factor
== 0.0f
) {
293 _amp
->gain_control()->Changed(); /* EMIT SIGNAL */
297 factor
= _route_group
->get_min_factor(factor
);
298 if (factor
== 0.0f
) {
299 _amp
->gain_control()->Changed(); /* EMIT SIGNAL */
304 _route_group
->apply (&Route::inc_gain
, factor
, _route_group
);
308 _route_group
->apply (&Route::set_gain
, val
, _route_group
);
314 if (val
== _amp
->gain()) {
318 _amp
->set_gain (val
, src
);
321 /** Process this route for one (sub) cycle (process thread)
323 * @param bufs Scratch buffers to use for the signal path
324 * @param start_frame Initial transport frame
325 * @param end_frame Final transport frame
326 * @param nframes Number of frames to output (to ports)
328 * Note that (end_frame - start_frame) may not be equal to nframes when the
329 * transport speed isn't 1.0 (eg varispeed).
332 Route::process_output_buffers (BufferSet
& bufs
,
333 sframes_t start_frame
, sframes_t end_frame
, nframes_t nframes
,
334 bool /*with_processors*/, int declick
)
338 bufs
.is_silent (false);
340 switch (Config
->get_monitoring_model()) {
341 case HardwareMonitoring
:
342 case ExternalMonitoring
:
343 monitor
= !record_enabled() || (_session
.config
.get_auto_input() && !_session
.actively_recording());
350 declick
= _pending_declick
;
353 /* figure out if we're going to use gain automation */
354 _amp
->setup_gain_automation (start_frame
, end_frame
, nframes
);
357 /* tell main outs what to do about monitoring */
358 _main_outs
->no_outs_cuz_we_no_monitor (!monitor
);
361 /* -------------------------------------------------------------------------------------------
362 GLOBAL DECLICK (for transport changes etc.)
363 ----------------------------------------------------------------------------------------- */
366 Amp::apply_gain (bufs
, nframes
, 0.0, 1.0);
367 } else if (declick
< 0) {
368 Amp::apply_gain (bufs
, nframes
, 1.0, 0.0);
371 _pending_declick
= 0;
373 /* -------------------------------------------------------------------------------------------
374 DENORMAL CONTROL/PHASE INVERT
375 ----------------------------------------------------------------------------------------- */
381 if (_denormal_protection
|| Config
->get_denormal_protection()) {
383 for (BufferSet::audio_iterator i
= bufs
.audio_begin(); i
!= bufs
.audio_end(); ++i
, ++chn
) {
384 Sample
* const sp
= i
->data();
386 if (_phase_invert
& chn
) {
387 for (nframes_t nx
= 0; nx
< nframes
; ++nx
) {
392 for (nframes_t nx
= 0; nx
< nframes
; ++nx
) {
400 for (BufferSet::audio_iterator i
= bufs
.audio_begin(); i
!= bufs
.audio_end(); ++i
, ++chn
) {
401 Sample
* const sp
= i
->data();
403 if (_phase_invert
& chn
) {
404 for (nframes_t nx
= 0; nx
< nframes
; ++nx
) {
413 if (_denormal_protection
|| Config
->get_denormal_protection()) {
415 for (BufferSet::audio_iterator i
= bufs
.audio_begin(); i
!= bufs
.audio_end(); ++i
) {
416 Sample
* const sp
= i
->data();
417 for (nframes_t nx
= 0; nx
< nframes
; ++nx
) {
425 /* -------------------------------------------------------------------------------------------
427 ----------------------------------------------------------------------------------------- */
429 Glib::RWLock::ReaderLock
rm (_processor_lock
, Glib::TRY_LOCK
);
432 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
434 if (bufs
.count() != (*i
)->input_streams()) {
435 cerr
<< _name
<< " bufs = " << bufs
.count()
436 << " input for " << (*i
)->name() << " = " << (*i
)->input_streams()
439 assert (bufs
.count() == (*i
)->input_streams());
441 (*i
)->run (bufs
, start_frame
, end_frame
, nframes
, *i
!= _processors
.back());
442 bufs
.set_count (ChanCount::max(bufs
.count(), (*i
)->output_streams()));
445 if (!_processors
.empty()) {
446 bufs
.set_count (ChanCount::max (bufs
.count(), _processors
.back()->output_streams()));
452 Route::n_process_buffers ()
454 return max (_input
->n_ports(), processor_max_streams
);
458 Route::passthru (sframes_t start_frame
, sframes_t end_frame
, nframes_t nframes
, int declick
)
460 BufferSet
& bufs
= _session
.get_scratch_buffers (n_process_buffers());
464 assert (bufs
.available() >= _input
->n_ports());
466 if (_input
->n_ports() == ChanCount::ZERO
) {
470 bufs
.set_count (_input
->n_ports());
472 if (is_control() && _session
.listening()) {
474 /* control/monitor bus ignores input ports when something is
475 feeding the listen "stream". data will "arrive" into the
476 route from the intreturn processor element.
479 bufs
.silence (nframes
, 0);
483 for (DataType::iterator t
= DataType::begin(); t
!= DataType::end(); ++t
) {
485 BufferSet::iterator o
= bufs
.begin(*t
);
486 PortSet
& ports (_input
->ports());
488 for (PortSet::iterator i
= ports
.begin(*t
); i
!= ports
.end(*t
); ++i
, ++o
) {
489 o
->read_from (i
->get_buffer(nframes
), nframes
);
494 write_out_of_band_data (bufs
, start_frame
, end_frame
, nframes
);
495 process_output_buffers (bufs
, start_frame
, end_frame
, nframes
, true, declick
);
499 Route::passthru_silence (sframes_t start_frame
, sframes_t end_frame
, nframes_t nframes
, int declick
)
501 BufferSet
& bufs (_session
.get_silent_buffers (n_process_buffers()));
502 bufs
.set_count (_input
->n_ports());
503 write_out_of_band_data (bufs
, start_frame
, end_frame
, nframes
);
504 process_output_buffers (bufs
, start_frame
, end_frame
, nframes
, true, declick
);
508 Route::set_listen (bool yn
, void* src
)
511 if (yn
!= _control_outs
->active()) {
513 _control_outs
->activate ();
515 _control_outs
->deactivate ();
518 listen_changed (src
); /* EMIT SIGNAL */
524 Route::listening () const
527 return _control_outs
->active ();
534 Route::set_solo_safe (bool yn
, void *src
)
536 if (_solo_safe
!= yn
) {
538 solo_safe_changed (src
);
543 Route::solo_safe() const
549 Route::set_solo (bool yn
, void *src
)
555 if (_route_group
&& src
!= _route_group
&& _route_group
->active_property (RouteGroup::Solo
)) {
556 _route_group
->apply (&Route::set_solo
, yn
, _route_group
);
560 if (self_soloed() != yn
) {
562 set_delivery_solo ();
563 solo_changed (src
); /* EMIT SIGNAL */
564 _solo_control
->Changed (); /* EMIT SIGNAL */
569 Route::set_self_solo (bool yn
)
575 Route::mod_solo_by_others (int32_t delta
)
578 if (_soloed_by_others
>= (uint32_t) delta
) {
579 _soloed_by_others
+= delta
;
581 _soloed_by_others
= 0;
584 _soloed_by_others
+= delta
;
587 set_delivery_solo ();
591 Route::set_delivery_solo ()
593 /* tell all delivery processors what the solo situation is, so that they keep
594 delivering even though Session::soloing() is true and they were not
598 Glib::RWLock::ReaderLock
rm (_processor_lock
);
599 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
600 boost::shared_ptr
<Delivery
> d
;
602 if ((d
= boost::dynamic_pointer_cast
<Delivery
> (*i
)) != 0) {
603 d
->set_solo_level (soloed ());
604 d
->set_solo_isolated (solo_isolated());
610 Route::set_solo_isolated (bool yn
, void *src
)
612 if (is_master() || is_control() || is_hidden()) {
616 if (_route_group
&& src
!= _route_group
&& _route_group
->active_property (RouteGroup::Solo
)) {
617 _route_group
->apply (&Route::set_solo_isolated
, yn
, _route_group
);
621 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
623 boost::shared_ptr
<RouteList
> routes
= _session
.get_routes ();
624 for (RouteList::iterator i
= routes
->begin(); i
!= routes
->end(); ++i
) {
626 bool does_feed
= feeds (*i
, &sends_only
);
628 if (does_feed
&& !sends_only
) {
629 (*i
)->set_solo_isolated (yn
, (*i
)->route_group());
633 bool changed
= false;
636 if (_solo_isolated
== 0) {
641 changed
= (_solo_isolated
== 1);
642 if (_solo_isolated
> 0) {
648 set_delivery_solo ();
649 solo_isolated_changed (src
);
654 Route::solo_isolated () const
656 return _solo_isolated
> 0;
660 Route::set_mute_points (MuteMaster::MutePoint mp
)
663 mute_points_changed (); /* EMIT SIGNAL */
665 if (_mute_master
->muted()) {
666 _mute_master
->mute_at (_mute_points
);
667 mute_changed (this); /* EMIT SIGNAL */
672 Route::set_mute (bool yn
, void *src
)
674 if (_route_group
&& src
!= _route_group
&& _route_group
->active_property (RouteGroup::Mute
)) {
675 _route_group
->apply (&Route::set_mute
, yn
, _route_group
);
681 _mute_master
->mute_at (_mute_points
);
683 _mute_master
->clear_mute ();
686 mute_changed (src
); /* EMIT SIGNAL */
693 return _mute_master
->muted ();
698 dump_processors(const string
& name
, const list
<boost::shared_ptr
<Processor
> >& procs
)
700 cerr
<< name
<< " {" << endl
;
701 for (list
<boost::shared_ptr
<Processor
> >::const_iterator p
= procs
.begin();
702 p
!= procs
.end(); ++p
) {
703 cerr
<< "\t" << (*p
)->name() << " ID = " << (*p
)->id() << endl
;
710 Route::add_processor (boost::shared_ptr
<Processor
> processor
, Placement placement
, ProcessorStreams
* err
)
712 ProcessorList::iterator loc
;
714 /* XXX this is not thread safe - we don't hold the lock across determining the iter
715 to add before and actually doing the insertion. dammit.
718 if (placement
== PreFader
) {
719 /* generic pre-fader: insert immediately before the amp */
720 loc
= find (_processors
.begin(), _processors
.end(), _amp
);
722 /* generic post-fader: insert right before the main outs */
723 loc
= find (_processors
.begin(), _processors
.end(), _main_outs
);
726 return add_processor (processor
, loc
, err
);
730 /** Add a processor to the route.
731 * If @a iter is not NULL, it must point to an iterator in _processors and the new
732 * processor will be inserted immediately before this location. Otherwise,
733 * @a position is used.
736 Route::add_processor (boost::shared_ptr
<Processor
> processor
, ProcessorList::iterator iter
, ProcessorStreams
* err
)
738 ChanCount old_pms
= processor_max_streams
;
740 if (!_session
.engine().connected() || !processor
) {
745 Glib::RWLock::WriterLock
lm (_processor_lock
);
747 boost::shared_ptr
<PluginInsert
> pi
;
748 boost::shared_ptr
<PortInsert
> porti
;
750 ProcessorList::iterator loc
= find(_processors
.begin(), _processors
.end(), processor
);
752 if (processor
== _amp
|| processor
== _meter
|| processor
== _main_outs
) {
753 // Ensure only one of these are in the list at any time
754 if (loc
!= _processors
.end()) {
755 if (iter
== loc
) { // Already in place, do nothing
757 } else { // New position given, relocate
758 _processors
.erase (loc
);
763 if (loc
!= _processors
.end()) {
764 cerr
<< "ERROR: Processor added to route twice!" << endl
;
771 _processors
.insert (loc
, processor
);
773 // Set up processor list channels. This will set processor->[input|output]_streams(),
774 // configure redirect ports properly, etc.
776 if (configure_processors_unlocked (err
)) {
777 ProcessorList::iterator ploc
= loc
;
779 _processors
.erase(ploc
);
780 configure_processors_unlocked (0); // it worked before we tried to add it ...
781 cerr
<< "configure failed\n";
785 if ((pi
= boost::dynamic_pointer_cast
<PluginInsert
>(processor
)) != 0) {
787 if (pi
->natural_input_streams() == ChanCount::ZERO
) {
788 /* generator plugin */
789 _have_internal_generator
= true;
794 if (_control_outs
!= processor
) {
795 // XXX: do we want to emit the signal here ? change call order.
796 processor
->activate ();
799 processor
->ActiveChanged
.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation
, &_session
, false, false));
801 _output
->set_user_latency (0);
804 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
810 Route::add_processor_from_xml (const XMLNode
& node
, ProcessorList::iterator iter
)
812 const XMLProperty
*prop
;
814 if (node
.name() != "Processor") {
819 if ((prop
= node
.property ("type")) != 0) {
821 boost::shared_ptr
<Processor
> processor
;
823 if (prop
->value() == "ladspa" || prop
->value() == "Ladspa" ||
824 prop
->value() == "lv2" ||
825 prop
->value() == "vst" ||
826 prop
->value() == "audiounit") {
828 processor
.reset (new PluginInsert(_session
, node
));
830 } else if (prop
->value() == "port") {
832 processor
.reset (new PortInsert (_session
, _mute_master
, node
));
834 } else if (prop
->value() == "send") {
836 processor
.reset (new Send (_session
, _mute_master
, node
));
838 } else if (prop
->value() == "meter") {
841 if (_meter
->set_state (node
, Stateful::loading_state_version
)) {
848 _meter
.reset (new PeakMeter (_session
, node
));
849 _meter
->set_display_to_user (_meter_point
== MeterCustom
);
852 } else if (prop
->value() == "amp") {
854 /* amp always exists */
857 if (processor
->set_state (node
, Stateful::loading_state_version
)) {
860 /* never any reason to add it */
864 } else if (prop
->value() == "intsend") {
866 processor
.reset (new InternalSend (_session
, _mute_master
, node
));
868 } else if (prop
->value() == "intreturn") {
871 if (_intreturn
->set_state (node
, Stateful::loading_state_version
)) {
877 _intreturn
.reset (new InternalReturn (_session
, node
));
878 processor
= _intreturn
;
880 } else if (prop
->value() == "main-outs") {
883 if (_main_outs
->set_state (node
, Stateful::loading_state_version
)) {
890 _main_outs
.reset (new Delivery (_session
, _output
, _mute_master
, node
));
891 processor
= _main_outs
;
894 error
<< string_compose(_("unknown Processor type \"%1\"; ignored"), prop
->value()) << endmsg
;
898 if (iter
== _processors
.end() && processor
->display_to_user() && !_processors
.empty()) {
899 /* check for invisible processors stacked at the end and leave them there */
900 ProcessorList::iterator p
;
901 p
= _processors
.end();
903 while (!(*p
)->display_to_user() && p
!= _processors
.begin()) {
910 return (add_processor (processor
, iter
) == 0);
913 error
<< _("Processor XML node has no type property") << endmsg
;
918 catch (failed_constructor
&err
) {
919 warning
<< _("processor could not be created. Ignored.") << endmsg
;
926 Route::add_processor_from_xml_2X (const XMLNode
& node
, int version
, ProcessorList::iterator iter
)
928 const XMLProperty
*prop
;
931 boost::shared_ptr
<Processor
> processor
;
933 if (node
.name() == "Insert") {
935 if ((prop
= node
.property ("type")) != 0) {
937 if (prop
->value() == "ladspa" || prop
->value() == "Ladspa" ||
938 prop
->value() == "lv2" ||
939 prop
->value() == "vst" ||
940 prop
->value() == "audiounit") {
942 processor
.reset (new PluginInsert (_session
, node
));
946 processor
.reset (new PortInsert (_session
, _mute_master
, node
));
951 } else if (node
.name() == "Send") {
953 processor
.reset (new Send (_session
, _mute_master
, node
, version
));
957 error
<< string_compose(_("unknown Processor type \"%1\"; ignored"), node
.name()) << endmsg
;
961 if (iter
== _processors
.end() && processor
->display_to_user() && !_processors
.empty()) {
962 /* check for invisible processors stacked at the end and leave them there */
963 ProcessorList::iterator p
;
964 p
= _processors
.end();
966 while (!(*p
)->display_to_user() && p
!= _processors
.begin()) {
973 return (add_processor (processor
, iter
) == 0);
976 catch (failed_constructor
&err
) {
977 warning
<< _("processor could not be created. Ignored.") << endmsg
;
983 Route::add_processors (const ProcessorList
& others
, boost::shared_ptr
<Processor
> before
, ProcessorStreams
* err
)
985 ProcessorList::iterator loc
;
988 loc
= find(_processors
.begin(), _processors
.end(), before
);
990 /* nothing specified - at end but before main outs */
991 loc
= find (_processors
.begin(), _processors
.end(), _main_outs
);
994 return add_processors (others
, loc
, err
);
998 Route::add_processors (const ProcessorList
& others
, ProcessorList::iterator iter
, ProcessorStreams
* err
)
1000 /* NOTE: this is intended to be used ONLY when copying
1001 processors from another Route. Hence the subtle
1002 differences between this and ::add_processor()
1005 ChanCount old_pms
= processor_max_streams
;
1007 if (!_session
.engine().connected()) {
1011 if (others
.empty()) {
1016 Glib::RWLock::WriterLock
lm (_processor_lock
);
1018 ChanCount potential_max_streams
= ChanCount::max (_input
->n_ports(), _output
->n_ports());
1020 for (ProcessorList::const_iterator i
= others
.begin(); i
!= others
.end(); ++i
) {
1022 // Ensure meter only appears in the list once
1024 ProcessorList::iterator m
= find(_processors
.begin(), _processors
.end(), *i
);
1025 if (m
!= _processors
.end()) {
1026 _processors
.erase(m
);
1030 boost::shared_ptr
<PluginInsert
> pi
;
1032 if ((pi
= boost::dynamic_pointer_cast
<PluginInsert
>(*i
)) != 0) {
1035 ChanCount m
= max (pi
->input_streams(), pi
->output_streams());
1037 if (m
> potential_max_streams
) {
1038 potential_max_streams
= m
;
1042 ProcessorList::iterator inserted
= _processors
.insert (iter
, *i
);
1044 if ((*i
)->active()) {
1048 if (configure_processors_unlocked (err
)) {
1049 _processors
.erase (inserted
);
1050 configure_processors_unlocked (0); // it worked before we tried to add it ...
1054 (*i
)->ActiveChanged
.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation
, &_session
, false, false));
1057 _output
->set_user_latency (0);
1060 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1066 Route::placement_range(Placement p
, ProcessorList::iterator
& start
, ProcessorList::iterator
& end
)
1068 if (p
== PreFader
) {
1069 start
= _processors
.begin();
1070 end
= find(_processors
.begin(), _processors
.end(), _amp
);
1072 start
= find(_processors
.begin(), _processors
.end(), _amp
);
1074 end
= _processors
.end();
1078 /** Turn off all processors with a given placement
1079 * @param p Placement of processors to disable
1082 Route::disable_processors (Placement p
)
1084 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1086 ProcessorList::iterator start
, end
;
1087 placement_range(p
, start
, end
);
1089 for (ProcessorList::iterator i
= start
; i
!= end
; ++i
) {
1090 (*i
)->deactivate ();
1093 _session
.set_dirty ();
1096 /** Turn off all redirects
1099 Route::disable_processors ()
1101 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1103 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1104 (*i
)->deactivate ();
1107 _session
.set_dirty ();
1110 /** Turn off all redirects with a given placement
1111 * @param p Placement of redirects to disable
1114 Route::disable_plugins (Placement p
)
1116 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1118 ProcessorList::iterator start
, end
;
1119 placement_range(p
, start
, end
);
1121 for (ProcessorList::iterator i
= start
; i
!= end
; ++i
) {
1122 if (boost::dynamic_pointer_cast
<PluginInsert
> (*i
)) {
1123 (*i
)->deactivate ();
1127 _session
.set_dirty ();
1130 /** Turn off all plugins
1133 Route::disable_plugins ()
1135 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1137 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1138 if (boost::dynamic_pointer_cast
<PluginInsert
> (*i
)) {
1139 (*i
)->deactivate ();
1143 _session
.set_dirty ();
1148 Route::ab_plugins (bool forward
)
1150 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1154 /* forward = turn off all active redirects, and mark them so that the next time
1155 we go the other way, we will revert them
1158 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1159 if (!boost::dynamic_pointer_cast
<PluginInsert
> (*i
)) {
1163 if ((*i
)->active()) {
1164 (*i
)->deactivate ();
1165 (*i
)->set_next_ab_is_active (true);
1167 (*i
)->set_next_ab_is_active (false);
1173 /* backward = if the redirect was marked to go active on the next ab, do so */
1175 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1177 if (!boost::dynamic_pointer_cast
<PluginInsert
> (*i
)) {
1181 if ((*i
)->get_next_ab_is_active()) {
1184 (*i
)->deactivate ();
1189 _session
.set_dirty ();
1193 /** Remove processors with a given placement.
1194 * @param p Placement of processors to remove.
1197 Route::clear_processors (Placement p
)
1199 const ChanCount old_pms
= processor_max_streams
;
1201 if (!_session
.engine().connected()) {
1205 bool already_deleting
= _session
.deletion_in_progress();
1206 if (!already_deleting
) {
1207 _session
.set_deletion_in_progress();
1211 Glib::RWLock::WriterLock
lm (_processor_lock
);
1212 ProcessorList new_list
;
1213 ProcessorStreams err
;
1214 bool seen_amp
= false;
1216 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1222 if ((*i
) == _amp
|| (*i
) == _meter
|| (*i
) == _main_outs
) {
1224 /* you can't remove these */
1226 new_list
.push_back (*i
);
1233 new_list
.push_back (*i
);
1236 (*i
)->drop_references ();
1244 (*i
)->drop_references ();
1247 new_list
.push_back (*i
);
1254 _processors
= new_list
;
1255 configure_processors_unlocked (&err
); // this can't fail
1258 processor_max_streams
.reset();
1259 _have_internal_generator
= false;
1260 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1262 if (!already_deleting
) {
1263 _session
.clear_deletion_in_progress();
1268 Route::remove_processor (boost::shared_ptr
<Processor
> processor
, ProcessorStreams
* err
)
1270 /* these can never be removed */
1272 if (processor
== _amp
|| processor
== _meter
|| processor
== _main_outs
) {
1276 ChanCount old_pms
= processor_max_streams
;
1278 if (!_session
.engine().connected()) {
1282 processor_max_streams
.reset();
1285 Glib::RWLock::WriterLock
lm (_processor_lock
);
1286 ProcessorList::iterator i
;
1287 bool removed
= false;
1289 for (i
= _processors
.begin(); i
!= _processors
.end(); ) {
1290 if (*i
== processor
) {
1292 /* move along, see failure case for configure_processors()
1293 where we may need to reconfigure the processor.
1296 /* stop redirects that send signals to JACK ports
1297 from causing noise as a result of no longer being
1301 boost::shared_ptr
<IOProcessor
> iop
;
1303 if ((iop
= boost::dynamic_pointer_cast
<IOProcessor
> (*i
)) != 0) {
1305 iop
->input()->disconnect (this);
1307 if (iop
->output()) {
1308 iop
->output()->disconnect (this);
1312 i
= _processors
.erase (i
);
1320 _output
->set_user_latency (0);
1328 if (configure_processors_unlocked (err
)) {
1329 /* get back to where we where */
1330 _processors
.insert (i
, processor
);
1331 /* we know this will work, because it worked before :) */
1332 configure_processors_unlocked (0);
1336 _have_internal_generator
= false;
1338 for (i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1339 boost::shared_ptr
<PluginInsert
> pi
;
1341 if ((pi
= boost::dynamic_pointer_cast
<PluginInsert
>(*i
)) != 0) {
1342 if (pi
->is_generator()) {
1343 _have_internal_generator
= true;
1350 processor
->drop_references ();
1351 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1357 Route::remove_processors (const ProcessorList
& to_be_deleted
, ProcessorStreams
* err
)
1359 ProcessorList deleted
;
1360 ProcessorList as_we_were
;
1362 if (!_session
.engine().connected()) {
1366 processor_max_streams
.reset();
1369 Glib::RWLock::WriterLock
lm (_processor_lock
);
1370 ProcessorList::iterator i
;
1371 boost::shared_ptr
<Processor
> processor
;
1373 as_we_were
= _processors
;
1375 for (i
= _processors
.begin(); i
!= _processors
.end(); ) {
1379 /* these can never be removed */
1381 if (processor
== _amp
|| processor
== _meter
|| processor
== _main_outs
) {
1386 /* see if its in the list of processors to delete */
1388 if (find (to_be_deleted
.begin(), to_be_deleted
.end(), processor
) == to_be_deleted
.end()) {
1393 /* stop IOProcessors that send to JACK ports
1394 from causing noise as a result of no longer being
1398 boost::shared_ptr
<IOProcessor
> iop
;
1400 if ((iop
= boost::dynamic_pointer_cast
<IOProcessor
> (processor
)) != 0) {
1404 deleted
.push_back (processor
);
1405 i
= _processors
.erase (i
);
1408 if (deleted
.empty()) {
1409 /* none of those in the requested list were found */
1413 _output
->set_user_latency (0);
1415 if (configure_processors_unlocked (err
)) {
1416 /* get back to where we where */
1417 _processors
= as_we_were
;
1418 /* we know this will work, because it worked before :) */
1419 configure_processors_unlocked (0);
1423 _have_internal_generator
= false;
1425 for (i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1426 boost::shared_ptr
<PluginInsert
> pi
;
1428 if ((pi
= boost::dynamic_pointer_cast
<PluginInsert
>(*i
)) != 0) {
1429 if (pi
->is_generator()) {
1430 _have_internal_generator
= true;
1437 /* now try to do what we need to so that those that were removed will be deleted */
1439 for (ProcessorList::iterator i
= deleted
.begin(); i
!= deleted
.end(); ++i
) {
1440 (*i
)->drop_references ();
1443 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1450 Route::configure_processors (ProcessorStreams
* err
)
1452 if (!_in_configure_processors
) {
1453 Glib::RWLock::WriterLock
lm (_processor_lock
);
1454 return configure_processors_unlocked (err
);
1459 /** Configure the input/output configuration of each processor in the processors list.
1460 * Return 0 on success, otherwise configuration is impossible.
1463 Route::configure_processors_unlocked (ProcessorStreams
* err
)
1465 if (_in_configure_processors
) {
1469 _in_configure_processors
= true;
1471 // Check each processor in order to see if we can configure as requested
1472 ChanCount in
= _input
->n_ports ();
1474 list
< pair
<ChanCount
,ChanCount
> > configuration
;
1477 DEBUG_TRACE (DEBUG::Processors
, string_compose ("%1: configure processors\n", _name
));
1479 DEBUG_TRACE (DEBUG::Processors
, "{\n");
1480 for (list
<boost::shared_ptr
<Processor
> >::const_iterator p
= _processors
.begin(); p
!= _processors
.end(); ++p
) {
1481 DEBUG_TRACE (DEBUG::Processors
, string_compose ("\t%1 ID = %2\n", (*p
)->name(), (*p
)->id()));
1483 DEBUG_TRACE (DEBUG::Processors
, "}\n");
1486 for (ProcessorList::iterator p
= _processors
.begin(); p
!= _processors
.end(); ++p
, ++index
) {
1488 if ((*p
)->can_support_io_configuration(in
, out
)) {
1489 DEBUG_TRACE (DEBUG::Processors
, string_compose ("\t%1in = %2 out = %3\n",(*p
)->name(), in
, out
));
1490 configuration
.push_back(make_pair(in
, out
));
1497 _in_configure_processors
= false;
1502 // We can, so configure everything
1503 list
< pair
<ChanCount
,ChanCount
> >::iterator c
= configuration
.begin();
1504 for (ProcessorList::iterator p
= _processors
.begin(); p
!= _processors
.end(); ++p
, ++c
) {
1505 (*p
)->configure_io(c
->first
, c
->second
);
1506 processor_max_streams
= ChanCount::max(processor_max_streams
, c
->first
);
1507 processor_max_streams
= ChanCount::max(processor_max_streams
, c
->second
);
1512 _meter
->reset_max_channels (processor_max_streams
);
1515 /* make sure we have sufficient scratch buffers to cope with the new processor
1517 _session
.ensure_buffers (n_process_buffers ());
1519 _in_configure_processors
= false;
1524 Route::all_processors_flip ()
1526 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1528 if (_processors
.empty()) {
1532 bool first_is_on
= _processors
.front()->active();
1534 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1536 (*i
)->deactivate ();
1542 _session
.set_dirty ();
1545 /** Set all processors with a given placement to a given active state.
1546 * @param p Placement of processors to change.
1547 * @param state New active state for those processors.
1550 Route::all_processors_active (Placement p
, bool state
)
1552 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1554 if (_processors
.empty()) {
1557 ProcessorList::iterator start
, end
;
1558 placement_range(p
, start
, end
);
1560 bool before_amp
= true;
1561 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1566 if (p
== PreFader
&& before_amp
) {
1570 (*i
)->deactivate ();
1575 _session
.set_dirty ();
1579 Route::processor_is_prefader (boost::shared_ptr
<Processor
> p
)
1581 bool pre_fader
= true;
1582 Glib::RWLock::ReaderLock
lm (_processor_lock
);
1584 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1586 /* semantic note: if p == amp, we want to return true, so test
1587 for equality before checking if this is the amp
1604 Route::reorder_processors (const ProcessorList
& new_order
, ProcessorStreams
* err
)
1606 /* "new_order" is an ordered list of processors to be positioned according to "placement".
1607 NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
1608 processors in the current actual processor list that are hidden. Any visible processors
1609 in the current list but not in "new_order" will be assumed to be deleted.
1613 Glib::RWLock::WriterLock
lm (_processor_lock
);
1614 ChanCount old_pms
= processor_max_streams
;
1615 ProcessorList::iterator oiter
;
1616 ProcessorList::const_iterator niter
;
1617 ProcessorList as_it_was_before
= _processors
;
1618 ProcessorList as_it_will_be
;
1620 oiter
= _processors
.begin();
1621 niter
= new_order
.begin();
1623 while (niter
!= new_order
.end()) {
1625 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
1626 then append it to the temp list.
1628 Otherwise, see if the next processor in the old list is in the new list. if not,
1629 its been deleted. If its there, append it to the temp list.
1632 if (oiter
== _processors
.end()) {
1634 /* no more elements in the old list, so just stick the rest of
1635 the new order onto the temp list.
1638 as_it_will_be
.insert (as_it_will_be
.end(), niter
, new_order
.end());
1639 while (niter
!= new_order
.end()) {
1646 if (!(*oiter
)->display_to_user()) {
1648 as_it_will_be
.push_back (*oiter
);
1652 /* visible processor: check that its in the new order */
1654 if (find (new_order
.begin(), new_order
.end(), (*oiter
)) == new_order
.end()) {
1655 /* deleted: do nothing, shared_ptr<> will clean up */
1657 /* ignore this one, and add the next item from the new order instead */
1658 as_it_will_be
.push_back (*niter
);
1663 /* now remove from old order - its taken care of no matter what */
1664 oiter
= _processors
.erase (oiter
);
1669 _processors
.insert (oiter
, as_it_will_be
.begin(), as_it_will_be
.end());
1671 if (configure_processors_unlocked (err
)) {
1672 _processors
= as_it_was_before
;
1673 processor_max_streams
= old_pms
;
1678 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1690 Route::get_template()
1692 return state(false);
1696 Route::state(bool full_state
)
1698 XMLNode
*node
= new XMLNode("Route");
1699 ProcessorList::iterator i
;
1702 id().print (buf
, sizeof (buf
));
1703 node
->add_property("id", buf
);
1704 node
->add_property ("name", _name
);
1705 node
->add_property("default-type", _default_type
.to_string());
1708 node
->add_property("flags", enum_2_string (_flags
));
1711 node
->add_property("active", _active
?"yes":"no");
1712 node
->add_property("phase-invert", _phase_invert
?"yes":"no");
1713 node
->add_property("denormal-protection", _denormal_protection
?"yes":"no");
1714 node
->add_property("meter-point", enum_2_string (_meter_point
));
1717 node
->add_property("route-group", _route_group
->name());
1720 string order_string
;
1721 OrderKeys::iterator x
= order_keys
.begin();
1723 while (x
!= order_keys
.end()) {
1724 order_string
+= string ((*x
).first
);
1725 order_string
+= '=';
1726 snprintf (buf
, sizeof(buf
), "%ld", (*x
).second
);
1727 order_string
+= buf
;
1731 if (x
== order_keys
.end()) {
1735 order_string
+= ':';
1737 node
->add_property ("order-keys", order_string
);
1738 node
->add_property ("self-solo", (_self_solo
? "yes" : "no"));
1739 snprintf (buf
, sizeof (buf
), "%d", _soloed_by_others
);
1740 node
->add_property ("soloed-by-others", buf
);
1742 node
->add_child_nocopy (_input
->state (full_state
));
1743 node
->add_child_nocopy (_output
->state (full_state
));
1744 node
->add_child_nocopy (_solo_control
->get_state ());
1745 node
->add_child_nocopy (_mute_master
->get_state ());
1747 XMLNode
* remote_control_node
= new XMLNode (X_("RemoteControl"));
1748 snprintf (buf
, sizeof (buf
), "%d", _remote_control_id
);
1749 remote_control_node
->add_property (X_("id"), buf
);
1750 node
->add_child_nocopy (*remote_control_node
);
1752 if (_comment
.length()) {
1753 XMLNode
*cmt
= node
->add_child ("Comment");
1754 cmt
->add_content (_comment
);
1757 for (i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
1758 node
->add_child_nocopy((*i
)->state (full_state
));
1762 node
->add_child_copy (*_extra_xml
);
1769 Route::set_state (const XMLNode
& node
, int version
)
1771 return _set_state (node
, version
, true);
1775 Route::_set_state (const XMLNode
& node
, int version
, bool /*call_base*/)
1777 if (version
< 3000) {
1778 return _set_state_2X (node
, version
);
1782 XMLNodeConstIterator niter
;
1784 XMLPropertyList plist
;
1785 const XMLProperty
*prop
;
1787 if (node
.name() != "Route"){
1788 error
<< string_compose(_("Bad node sent to Route::set_state() [%1]"), node
.name()) << endmsg
;
1792 if ((prop
= node
.property (X_("name"))) != 0) {
1793 Route::set_name (prop
->value());
1796 if ((prop
= node
.property ("id")) != 0) {
1797 _id
= prop
->value ();
1800 if ((prop
= node
.property (X_("flags"))) != 0) {
1801 _flags
= Flag (string_2_enum (prop
->value(), _flags
));
1806 /* add all processors (except amp, which is always present) */
1808 nlist
= node
.children();
1809 XMLNode
processor_state (X_("processor_state"));
1811 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
){
1815 if (child
->name() == IO::state_node_name
) {
1816 if ((prop
= child
->property (X_("direction"))) == 0) {
1820 if (prop
->value() == "Input") {
1821 _input
->set_state (*child
, version
);
1822 } else if (prop
->value() == "Output") {
1823 _output
->set_state (*child
, version
);
1827 if (child
->name() == X_("Processor")) {
1828 processor_state
.add_child_copy (*child
);
1832 set_processor_state (processor_state
);
1834 if ((prop
= node
.property ("self-solo")) != 0) {
1835 set_self_solo (string_is_affirmative (prop
->value()));
1838 if ((prop
= node
.property ("soloed-by-others")) != 0) {
1839 _soloed_by_others
= 0; // needed for mod_solo_by_others () to work
1840 mod_solo_by_others (atoi (prop
->value()));
1843 if ((prop
= node
.property ("solo-isolated")) != 0) {
1844 set_solo_isolated (string_is_affirmative (prop
->value()), this);
1847 if ((prop
= node
.property (X_("phase-invert"))) != 0) {
1848 set_phase_invert (string_is_affirmative (prop
->value()));
1851 if ((prop
= node
.property (X_("denormal-protection"))) != 0) {
1852 set_denormal_protection (string_is_affirmative (prop
->value()));
1855 if ((prop
= node
.property (X_("active"))) != 0) {
1856 bool yn
= string_is_affirmative (prop
->value());
1857 _active
= !yn
; // force switch
1861 if ((prop
= node
.property (X_("meter-point"))) != 0) {
1862 _meter_point
= MeterPoint (string_2_enum (prop
->value (), _meter_point
));
1864 _meter
->set_display_to_user (_meter_point
== MeterCustom
);
1868 if ((prop
= node
.property (X_("order-keys"))) != 0) {
1872 string::size_type colon
, equal
;
1873 string remaining
= prop
->value();
1875 while (remaining
.length()) {
1877 if ((equal
= remaining
.find_first_of ('=')) == string::npos
|| equal
== remaining
.length()) {
1878 error
<< string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining
)
1881 if (sscanf (remaining
.substr (equal
+1).c_str(), "%ld", &n
) != 1) {
1882 error
<< string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining
)
1885 set_order_key (remaining
.substr (0, equal
), n
);
1889 colon
= remaining
.find_first_of (':');
1891 if (colon
!= string::npos
) {
1892 remaining
= remaining
.substr (colon
+1);
1899 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
){
1902 if (child
->name() == X_("Comment")) {
1904 /* XXX this is a terrible API design in libxml++ */
1906 XMLNode
*cmt
= *(child
->children().begin());
1907 _comment
= cmt
->content();
1909 } else if (child
->name() == X_("Extra")) {
1911 _extra_xml
= new XMLNode (*child
);
1913 } else if (child
->name() == X_("Controllable") && (prop
= child
->property("name")) != 0) {
1915 if (prop
->value() == "solo") {
1916 _solo_control
->set_state (*child
, version
);
1917 _session
.add_controllable (_solo_control
);
1920 } else if (child
->name() == X_("RemoteControl")) {
1921 if ((prop
= child
->property (X_("id"))) != 0) {
1923 sscanf (prop
->value().c_str(), "%d", &x
);
1924 set_remote_control_id (x
);
1927 } else if (child
->name() == X_("MuteMaster")) {
1928 _mute_master
->set_state (*child
, version
);
1936 Route::_set_state_2X (const XMLNode
& node
, int version
)
1939 XMLNodeConstIterator niter
;
1941 XMLPropertyList plist
;
1942 const XMLProperty
*prop
;
1944 /* 2X things which still remain to be handled:
1947 * mute-affects-pre-fader
1948 * mute-affects-post-fader
1949 * mute-affects-control-outs
1950 * mute-affects-main-outs
1955 if (node
.name() != "Route") {
1956 error
<< string_compose(_("Bad node sent to Route::set_state() [%1]"), node
.name()) << endmsg
;
1960 if ((prop
= node
.property (X_("flags"))) != 0) {
1961 _flags
= Flag (string_2_enum (prop
->value(), _flags
));
1966 /* add standard processors */
1968 _meter
.reset (new PeakMeter (_session
));
1969 add_processor (_meter
, PreFader
);
1971 if (_flags
& ControlOut
) {
1972 /* where we listen to tracks */
1973 _intreturn
.reset (new InternalReturn (_session
));
1974 add_processor (_intreturn
, PreFader
);
1977 _main_outs
.reset (new Delivery (_session
, _output
, _mute_master
, _name
, Delivery::Main
));
1978 add_processor (_main_outs
, PostFader
);
1982 nlist
= node
.children ();
1983 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
) {
1987 if (child
->name() == IO::state_node_name
) {
1989 /* there is a note in IO::set_state_2X() about why we have to call
1993 _input
->set_state_2X (*child
, version
, true);
1994 _output
->set_state_2X (*child
, version
, false);
1996 if ((prop
= child
->property (X_("name"))) != 0) {
1997 set_name (prop
->value ());
2000 if ((prop
= child
->property (X_("id"))) != 0) {
2001 _id
= prop
->value ();
2004 if ((prop
= child
->property (X_("active"))) != 0) {
2005 bool yn
= string_is_affirmative (prop
->value());
2006 _active
= !yn
; // force switch
2014 if ((prop
= node
.property (X_("phase-invert"))) != 0) {
2015 set_phase_invert (string_is_affirmative (prop
->value()));
2018 if ((prop
= node
.property (X_("denormal-protection"))) != 0) {
2019 set_denormal_protection (string_is_affirmative (prop
->value()));
2022 if ((prop
= node
.property (X_("soloed"))) != 0) {
2023 bool yn
= string_is_affirmative (prop
->value());
2025 /* XXX force reset of solo status */
2027 set_solo (yn
, this);
2030 if ((prop
= node
.property (X_("meter-point"))) != 0) {
2031 _meter_point
= MeterPoint (string_2_enum (prop
->value (), _meter_point
));
2034 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
2035 don't mean the same thing.
2038 if ((prop
= node
.property (X_("order-keys"))) != 0) {
2042 string::size_type colon
, equal
;
2043 string remaining
= prop
->value();
2045 while (remaining
.length()) {
2047 if ((equal
= remaining
.find_first_of ('=')) == string::npos
|| equal
== remaining
.length()) {
2048 error
<< string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining
)
2051 if (sscanf (remaining
.substr (equal
+1).c_str(), "%ld", &n
) != 1) {
2052 error
<< string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining
)
2055 set_order_key (remaining
.substr (0, equal
), n
);
2059 colon
= remaining
.find_first_of (':');
2061 if (colon
!= string::npos
) {
2062 remaining
= remaining
.substr (colon
+1);
2069 XMLNodeList redirect_nodes
;
2071 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
){
2075 if (child
->name() == X_("Send") || child
->name() == X_("Insert")) {
2076 redirect_nodes
.push_back(child
);
2081 set_processor_state_2X (redirect_nodes
, version
);
2083 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
){
2086 if (child
->name() == X_("Comment")) {
2088 /* XXX this is a terrible API design in libxml++ */
2090 XMLNode
*cmt
= *(child
->children().begin());
2091 _comment
= cmt
->content();
2093 } else if (child
->name() == X_("Extra")) {
2095 _extra_xml
= new XMLNode (*child
);
2097 } else if (child
->name() == X_("Controllable") && (prop
= child
->property("name")) != 0) {
2099 if (prop
->value() == "solo") {
2100 _solo_control
->set_state (*child
, version
);
2101 _session
.add_controllable (_solo_control
);
2104 } else if (child
->name() == X_("RemoteControl")) {
2105 if ((prop
= child
->property (X_("id"))) != 0) {
2107 sscanf (prop
->value().c_str(), "%d", &x
);
2108 set_remote_control_id (x
);
2118 Route::get_processor_state ()
2120 XMLNode
* root
= new XMLNode (X_("redirects"));
2121 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2122 root
->add_child_nocopy ((*i
)->state (true));
2129 Route::set_processor_state_2X (XMLNodeList
const & nList
, int version
)
2131 /* We don't bother removing existing processors not in nList, as this
2132 method will only be called when creating a Route from scratch, not
2133 for undo purposes. Just put processors in at the appropriate place
2137 for (XMLNodeConstIterator i
= nList
.begin(); i
!= nList
.end(); ++i
) {
2138 add_processor_from_xml_2X (**i
, version
, _processors
.begin ());
2143 Route::set_processor_state (const XMLNode
& node
)
2145 const XMLNodeList
&nlist
= node
.children();
2146 XMLNodeConstIterator niter
;
2147 ProcessorList::iterator i
, o
;
2149 // Iterate through existing processors, remove those which are not in the state list
2151 for (i
= _processors
.begin(); i
!= _processors
.end(); ) {
2153 /* leave amp alone, always */
2160 ProcessorList::iterator tmp
= i
;
2163 bool processorInStateList
= false;
2165 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
) {
2167 XMLProperty
* id_prop
= (*niter
)->property(X_("id"));
2169 if (id_prop
&& (*i
)->id() == id_prop
->value()) {
2170 processorInStateList
= true;
2175 if (!processorInStateList
) {
2176 remove_processor (*i
);
2182 // Iterate through state list and make sure all processors are on the track and in the correct order,
2183 // set the state of existing processors according to the new state on the same go
2185 i
= _processors
.begin();
2187 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
, ++i
) {
2189 XMLProperty
* prop
= (*niter
)->property ("type");
2193 // Check whether the next processor in the list is the right one,
2194 // except for "amp" which is always there and may not have the
2195 // old ID since it is always created anew in every Route
2197 if (prop
->value() != "amp") {
2198 while (o
!= _processors
.end()) {
2199 XMLProperty
* id_prop
= (*niter
)->property(X_("id"));
2200 if (id_prop
&& (*o
)->id() == id_prop
->value()) {
2208 // If the processor (*niter) is not on the route,
2209 // create it and move it to the correct location
2211 if (o
== _processors
.end()) {
2213 if (add_processor_from_xml (**niter
, i
)) {
2214 --i
; // move iterator to the newly inserted processor
2216 cerr
<< "Error restoring route: unable to restore processor" << endl
;
2221 // Otherwise, the processor already exists; just
2222 // ensure it is at the location provided in the XML state
2225 boost::shared_ptr
<Processor
> tmp
= (*o
);
2226 _processors
.erase (o
); // remove the old copy
2227 _processors
.insert (i
, tmp
); // insert the processor at the correct location
2228 --i
; // move iterator to the correct processor
2231 // and make it (just) so
2233 (*i
)->set_state (**niter
, Stateful::current_state_version
);
2237 /* note: there is no configure_processors() call because we figure that
2238 the XML state represents a working signal route.
2241 processors_changed (RouteProcessorChange ());
2245 Route::curve_reallocate ()
2247 // _gain_automation_curve.finish_resize ();
2248 // _pan_automation_curve.finish_resize ();
2252 Route::silence (nframes_t nframes
)
2256 _output
->silence (nframes
);
2259 Glib::RWLock::ReaderLock
lm (_processor_lock
, Glib::TRY_LOCK
);
2262 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2263 boost::shared_ptr
<PluginInsert
> pi
;
2265 if (!_active
&& (pi
= boost::dynamic_pointer_cast
<PluginInsert
> (*i
)) != 0) {
2266 // skip plugins, they don't need anything when we're not active
2270 (*i
)->silence (nframes
);
2273 if (nframes
== _session
.get_block_size()) {
2283 Route::add_internal_return ()
2286 _intreturn
.reset (new InternalReturn (_session
));
2287 add_processor (_intreturn
, PreFader
);
2292 Route::get_return_buffer () const
2294 Glib::RWLock::ReaderLock
rm (_processor_lock
);
2296 for (ProcessorList::const_iterator x
= _processors
.begin(); x
!= _processors
.end(); ++x
) {
2297 boost::shared_ptr
<InternalReturn
> d
= boost::dynamic_pointer_cast
<InternalReturn
>(*x
);
2300 BufferSet
* bs
= d
->get_buffers ();
2309 Route::release_return_buffer () const
2311 Glib::RWLock::ReaderLock
rm (_processor_lock
);
2313 for (ProcessorList::const_iterator x
= _processors
.begin(); x
!= _processors
.end(); ++x
) {
2314 boost::shared_ptr
<InternalReturn
> d
= boost::dynamic_pointer_cast
<InternalReturn
>(*x
);
2317 return d
->release_buffers ();
2323 Route::listen_via (boost::shared_ptr
<Route
> route
, Placement placement
, bool /*active*/, bool aux
)
2325 vector
<string
> ports
;
2326 vector
<string
>::const_iterator i
;
2329 Glib::RWLock::ReaderLock
rm (_processor_lock
);
2331 for (ProcessorList::iterator x
= _processors
.begin(); x
!= _processors
.end(); ++x
) {
2333 boost::shared_ptr
<InternalSend
> d
= boost::dynamic_pointer_cast
<InternalSend
>(*x
);
2335 if (d
&& d
->target_route() == route
) {
2337 /* if the target is the control outs, then make sure
2338 we take note of which i-send is doing that.
2341 if (route
== _session
.control_out()) {
2342 _control_outs
= boost::dynamic_pointer_cast
<Delivery
>(d
);
2345 /* already listening via the specified IO: do nothing */
2352 boost::shared_ptr
<InternalSend
> listener
;
2355 listener
.reset (new InternalSend (_session
, _mute_master
, route
, (aux
? Delivery::Aux
: Delivery::Listen
)));
2357 } catch (failed_constructor
& err
) {
2361 if (route
== _session
.control_out()) {
2362 _control_outs
= listener
;
2365 add_processor (listener
, placement
);
2371 Route::drop_listen (boost::shared_ptr
<Route
> route
)
2373 ProcessorStreams err
;
2374 ProcessorList::iterator tmp
;
2376 Glib::RWLock::ReaderLock
rl(_processor_lock
);
2380 for (ProcessorList::iterator x
= _processors
.begin(); x
!= _processors
.end(); ) {
2382 boost::shared_ptr
<InternalSend
> d
= boost::dynamic_pointer_cast
<InternalSend
>(*x
);
2384 if (d
&& d
->target_route() == route
) {
2386 remove_processor (*x
, &err
);
2389 /* list could have been demolished while we dropped the lock
2399 if (route
== _session
.control_out()) {
2400 _control_outs
.reset ();
2405 Route::set_comment (string cmt
, void *src
)
2408 comment_changed (src
);
2409 _session
.set_dirty ();
2413 Route::feeds (boost::shared_ptr
<Route
> other
, bool* only_send
)
2415 DEBUG_TRACE (DEBUG::Graph
, string_compose ("Feeds? %1\n", _name
));
2417 if (_output
->connected_to (other
->input())) {
2418 DEBUG_TRACE (DEBUG::Graph
, string_compose ("\tdirect FEEDS %2\n", other
->name()));
2427 for (ProcessorList::iterator r
= _processors
.begin(); r
!= _processors
.end(); r
++) {
2429 boost::shared_ptr
<IOProcessor
> iop
;
2431 if ((iop
= boost::dynamic_pointer_cast
<IOProcessor
>(*r
)) != 0) {
2432 if (iop
->feeds (other
)) {
2433 DEBUG_TRACE (DEBUG::Graph
, string_compose ("\tIOP %1 does feed %2\n", iop
->name(), other
->name()));
2439 DEBUG_TRACE (DEBUG::Graph
, string_compose ("\tIOP %1 does NOT feed %2\n", iop
->name(), other
->name()));
2442 DEBUG_TRACE (DEBUG::Graph
, string_compose ("\tPROC %1 is not an IOP\n", (*r
)->name()));
2447 DEBUG_TRACE (DEBUG::Graph
, string_compose ("\tdoes NOT feed %1\n", other
->name()));
2452 Route::handle_transport_stopped (bool /*abort_ignored*/, bool did_locate
, bool can_flush_processors
)
2454 nframes_t now
= _session
.transport_frame();
2457 Glib::RWLock::ReaderLock
lm (_processor_lock
);
2460 automation_snapshot (now
, true);
2463 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2465 if (Config
->get_plugins_stop_with_transport() && can_flush_processors
) {
2466 (*i
)->deactivate ();
2470 (*i
)->transport_stopped (now
);
2474 _roll_delay
= _initial_delay
;
2478 Route::input_change_handler (IOChange change
, void * /*src*/)
2480 if ((change
& ConfigurationChanged
)) {
2481 configure_processors (0);
2486 Route::output_change_handler (IOChange change
, void * /*src*/)
2488 if ((change
& ConfigurationChanged
)) {
2490 /* XXX resize all listeners to match _main_outs? */
2492 // configure_processors (0);
2497 Route::pans_required () const
2499 if (n_outputs().n_audio() < 2) {
2503 return max (n_inputs ().n_audio(), processor_max_streams
.n_audio());
2507 Route::no_roll (nframes_t nframes
, sframes_t start_frame
, sframes_t end_frame
,
2508 bool session_state_changing
, bool /*can_record*/, bool /*rec_monitors_input*/)
2510 if (n_outputs().n_total() == 0) {
2514 if (session_state_changing
|| !_active
|| n_inputs() == ChanCount::ZERO
) {
2519 _amp
->apply_gain_automation (false);
2520 passthru (start_frame
, end_frame
, nframes
, 0);
2526 Route::check_initial_delay (nframes_t nframes
, nframes_t
& transport_frame
)
2528 if (_roll_delay
> nframes
) {
2530 _roll_delay
-= nframes
;
2532 /* transport frame is not legal for caller to use */
2535 } else if (_roll_delay
> 0) {
2537 nframes
-= _roll_delay
;
2538 silence (_roll_delay
);
2539 /* we've written _roll_delay of samples into the
2540 output ports, so make a note of that for
2543 _main_outs
->increment_output_offset (_roll_delay
);
2544 transport_frame
+= _roll_delay
;
2553 Route::roll (nframes_t nframes
, sframes_t start_frame
, sframes_t end_frame
, int declick
,
2554 bool /*can_record*/, bool /*rec_monitors_input*/)
2557 // automation snapshot can also be called from the non-rt context
2558 // and it uses the processor list, so we try to acquire the lock here
2559 Glib::RWLock::ReaderLock
lm (_processor_lock
, Glib::TRY_LOCK
);
2562 automation_snapshot (_session
.transport_frame(), false);
2566 if (n_outputs().n_total() == 0) {
2570 if (!_active
|| n_inputs().n_total() == 0) {
2575 nframes_t unused
= 0;
2577 if ((nframes
= check_initial_delay (nframes
, unused
)) == 0) {
2583 passthru (start_frame
, end_frame
, nframes
, declick
);
2589 Route::silent_roll (nframes_t nframes
, sframes_t
/*start_frame*/, sframes_t
/*end_frame*/,
2590 bool /*can_record*/, bool /*rec_monitors_input*/)
2597 Route::toggle_monitor_input ()
2599 for (PortSet::iterator i
= _input
->ports().begin(); i
!= _input
->ports().end(); ++i
) {
2600 i
->ensure_monitor_input( ! i
->monitoring_input());
2605 Route::has_external_redirects () const
2607 // FIXME: what about sends? - they don't return a signal back to ardour?
2609 boost::shared_ptr
<const PortInsert
> pi
;
2611 for (ProcessorList::const_iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2613 if ((pi
= boost::dynamic_pointer_cast
<const PortInsert
>(*i
)) != 0) {
2615 for (PortSet::const_iterator port
= pi
->output()->ports().begin(); port
!= pi
->output()->ports().end(); ++port
) {
2617 string port_name
= port
->name();
2618 string client_name
= port_name
.substr (0, port_name
.find(':'));
2620 /* only say "yes" if the redirect is actually in use */
2622 if (client_name
!= "ardour" && pi
->active()) {
2633 Route::flush_processors ()
2635 /* XXX shouldn't really try to take this lock, since
2636 this is called from the RT audio thread.
2639 Glib::RWLock::ReaderLock
lm (_processor_lock
);
2641 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2642 (*i
)->deactivate ();
2648 Route::set_meter_point (MeterPoint p
, void *src
)
2650 /* CAN BE CALLED FROM PROCESS CONTEXT */
2652 if (_meter_point
== p
) {
2656 bool meter_was_visible_to_user
= _meter
->display_to_user ();
2659 Glib::RWLock::WriterLock
lm (_processor_lock
);
2661 if (p
!= MeterCustom
) {
2662 // Move meter in the processors list to reflect the new position
2663 ProcessorList::iterator loc
= find (_processors
.begin(), _processors
.end(), _meter
);
2664 _processors
.erase(loc
);
2667 loc
= _processors
.begin();
2670 loc
= find (_processors
.begin(), _processors
.end(), _amp
);
2672 case MeterPostFader
:
2673 loc
= _processors
.end();
2681 if (loc
== _processors
.begin()) {
2682 m_in
= _input
->n_ports();
2684 ProcessorList::iterator before
= loc
;
2686 m_in
= (*before
)->output_streams ();
2689 _meter
->reflect_inputs (m_in
);
2691 _processors
.insert (loc
, _meter
);
2693 /* we do not need to reconfigure the processors, because the meter
2694 (a) is always ready to handle processor_max_streams
2695 (b) is always an N-in/N-out processor, and thus moving
2696 it doesn't require any changes to the other processors.
2699 _meter
->set_display_to_user (false);
2703 // just make it visible and let the user move it
2705 _meter
->set_display_to_user (true);
2710 meter_change (src
); /* EMIT SIGNAL */
2712 bool const meter_visibly_changed
= (_meter
->display_to_user() != meter_was_visible_to_user
);
2714 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange
, meter_visibly_changed
)); /* EMIT SIGNAL */
2718 Route::put_control_outs_at (Placement p
)
2720 if (!_control_outs
) {
2725 Glib::RWLock::WriterLock
lm (_processor_lock
);
2726 ProcessorList
as_it_was (_processors
);
2727 // Move meter in the processors list
2728 ProcessorList::iterator loc
= find(_processors
.begin(), _processors
.end(), _control_outs
);
2729 _processors
.erase(loc
);
2733 loc
= find(_processors
.begin(), _processors
.end(), _amp
);
2734 if (loc
!= _processors
.begin()) {
2739 loc
= find(_processors
.begin(), _processors
.end(), _amp
);
2740 assert (loc
!= _processors
.end());
2745 _processors
.insert(loc
, _control_outs
);
2747 if (configure_processors_unlocked (0)) {
2748 _processors
= as_it_was
;
2749 configure_processors_unlocked (0); // it worked before we tried to add it ...
2754 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2755 _session
.set_dirty ();
2759 Route::update_total_latency ()
2761 nframes_t old
= _output
->effective_latency();
2762 nframes_t own_latency
= _output
->user_latency();
2764 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2765 if ((*i
)->active ()) {
2766 own_latency
+= (*i
)->signal_latency ();
2770 DEBUG_TRACE (DEBUG::Latency
, string_compose ("%1: internal redirect latency = %2\n", _name
, own_latency
));
2772 _output
->set_port_latency (own_latency
);
2774 if (_output
->user_latency() == 0) {
2776 /* this (virtual) function is used for pure Routes,
2777 not derived classes like AudioTrack. this means
2778 that the data processed here comes from an input
2779 port, not prerecorded material, and therefore we
2780 have to take into account any input latency.
2783 own_latency
+= _input
->signal_latency ();
2786 if (old
!= own_latency
) {
2787 _output
->set_latency_delay (own_latency
);
2788 signal_latency_changed (); /* EMIT SIGNAL */
2791 DEBUG_TRACE (DEBUG::Latency
, string_compose ("%1: input latency = %2 total = %3\n", _name
, _input
->signal_latency(), own_latency
));
2793 return _output
->effective_latency ();
2797 Route::set_user_latency (nframes_t nframes
)
2799 _output
->set_user_latency (nframes
);
2800 _session
.update_latency_compensation (false, false);
2804 Route::set_latency_delay (nframes_t longest_session_latency
)
2806 nframes_t old
= _initial_delay
;
2808 if (_output
->effective_latency() < longest_session_latency
) {
2809 _initial_delay
= longest_session_latency
- _output
->effective_latency();
2814 if (_initial_delay
!= old
) {
2815 initial_delay_changed (); /* EMIT SIGNAL */
2818 if (_session
.transport_stopped()) {
2819 _roll_delay
= _initial_delay
;
2824 Route::automation_snapshot (nframes_t now
, bool force
)
2826 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2827 (*i
)->automation_snapshot (now
, force
);
2831 Route::SoloControllable::SoloControllable (std::string name
, Route
& r
)
2832 : AutomationControl (r
.session(), Evoral::Parameter (SoloAutomation
),
2833 boost::shared_ptr
<AutomationList
>(), name
)
2836 boost::shared_ptr
<AutomationList
> gl(new AutomationList(Evoral::Parameter(SoloAutomation
)));
2841 Route::SoloControllable::set_value (float val
)
2843 bool bval
= ((val
>= 0.5f
) ? true: false);
2845 route
.set_solo (bval
, this);
2849 Route::SoloControllable::get_value (void) const
2851 return route
.self_soloed() ? 1.0f
: 0.0f
;
2855 Route::set_block_size (nframes_t nframes
)
2857 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2858 (*i
)->set_block_size (nframes
);
2861 _session
.ensure_buffers (n_process_buffers ());
2865 Route::protect_automation ()
2867 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
)
2868 (*i
)->protect_automation();
2872 Route::set_pending_declick (int declick
)
2875 /* this call is not allowed to turn off a pending declick unless "force" is true */
2877 _pending_declick
= declick
;
2879 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
2881 _pending_declick
= 0;
2886 /** Shift automation forwards from a particular place, thereby inserting time.
2887 * Adds undo commands for any shifts that are performed.
2889 * @param pos Position to start shifting from.
2890 * @param frames Amount to shift forwards by.
2894 Route::shift (nframes64_t
/*pos*/, nframes64_t
/*frames*/)
2896 #ifdef THIS_NEEDS_FIXING_FOR_V3
2898 /* gain automation */
2899 XMLNode
&before
= _gain_control
->get_state ();
2900 _gain_control
->shift (pos
, frames
);
2901 XMLNode
&after
= _gain_control
->get_state ();
2902 _session
.add_command (new MementoCommand
<AutomationList
> (_gain_automation_curve
, &before
, &after
));
2904 /* pan automation */
2905 for (std::vector
<StreamPanner
*>::iterator i
= _panner
->begin (); i
!= _panner
->end (); ++i
) {
2906 Curve
& c
= (*i
)->automation ();
2907 XMLNode
&before
= c
.get_state ();
2908 c
.shift (pos
, frames
);
2909 XMLNode
&after
= c
.get_state ();
2910 _session
.add_command (new MementoCommand
<AutomationList
> (c
, &before
, &after
));
2913 /* redirect automation */
2915 Glib::RWLock::ReaderLock
lm (redirect_lock
);
2916 for (RedirectList::iterator i
= _redirects
.begin (); i
!= _redirects
.end (); ++i
) {
2919 (*i
)->what_has_automation (a
);
2921 for (set
<uint32_t>::const_iterator j
= a
.begin (); j
!= a
.end (); ++j
) {
2922 AutomationList
& al
= (*i
)->automation_list (*j
);
2923 XMLNode
&before
= al
.get_state ();
2924 al
.shift (pos
, frames
);
2925 XMLNode
&after
= al
.get_state ();
2926 _session
.add_command (new MementoCommand
<AutomationList
> (al
, &before
, &after
));
2936 Route::save_as_template (const string
& path
, const string
& name
)
2938 XMLNode
& node (state (false));
2941 IO::set_name_in_state (*node
.children().front(), name
);
2943 tree
.set_root (&node
);
2944 return tree
.write (path
.c_str());
2949 Route::set_name (const string
& str
)
2955 name
= Route::ensure_track_or_route_name (str
, _session
);
2956 SessionObject::set_name (name
);
2958 ret
= (_input
->set_name(name
) && _output
->set_name(name
));
2962 Glib::RWLock::ReaderLock
lm (_processor_lock
);
2964 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2966 /* rename all I/O processors that have inputs or outputs */
2968 boost::shared_ptr
<IOProcessor
> iop
= boost::dynamic_pointer_cast
<IOProcessor
> (*i
);
2970 if (iop
&& (iop
->output() || iop
->input())) {
2971 if (!iop
->set_name (name
)) {
2982 boost::shared_ptr
<Send
>
2983 Route::internal_send_for (boost::shared_ptr
<const Route
> target
) const
2985 Glib::RWLock::ReaderLock
lm (_processor_lock
);
2987 for (ProcessorList::const_iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
2988 boost::shared_ptr
<InternalSend
> send
;
2990 if ((send
= boost::dynamic_pointer_cast
<InternalSend
>(*i
)) != 0) {
2991 if (send
->target_route() == target
) {
2997 return boost::shared_ptr
<Send
>();
3001 Route::set_phase_invert (bool yn
)
3003 if (_phase_invert
!= yn
) {
3004 _phase_invert
= 0xffff; // XXX all channels
3005 phase_invert_changed (); /* EMIT SIGNAL */
3010 Route::phase_invert () const
3012 return _phase_invert
!= 0;
3016 Route::set_denormal_protection (bool yn
)
3018 if (_denormal_protection
!= yn
) {
3019 _denormal_protection
= yn
;
3020 denormal_protection_changed (); /* EMIT SIGNAL */
3025 Route::denormal_protection () const
3027 return _denormal_protection
;
3031 Route::set_active (bool yn
)
3033 if (_active
!= yn
) {
3035 _input
->set_active (yn
);
3036 _output
->set_active (yn
);
3037 active_changed (); // EMIT SIGNAL
3044 Glib::RWLock::ReaderLock
rm (_processor_lock
, Glib::TRY_LOCK
);
3050 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
3052 boost::shared_ptr
<Send
> s
;
3053 boost::shared_ptr
<Return
> r
;
3055 if ((s
= boost::dynamic_pointer_cast
<Send
> (*i
)) != 0) {
3056 s
->meter()->meter();
3057 } else if ((r
= boost::dynamic_pointer_cast
<Return
> (*i
)) != 0) {
3058 r
->meter()->meter ();
3063 boost::shared_ptr
<Panner
>
3064 Route::panner() const
3067 return _main_outs
->panner();
3070 boost::shared_ptr
<AutomationControl
>
3071 Route::gain_control() const
3074 return _amp
->gain_control();
3077 boost::shared_ptr
<AutomationControl
>
3078 Route::get_control (const Evoral::Parameter
& param
)
3080 /* either we own the control or .... */
3082 boost::shared_ptr
<AutomationControl
> c
= boost::dynamic_pointer_cast
<AutomationControl
>(data().control (param
));
3086 /* maybe one of our processors does or ... */
3088 Glib::RWLock::ReaderLock
rm (_processor_lock
, Glib::TRY_LOCK
);
3089 for (ProcessorList::iterator i
= _processors
.begin(); i
!= _processors
.end(); ++i
) {
3090 if ((c
= boost::dynamic_pointer_cast
<AutomationControl
>((*i
)->data().control (param
))) != 0) {
3098 /* nobody does so we'll make a new one */
3100 c
= boost::dynamic_pointer_cast
<AutomationControl
>(control_factory(param
));