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 <sigc++/bind.h>
26 #include <pbd/xml++.h>
28 #include <ardour/timestamps.h>
29 #include <ardour/audioengine.h>
30 #include <ardour/route.h>
31 #include <ardour/buffer.h>
32 #include <ardour/insert.h>
33 #include <ardour/send.h>
34 #include <ardour/session.h>
35 #include <ardour/utils.h>
36 #include <ardour/configuration.h>
37 #include <ardour/cycle_timer.h>
38 #include <ardour/route_group.h>
39 #include <ardour/port.h>
40 #include <ardour/audio_port.h>
41 #include <ardour/ladspa_plugin.h>
42 #include <ardour/panner.h>
43 #include <ardour/dB.h>
44 #include <ardour/mix.h>
45 #include <ardour/amp.h>
46 #include <ardour/meter.h>
47 #include <ardour/buffer_set.h>
51 using namespace ARDOUR;
54 uint32_t Route::order_key_cnt = 0;
57 Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, DataType default_type)
58 : IO (sess, name, input_min, input_max, output_min, output_max, default_type),
60 _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
61 _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
66 Route::Route (Session& sess, const XMLNode& node, DataType default_type)
67 : IO (sess, *node.child ("IO"), default_type),
68 _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
69 _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
72 _set_state (node, false);
78 redirect_max_outs.reset();
82 _phase_invert = false;
83 order_keys[N_("signal")] = order_key_cnt++;
86 _meter_point = MeterPostFader;
90 _have_internal_generator = false;
92 _pending_declick = true;
93 _remote_control_id = 0;
98 _mute_affects_pre_fader = Config->get_mute_affects_pre_fader();
99 _mute_affects_post_fader = Config->get_mute_affects_post_fader();
100 _mute_affects_control_outs = Config->get_mute_affects_control_outs();
101 _mute_affects_main_outs = Config->get_mute_affects_main_outs();
104 desired_solo_gain = 1.0;
106 desired_mute_gain = 1.0;
110 input_changed.connect (mem_fun (this, &Route::input_change_handler));
111 output_changed.connect (mem_fun (this, &Route::output_change_handler));
116 clear_redirects (this);
119 delete _control_outs;
124 Route::set_remote_control_id (uint32_t id)
126 if (id != _remote_control_id) {
127 _remote_control_id = id;
128 RemoteControlIDChanged ();
133 Route::remote_control_id() const
135 return _remote_control_id;
139 Route::order_key (string name) const
141 OrderKeys::const_iterator i;
143 if ((i = order_keys.find (name)) == order_keys.end()) {
151 Route::set_order_key (string name, long n)
153 order_keys[name] = n;
154 _session.set_dirty ();
158 Route::inc_gain (gain_t fraction, void *src)
160 IO::inc_gain (fraction, src);
164 Route::set_gain (gain_t val, void *src)
166 if (src != 0 && _mix_group && src != _mix_group && _mix_group->is_active()) {
168 if (_mix_group->is_relative()) {
171 gain_t usable_gain = gain();
172 if (usable_gain < 0.000001f) {
173 usable_gain=0.000001f;
177 if (delta < 0.000001f) {
181 delta -= usable_gain;
183 if (delta == 0.0f) return;
185 gain_t factor = delta / usable_gain;
188 factor = _mix_group->get_max_factor(factor);
189 if (factor == 0.0f) {
194 factor = _mix_group->get_min_factor(factor);
195 if (factor == 0.0f) {
201 _mix_group->apply (&Route::inc_gain, factor, _mix_group);
205 _mix_group->apply (&Route::set_gain, val, _mix_group);
215 IO::set_gain (val, src);
218 /** Process this route for one (sub) cycle (process thread)
220 * @param bufs Scratch buffers to use for the signal path
221 * @param start_frame Initial transport frame
222 * @param end_frame Final transport frame
223 * @param nframes Number of frames to output (to ports)
224 * @param offset Output offset (of port buffers, for split cycles)
226 * Note that (end_frame - start_frame) may not be equal to nframes when the
227 * transport speed isn't 1.0 (eg varispeed).
230 Route::process_output_buffers (BufferSet& bufs,
231 nframes_t start_frame, nframes_t end_frame,
232 nframes_t nframes, nframes_t offset, bool with_redirects, int declick,
235 // This is definitely very audio-only for now
236 assert(_default_type == DataType::AUDIO);
238 RedirectList::iterator i;
239 bool post_fader_work = false;
240 bool mute_declick_applied = false;
246 gain_t* gab = _session.gain_automation_buffer();
248 switch (Config->get_monitoring_model()) {
249 case HardwareMonitoring:
250 case ExternalMonitoring:
257 declick = _pending_declick;
260 Glib::Mutex::Lock cm (control_outs_lock, Glib::TRY_LOCK);
270 Glib::Mutex::Lock dm (declick_lock, Glib::TRY_LOCK);
273 dmg = desired_mute_gain;
274 dsg = desired_solo_gain;
283 /* ----------------------------------------------------------------------------------------------------
284 GLOBAL DECLICK (for transport changes etc.)
285 -------------------------------------------------------------------------------------------------- */
288 Amp::run (bufs, nframes, 0.0, 1.0, false);
289 _pending_declick = 0;
290 } else if (declick < 0) {
291 Amp::run (bufs, nframes, 1.0, 0.0, false);
292 _pending_declick = 0;
295 /* no global declick */
297 if (solo_gain != dsg) {
298 Amp::run (bufs, nframes, solo_gain, dsg, false);
304 /* ----------------------------------------------------------------------------------------------------
305 INPUT METERING & MONITORING
306 -------------------------------------------------------------------------------------------------- */
308 if (meter && (_meter_point == MeterInput)) {
309 _meter->run(bufs, nframes);
312 if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
313 Amp::run (bufs, nframes, mute_gain, dmg, false);
315 mute_declick_applied = true;
318 if ((_meter_point == MeterInput) && co) {
320 solo_audible = dsg > 0;
321 mute_audible = dmg > 0;// || !_mute_affects_pre_fader;
323 if ( // muted by solo of another track
327 // muted by mute of this track
331 // rec-enabled but not s/w monitoring
333 // TODO: this is probably wrong
335 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
339 co->silence (nframes, offset);
343 co->deliver_output (bufs, start_frame, end_frame, nframes, offset);
348 /* ---------------------------------------------------------------------------------------------------
350 -------------------------------------------------------------------------------------------------- */
352 /* FIXME: Somewhere in these loops is where bufs.count() should go from n_inputs() to redirect_max_outs()
353 * (if they differ). Something explicit needs to be done here to make sure the list of redirects will
354 * give us what we need (possibly by inserting transparent 'translators' into the list to make it work) */
356 if (with_redirects) {
357 Glib::RWLock::ReaderLock rm (redirect_lock, Glib::TRY_LOCK);
359 if (mute_gain > 0 || !_mute_affects_pre_fader) {
360 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
361 switch ((*i)->placement()) {
363 (*i)->run (bufs, start_frame, end_frame, nframes, offset);
366 post_fader_work = true;
371 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
372 switch ((*i)->placement()) {
374 (*i)->silence (nframes, offset);
377 post_fader_work = true;
385 // FIXME: for now, just hope the redirects list did what it was supposed to
386 bufs.set_count(n_process_buffers());
389 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
390 Amp::run (bufs, nframes, mute_gain, dmg, false);
392 mute_declick_applied = true;
395 /* ----------------------------------------------------------------------------------------------------
396 PRE-FADER METERING & MONITORING
397 -------------------------------------------------------------------------------------------------- */
399 if (meter && (_meter_point == MeterPreFader)) {
400 _meter->run(bufs, nframes);
404 if ((_meter_point == MeterPreFader) && co) {
406 solo_audible = dsg > 0;
407 mute_audible = dmg > 0 || !_mute_affects_pre_fader;
409 if ( // muted by solo of another track
413 // muted by mute of this track
417 // rec-enabled but not s/w monitoring
419 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
423 co->silence (nframes, offset);
427 co->deliver_output (bufs, start_frame, end_frame, nframes, offset);
432 /* ----------------------------------------------------------------------------------------------------
434 -------------------------------------------------------------------------------------------------- */
436 /* if not recording or recording and requiring any monitor signal, then apply gain */
438 if ( // not recording
440 !(record_enabled() && _session.actively_recording()) ||
444 // h/w monitoring not in use
446 (!Config->get_monitoring_model() == HardwareMonitoring &&
448 // AND software monitoring required
450 Config->get_monitoring_model() == SoftwareMonitoring)) {
452 if (apply_gain_automation) {
455 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
456 Sample* const sp = i->data(nframes);
458 for (nframes_t nx = 0; nx < nframes; ++nx) {
463 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
464 Sample* const sp = i->data(nframes);
466 for (nframes_t nx = 0; nx < nframes; ++nx) {
472 if (apply_gain_automation && _session.transport_rolling() && nframes > 0) {
473 _effective_gain = gab[nframes-1];
478 /* manual (scalar) gain */
482 Amp::run (bufs, nframes, _gain, dg, _phase_invert);
485 } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
487 /* no need to interpolate current gain value,
488 but its non-unity, so apply it. if the gain
489 is zero, do nothing because we'll ship silence
501 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
502 Sample* const sp = i->data(nframes);
503 Session::apply_gain_to_buffer(sp,nframes,this_gain);
506 } else if (_gain == 0) {
507 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
515 /* actively recording, no monitoring required; leave buffers as-is to save CPU cycles */
519 /* ----------------------------------------------------------------------------------------------------
521 -------------------------------------------------------------------------------------------------- */
523 /* note that post_fader_work cannot be true unless with_redirects was also true, so don't test both */
525 if (post_fader_work) {
527 Glib::RWLock::ReaderLock rm (redirect_lock, Glib::TRY_LOCK);
529 if (mute_gain > 0 || !_mute_affects_post_fader) {
530 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
531 switch ((*i)->placement()) {
535 (*i)->run (bufs, start_frame, end_frame, nframes, offset);
540 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
541 switch ((*i)->placement()) {
545 (*i)->silence (nframes, offset);
553 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
554 Amp::run (bufs, nframes, mute_gain, dmg, false);
556 mute_declick_applied = true;
559 /* ----------------------------------------------------------------------------------------------------
561 -------------------------------------------------------------------------------------------------- */
563 if ((_meter_point == MeterPostFader) && co) {
565 solo_audible = solo_gain > 0;
566 mute_audible = dmg > 0 || !_mute_affects_control_outs;
568 if ( // silent anyway
570 (_gain == 0 && !apply_gain_automation) ||
572 // muted by solo of another track
576 // muted by mute of this track
580 // recording but not s/w monitoring
582 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
586 co->silence (nframes, offset);
590 co->deliver_output (bufs, start_frame, end_frame, nframes, offset);
594 /* ----------------------------------------------------------------------
596 ----------------------------------------------------------------------*/
598 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
599 Amp::run (bufs, nframes, mute_gain, dmg, false);
601 mute_declick_applied = true;
604 /* ----------------------------------------------------------------------------------------------------
606 -------------------------------------------------------------------------------------------------- */
608 solo_audible = dsg > 0;
609 mute_audible = dmg > 0 || !_mute_affects_main_outs;
611 if (n_outputs().get(_default_type) == 0) {
615 } else if (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording())) {
617 IO::silence (nframes, offset);
621 if ( // silent anyway
623 (_gain == 0 && !apply_gain_automation) ||
625 // muted by solo of another track, but not using control outs for solo
627 (!solo_audible && (Config->get_solo_model() != SoloBus)) ||
629 // muted by mute of this track
635 /* don't use Route::silence() here, because that causes
636 all outputs (sends, port inserts, etc. to be silent).
639 if (_meter_point == MeterPostFader) {
640 peak_meter().reset();
643 IO::silence (nframes, offset);
647 deliver_output(bufs, start_frame, end_frame, nframes, offset);
653 /* ----------------------------------------------------------------------------------------------------
655 -------------------------------------------------------------------------------------------------- */
657 if (meter && (_meter_point == MeterPostFader)) {
658 if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
661 _meter->run(output_buffers(), nframes, offset);
667 Route::n_process_buffers ()
669 return max (n_inputs(), redirect_max_outs);
673 Route::passthru (nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset, int declick, bool meter_first)
675 BufferSet& bufs = _session.get_scratch_buffers(n_process_buffers());
679 collect_input (bufs, nframes, offset);
681 #define meter_stream meter_first
684 _meter->run(bufs, nframes);
685 meter_stream = false;
690 process_output_buffers (bufs, start_frame, end_frame, nframes, offset, true, declick, meter_stream);
696 Route::passthru_silence (jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t nframes, jack_nframes_t offset, int declick, bool meter)
698 process_output_buffers (_session.get_silent_buffers (n_process_buffers()), start_frame, end_frame, nframes, offset, true, declick, meter);
702 Route::set_solo (bool yn, void *src)
708 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
709 _mix_group->apply (&Route::set_solo, yn, _mix_group);
715 solo_changed (src); /* EMIT SIGNAL */
716 _solo_control.Changed (); /* EMIT SIGNAL */
721 Route::set_solo_mute (bool yn)
723 Glib::Mutex::Lock lm (declick_lock);
725 /* Called by Session in response to another Route being soloed.
728 desired_solo_gain = (yn?0.0:1.0);
732 Route::set_solo_safe (bool yn, void *src)
734 if (_solo_safe != yn) {
736 solo_safe_changed (src); /* EMIT SIGNAL */
741 Route::set_mute (bool yn, void *src)
744 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
745 _mix_group->apply (&Route::set_mute, yn, _mix_group);
751 mute_changed (src); /* EMIT SIGNAL */
753 _mute_control.Changed (); /* EMIT SIGNAL */
755 Glib::Mutex::Lock lm (declick_lock);
756 desired_mute_gain = (yn?0.0f:1.0f);
761 Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams)
763 ChanCount old_rmo = redirect_max_outs;
765 if (!_session.engine().connected()) {
770 Glib::RWLock::WriterLock lm (redirect_lock);
772 boost::shared_ptr<PluginInsert> pi;
773 boost::shared_ptr<PortInsert> porti;
775 redirect->set_default_type(_default_type);
777 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redirect)) != 0) {
780 if (pi->input_streams() == ChanCount::ZERO) {
781 /* generator plugin */
782 _have_internal_generator = true;
785 } else if ((porti = boost::dynamic_pointer_cast<PortInsert>(redirect)) != 0) {
787 /* force new port inserts to start out with an i/o configuration
788 that matches this route's i/o configuration.
790 the "inputs" for the port are supposed to match the output
793 the "outputs" of the route should match the inputs of this
794 route. XXX shouldn't they match the number of active signal
795 streams at the point of insertion?
797 // FIXME: (yes, they should)
799 porti->ensure_io (n_outputs (), n_inputs(), false, this);
802 // Ensure peak vector sizes before the plugin is activated
803 ChanCount potential_max_streams = max(redirect->input_streams(), redirect->output_streams());
804 _meter->setup(potential_max_streams);
806 _redirects.push_back (redirect);
808 if (_reset_plugin_counts (err_streams)) {
809 _redirects.pop_back ();
810 _reset_plugin_counts (0); // it worked before we tried to add it ...
814 redirect->activate ();
815 redirect->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
818 if (redirect_max_outs != old_rmo || old_rmo == ChanCount::ZERO) {
823 redirects_changed (src); /* EMIT SIGNAL */
828 Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_streams)
830 ChanCount old_rmo = redirect_max_outs;
832 if (!_session.engine().connected()) {
837 Glib::RWLock::WriterLock lm (redirect_lock);
839 RedirectList::iterator existing_end = _redirects.end();
842 ChanCount potential_max_streams;
844 for (RedirectList::const_iterator i = others.begin(); i != others.end(); ++i) {
846 boost::shared_ptr<PluginInsert> pi;
848 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
851 ChanCount m = max(pi->input_streams(), pi->output_streams());
852 if (m > potential_max_streams)
853 potential_max_streams = m;
856 // Ensure peak vector sizes before the plugin is activated
857 _meter->setup(potential_max_streams);
859 _redirects.push_back (*i);
861 if (_reset_plugin_counts (err_streams)) {
863 _redirects.erase (existing_end, _redirects.end());
864 _reset_plugin_counts (0); // it worked before we tried to add it ...
869 (*i)->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
873 if (redirect_max_outs != old_rmo || old_rmo == ChanCount::ZERO) {
877 redirects_changed (src); /* EMIT SIGNAL */
882 Route::clear_redirects (void *src)
884 ChanCount old_rmo = redirect_max_outs;
886 if (!_session.engine().connected()) {
891 Glib::RWLock::WriterLock lm (redirect_lock);
895 if (redirect_max_outs != old_rmo) {
899 redirect_max_outs.reset();
900 _have_internal_generator = false;
901 redirects_changed (src); /* EMIT SIGNAL */
905 Route::remove_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams)
907 ChanCount old_rmo = redirect_max_outs;
909 if (!_session.engine().connected()) {
913 redirect_max_outs.reset();
916 Glib::RWLock::WriterLock lm (redirect_lock);
917 RedirectList::iterator i;
918 bool removed = false;
920 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
921 if (*i == redirect) {
923 RedirectList::iterator tmp;
925 /* move along, see failure case for reset_plugin_counts()
926 where we may need to reinsert the redirect.
932 /* stop redirects that send signals to JACK ports
933 from causing noise as a result of no longer being
937 boost::shared_ptr<Send> send;
938 boost::shared_ptr<PortInsert> port_insert;
940 if ((send = boost::dynamic_pointer_cast<Send> (*i)) != 0) {
941 send->disconnect_inputs (this);
942 send->disconnect_outputs (this);
943 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (*i)) != 0) {
944 port_insert->disconnect_inputs (this);
945 port_insert->disconnect_outputs (this);
948 _redirects.erase (i);
961 if (_reset_plugin_counts (err_streams)) {
962 /* get back to where we where */
963 _redirects.insert (i, redirect);
964 /* we know this will work, because it worked before :) */
965 _reset_plugin_counts (0);
971 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
972 boost::shared_ptr<PluginInsert> pi;
974 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
975 if (pi->is_generator()) {
981 _have_internal_generator = foo;
984 if (old_rmo != redirect_max_outs) {
988 redirects_changed (src); /* EMIT SIGNAL */
993 Route::reset_plugin_counts (uint32_t* lpc)
995 Glib::RWLock::WriterLock lm (redirect_lock);
996 return _reset_plugin_counts (lpc);
1001 Route::_reset_plugin_counts (uint32_t* err_streams)
1003 RedirectList::iterator r;
1006 map<Placement,list<InsertCount> > insert_map;
1007 nframes_t initial_streams;
1009 redirect_max_outs.reset();
1013 /* divide inserts up by placement so we get the signal flow
1014 properly modelled. we need to do this because the _redirects
1015 list is not sorted by placement, and because other reasons may
1016 exist now or in the future for this separate treatment.
1019 for (r = _redirects.begin(); r != _redirects.end(); ++r) {
1021 boost::shared_ptr<Insert> insert;
1023 /* do this here in case we bomb out before we get to the end of
1027 redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs);
1029 if ((insert = boost::dynamic_pointer_cast<Insert>(*r)) != 0) {
1031 insert_map[insert->placement()].push_back (InsertCount (insert));
1033 /* reset plugin counts back to one for now so
1034 that we have a predictable, controlled
1035 state to try to configure.
1038 boost::shared_ptr<PluginInsert> pi;
1040 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(insert)) != 0) {
1044 } else if (boost::dynamic_pointer_cast<Send> (*r) != 0) {
1057 /* Now process each placement in order, checking to see if we
1058 can really do what has been requested.
1063 if (check_some_plugin_counts (insert_map[PreFader], n_inputs ().get(_default_type), err_streams)) {
1067 /* figure out the streams that will feed into PreFader */
1069 if (!insert_map[PreFader].empty()) {
1070 InsertCount& ic (insert_map[PreFader].back());
1071 initial_streams = ic.insert->compute_output_streams (ic.cnt);
1073 initial_streams = n_inputs ().get(_default_type);
1078 if (check_some_plugin_counts (insert_map[PostFader], initial_streams, err_streams)) {
1082 /* OK, everything can be set up correctly, so lets do it */
1084 apply_some_plugin_counts (insert_map[PreFader]);
1085 apply_some_plugin_counts (insert_map[PostFader]);
1087 /* recompute max outs of any redirect */
1091 redirect_max_outs.reset();
1092 RedirectList::iterator prev = _redirects.end();
1094 for (r = _redirects.begin(); r != _redirects.end(); prev = r, ++r) {
1095 boost::shared_ptr<Send> s;
1097 if ((s = boost::dynamic_pointer_cast<Send> (*r)) != 0) {
1098 if (r == _redirects.begin()) {
1099 s->expect_inputs (n_inputs());
1101 s->expect_inputs ((*prev)->output_streams());
1105 redirect_max_outs = max ((*r)->output_streams(), redirect_max_outs);
1114 Route::apply_some_plugin_counts (list<InsertCount>& iclist)
1116 list<InsertCount>::iterator i;
1118 for (i = iclist.begin(); i != iclist.end(); ++i) {
1120 if ((*i).insert->configure_io ((*i).cnt, (*i).in, (*i).out)) {
1123 /* make sure that however many we have, they are all active */
1124 (*i).insert->activate ();
1131 Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inputs, uint32_t* err_streams)
1133 list<InsertCount>::iterator i;
1135 for (i = iclist.begin(); i != iclist.end(); ++i) {
1137 if (((*i).cnt = (*i).insert->can_support_input_configuration (required_inputs)) < 0) {
1139 *err_streams = required_inputs;
1144 (*i).in = required_inputs;
1145 (*i).out = (*i).insert->compute_output_streams ((*i).cnt);
1147 required_inputs = (*i).out;
1154 Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_streams)
1156 ChanCount old_rmo = redirect_max_outs;
1162 RedirectList to_be_deleted;
1165 Glib::RWLock::WriterLock lm (redirect_lock);
1166 RedirectList::iterator tmp;
1167 RedirectList the_copy;
1169 the_copy = _redirects;
1171 /* remove all relevant redirects */
1173 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1177 if ((*i)->placement() == placement) {
1178 to_be_deleted.push_back (*i);
1179 _redirects.erase (i);
1185 /* now copy the relevant ones from "other" */
1187 for (RedirectList::const_iterator i = other._redirects.begin(); i != other._redirects.end(); ++i) {
1188 if ((*i)->placement() == placement) {
1189 _redirects.push_back (Redirect::clone (*i));
1193 /* reset plugin stream handling */
1195 if (_reset_plugin_counts (err_streams)) {
1197 /* FAILED COPY ATTEMPT: we have to restore order */
1199 /* delete all cloned redirects */
1201 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1206 if ((*i)->placement() == placement) {
1207 _redirects.erase (i);
1213 /* restore the natural order */
1215 _redirects = the_copy;
1216 redirect_max_outs = old_rmo;
1218 /* we failed, even though things are OK again */
1224 /* SUCCESSFUL COPY ATTEMPT: delete the redirects we removed pre-copy */
1225 to_be_deleted.clear ();
1229 if (redirect_max_outs != old_rmo || old_rmo == ChanCount::ZERO) {
1233 redirects_changed (this); /* EMIT SIGNAL */
1238 Route::all_redirects_flip ()
1240 Glib::RWLock::ReaderLock lm (redirect_lock);
1242 if (_redirects.empty()) {
1246 bool first_is_on = _redirects.front()->active();
1248 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1249 (*i)->set_active (!first_is_on, this);
1254 Route::all_redirects_active (bool state)
1256 Glib::RWLock::ReaderLock lm (redirect_lock);
1258 if (_redirects.empty()) {
1262 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1263 (*i)->set_active (state, this);
1267 struct RedirectSorter {
1268 bool operator() (boost::shared_ptr<const Redirect> a, boost::shared_ptr<const Redirect> b) {
1269 return a->sort_key() < b->sort_key();
1274 Route::sort_redirects (uint32_t* err_streams)
1277 RedirectSorter comparator;
1278 Glib::RWLock::WriterLock lm (redirect_lock);
1279 ChanCount old_rmo = redirect_max_outs;
1281 /* the sweet power of C++ ... */
1283 RedirectList as_it_was_before = _redirects;
1285 _redirects.sort (comparator);
1287 if (_reset_plugin_counts (err_streams)) {
1288 _redirects = as_it_was_before;
1289 redirect_max_outs = old_rmo;
1295 redirects_changed (this); /* EMIT SIGNAL */
1307 Route::get_template()
1309 return state(false);
1313 Route::state(bool full_state)
1315 XMLNode *node = new XMLNode("Route");
1316 RedirectList:: iterator i;
1320 snprintf (buf, sizeof (buf), "0x%x", _flags);
1321 node->add_property("flags", buf);
1324 node->add_property("default-type", _default_type.to_string());
1326 node->add_property("active", _active?"yes":"no");
1327 node->add_property("muted", _muted?"yes":"no");
1328 node->add_property("soloed", _soloed?"yes":"no");
1329 node->add_property("phase-invert", _phase_invert?"yes":"no");
1330 node->add_property("mute-affects-pre-fader", _mute_affects_pre_fader?"yes":"no");
1331 node->add_property("mute-affects-post-fader", _mute_affects_post_fader?"yes":"no");
1332 node->add_property("mute-affects-control-outs", _mute_affects_control_outs?"yes":"no");
1333 node->add_property("mute-affects-main-outs", _mute_affects_main_outs?"yes":"no");
1336 node->add_property("edit-group", _edit_group->name());
1339 node->add_property("mix-group", _mix_group->name());
1342 string order_string;
1343 OrderKeys::iterator x = order_keys.begin();
1345 while (x != order_keys.end()) {
1346 order_string += (*x).first;
1347 order_string += '=';
1348 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1349 order_string += buf;
1353 if (x == order_keys.end()) {
1357 order_string += ':';
1359 node->add_property ("order-keys", order_string);
1361 node->add_child_nocopy (IO::state (full_state));
1362 node->add_child_nocopy (_solo_control.get_state ());
1363 node->add_child_nocopy (_mute_control.get_state ());
1365 if (_control_outs) {
1366 XMLNode* cnode = new XMLNode (X_("ControlOuts"));
1367 cnode->add_child_nocopy (_control_outs->state (full_state));
1368 node->add_child_nocopy (*cnode);
1371 if (_comment.length()) {
1372 XMLNode *cmt = node->add_child ("Comment");
1373 cmt->add_content (_comment);
1376 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
1377 node->add_child_nocopy((*i)->state (full_state));
1381 node->add_child_copy (*_extra_xml);
1388 Route::set_deferred_state ()
1391 XMLNodeConstIterator niter;
1393 if (!deferred_state) {
1397 nlist = deferred_state->children();
1399 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1400 add_redirect_from_xml (**niter);
1403 delete deferred_state;
1408 Route::add_redirect_from_xml (const XMLNode& node)
1410 const XMLProperty *prop;
1412 if (node.name() == "Send") {
1416 boost::shared_ptr<Send> send (new Send (_session, node));
1417 add_redirect (send, this);
1420 catch (failed_constructor &err) {
1421 error << _("Send construction failed") << endmsg;
1425 } else if (node.name() == "Insert") {
1428 if ((prop = node.property ("type")) != 0) {
1430 boost::shared_ptr<Insert> insert;
1432 if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") {
1434 insert.reset (new PluginInsert(_session, node));
1436 } else if (prop->value() == "port") {
1439 insert.reset (new PortInsert (_session, node));
1443 error << string_compose(_("unknown Insert type \"%1\"; ignored"), prop->value()) << endmsg;
1446 add_redirect (insert, this);
1449 error << _("Insert XML node has no type property") << endmsg;
1453 catch (failed_constructor &err) {
1454 warning << _("insert could not be created. Ignored.") << endmsg;
1461 Route::set_state (const XMLNode& node)
1463 return _set_state (node, true);
1467 Route::_set_state (const XMLNode& node, bool call_base)
1470 XMLNodeConstIterator niter;
1472 XMLPropertyList plist;
1473 const XMLProperty *prop;
1475 if (node.name() != "Route"){
1476 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1480 if ((prop = node.property (X_("flags"))) != 0) {
1482 sscanf (prop->value().c_str(), "0x%x", &x);
1488 if ((prop = node.property (X_("default-type"))) != 0) {
1489 _default_type = DataType(prop->value());
1490 assert(_default_type != DataType::NIL);
1493 if ((prop = node.property (X_("phase-invert"))) != 0) {
1494 set_phase_invert(prop->value()=="yes"?true:false, this);
1497 if ((prop = node.property (X_("active"))) != 0) {
1498 set_active (prop->value() == "yes");
1501 if ((prop = node.property (X_("muted"))) != 0) {
1502 bool yn = prop->value()=="yes"?true:false;
1504 /* force reset of mute status */
1508 mute_gain = desired_mute_gain;
1511 if ((prop = node.property (X_("soloed"))) != 0) {
1512 bool yn = prop->value()=="yes"?true:false;
1514 /* force reset of solo status */
1517 set_solo (yn, this);
1518 solo_gain = desired_solo_gain;
1521 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
1522 _mute_affects_pre_fader = (prop->value()=="yes")?true:false;
1525 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
1526 _mute_affects_post_fader = (prop->value()=="yes")?true:false;
1529 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
1530 _mute_affects_control_outs = (prop->value()=="yes")?true:false;
1533 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
1534 _mute_affects_main_outs = (prop->value()=="yes")?true:false;
1537 if ((prop = node.property (X_("edit-group"))) != 0) {
1538 RouteGroup* edit_group = _session.edit_group_by_name(prop->value());
1539 if(edit_group == 0) {
1540 error << string_compose(_("Route %1: unknown edit group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1542 set_edit_group(edit_group, this);
1546 if ((prop = node.property (X_("order-keys"))) != 0) {
1550 string::size_type colon, equal;
1551 string remaining = prop->value();
1553 while (remaining.length()) {
1555 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1556 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1559 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1560 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1563 set_order_key (remaining.substr (0, equal), n);
1567 colon = remaining.find_first_of (':');
1569 if (colon != string::npos) {
1570 remaining = remaining.substr (colon+1);
1577 nlist = node.children();
1579 if (deferred_state) {
1580 delete deferred_state;
1583 deferred_state = new XMLNode(X_("deferred state"));
1585 /* set parent class properties before anything else */
1587 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1591 if (child->name() == IO::state_node_name && call_base) {
1593 IO::set_state (*child);
1598 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1602 if (child->name() == X_("Send")) {
1605 if (!IO::ports_legal) {
1607 deferred_state->add_child_copy (*child);
1610 add_redirect_from_xml (*child);
1613 } else if (child->name() == X_("Insert")) {
1615 if (!IO::ports_legal) {
1617 deferred_state->add_child_copy (*child);
1621 add_redirect_from_xml (*child);
1624 } else if (child->name() == X_("Automation")) {
1626 if ((prop = child->property (X_("path"))) != 0) {
1627 load_automation (prop->value());
1630 } else if (child->name() == X_("ControlOuts")) {
1632 string coutname = _name;
1633 coutname += _("[control]");
1635 _control_outs = new IO (_session, coutname);
1636 _control_outs->set_state (**(child->children().begin()));
1638 } else if (child->name() == X_("Comment")) {
1640 /* XXX this is a terrible API design in libxml++ */
1642 XMLNode *cmt = *(child->children().begin());
1643 _comment = cmt->content();
1645 } else if (child->name() == X_("extra")) {
1646 _extra_xml = new XMLNode (*child);
1647 } else if (child->name() == X_("solo")) {
1648 _solo_control.set_state (*child);
1649 _session.add_controllable (&_solo_control);
1650 } else if (child->name() == X_("mute")) {
1651 _mute_control.set_state (*child);
1652 _session.add_controllable (&_mute_control);
1656 if ((prop = node.property (X_("mix-group"))) != 0) {
1657 RouteGroup* mix_group = _session.mix_group_by_name(prop->value());
1658 if (mix_group == 0) {
1659 error << string_compose(_("Route %1: unknown mix group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1661 set_mix_group(mix_group, this);
1669 Route::curve_reallocate ()
1671 // _gain_automation_curve.finish_resize ();
1672 // _pan_automation_curve.finish_resize ();
1676 Route::silence (nframes_t nframes, nframes_t offset)
1680 IO::silence (nframes, offset);
1682 if (_control_outs) {
1683 _control_outs->silence (nframes, offset);
1687 Glib::RWLock::ReaderLock lm (redirect_lock, Glib::TRY_LOCK);
1690 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1691 boost::shared_ptr<PluginInsert> pi;
1692 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
1693 // skip plugins, they don't need anything when we're not active
1697 (*i)->silence (nframes, offset);
1700 if (nframes == _session.get_block_size() && offset == 0) {
1710 Route::set_control_outs (const vector<string>& ports)
1712 Glib::Mutex::Lock lm (control_outs_lock);
1713 vector<string>::const_iterator i;
1715 if (_control_outs) {
1716 delete _control_outs;
1720 if (ports.empty()) {
1724 string coutname = _name;
1725 coutname += _("[control]");
1727 _control_outs = new IO (_session, coutname);
1729 /* our control outs need as many outputs as we
1730 have audio outputs. we track the changes in ::output_change_handler().
1733 _control_outs->ensure_io (ChanCount::ZERO, ChanCount(DataType::AUDIO, n_outputs().get(DataType::AUDIO)), true, this);
1739 Route::set_edit_group (RouteGroup *eg, void *src)
1742 if (eg == _edit_group) {
1747 _edit_group->remove (this);
1750 if ((_edit_group = eg) != 0) {
1751 _edit_group->add (this);
1754 _session.set_dirty ();
1755 edit_group_changed (src); /* EMIT SIGNAL */
1759 Route::drop_edit_group (void *src)
1762 _session.set_dirty ();
1763 edit_group_changed (src); /* EMIT SIGNAL */
1767 Route::set_mix_group (RouteGroup *mg, void *src)
1770 if (mg == _mix_group) {
1775 _mix_group->remove (this);
1778 if ((_mix_group = mg) != 0) {
1779 _mix_group->add (this);
1782 _session.set_dirty ();
1783 mix_group_changed (src); /* EMIT SIGNAL */
1787 Route::drop_mix_group (void *src)
1790 _session.set_dirty ();
1791 mix_group_changed (src); /* EMIT SIGNAL */
1795 Route::set_comment (string cmt, void *src)
1798 comment_changed (src);
1799 _session.set_dirty ();
1803 Route::feeds (boost::shared_ptr<Route> other)
1808 uint32_t no = self.n_outputs().get_total();
1809 uint32_t ni = other->n_inputs ().get_total();
1811 for (i = 0; i < no; ++i) {
1812 for (j = 0; j < ni; ++j) {
1813 if (self.output(i)->connected_to (other->input(j)->name())) {
1819 /* check Redirects which may also interconnect Routes */
1821 for (RedirectList::iterator r = _redirects.begin(); r != _redirects.end(); r++) {
1823 no = (*r)->n_outputs().get_total();
1825 for (i = 0; i < no; ++i) {
1826 for (j = 0; j < ni; ++j) {
1827 if ((*r)->output(i)->connected_to (other->input (j)->name())) {
1834 /* check for control room outputs which may also interconnect Routes */
1836 if (_control_outs) {
1838 no = _control_outs->n_outputs().get_total();
1840 for (i = 0; i < no; ++i) {
1841 for (j = 0; j < ni; ++j) {
1842 if (_control_outs->output(i)->connected_to (other->input (j)->name())) {
1853 Route::set_mute_config (mute_type t, bool onoff, void *src)
1857 _mute_affects_pre_fader = onoff;
1858 pre_fader_changed(src); /* EMIT SIGNAL */
1862 _mute_affects_post_fader = onoff;
1863 post_fader_changed(src); /* EMIT SIGNAL */
1867 _mute_affects_control_outs = onoff;
1868 control_outs_changed(src); /* EMIT SIGNAL */
1872 _mute_affects_main_outs = onoff;
1873 main_outs_changed(src); /* EMIT SIGNAL */
1879 Route::get_mute_config (mute_type t)
1885 onoff = _mute_affects_pre_fader;
1888 onoff = _mute_affects_post_fader;
1891 onoff = _mute_affects_control_outs;
1894 onoff = _mute_affects_main_outs;
1902 Route::set_active (bool yn)
1905 active_changed(); /* EMIT SIGNAL */
1909 Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
1911 nframes_t now = _session.transport_frame();
1914 Glib::RWLock::ReaderLock lm (redirect_lock);
1917 automation_snapshot (now);
1920 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1922 if (Config->get_plugins_stop_with_transport() && can_flush_redirects) {
1923 (*i)->deactivate ();
1927 (*i)->transport_stopped (now);
1931 IO::transport_stopped (now);
1933 _roll_delay = _initial_delay;
1937 Route::input_change_handler (IOChange change, void *ignored)
1939 if (change & ConfigurationChanged) {
1940 reset_plugin_counts (0);
1945 Route::output_change_handler (IOChange change, void *ignored)
1947 if (change & ConfigurationChanged) {
1948 if (_control_outs) {
1949 _control_outs->ensure_io (ChanCount::ZERO, ChanCount(DataType::AUDIO, n_outputs().get(DataType::AUDIO)), true, this);
1952 reset_plugin_counts (0);
1957 Route::pans_required () const
1959 if (n_outputs().get(DataType::AUDIO) < 2) {
1963 return max (n_inputs ().get(DataType::AUDIO), static_cast<size_t>(redirect_max_outs.get(DataType::AUDIO)));
1967 Route::no_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset,
1968 bool session_state_changing, bool can_record, bool rec_monitors_input)
1970 if (n_outputs().get_total() == 0) {
1974 if (session_state_changing || !_active) {
1975 silence (nframes, offset);
1979 apply_gain_automation = false;
1981 if (n_inputs().get_total()) {
1982 passthru (start_frame, end_frame, nframes, offset, 0, false);
1984 silence (nframes, offset);
1991 Route::check_initial_delay (nframes_t nframes, nframes_t& offset, nframes_t& transport_frame)
1993 if (_roll_delay > nframes) {
1995 _roll_delay -= nframes;
1996 silence (nframes, offset);
1997 /* transport frame is not legal for caller to use */
2000 } else if (_roll_delay > 0) {
2002 nframes -= _roll_delay;
2004 silence (_roll_delay, offset);
2006 offset += _roll_delay;
2007 transport_frame += _roll_delay;
2016 Route::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset, int declick,
2017 bool can_record, bool rec_monitors_input)
2020 Glib::RWLock::ReaderLock lm (redirect_lock, Glib::TRY_LOCK);
2022 // automation snapshot can also be called from the non-rt context
2023 // and it uses the redirect list, so we take the lock out here
2024 automation_snapshot (_session.transport_frame());
2028 if ((n_outputs().get_total() == 0 && _redirects.empty()) || n_inputs().get_total() == 0 || !_active) {
2029 silence (nframes, offset);
2033 nframes_t unused = 0;
2035 if ((nframes = check_initial_delay (nframes, offset, unused)) == 0) {
2041 apply_gain_automation = false;
2044 Glib::Mutex::Lock am (automation_lock, Glib::TRY_LOCK);
2046 if (am.locked() && _session.transport_rolling()) {
2048 if (gain_automation_playback()) {
2049 apply_gain_automation = _gain_automation_curve.rt_safe_get_vector (start_frame, end_frame, _session.gain_automation_buffer(), nframes);
2054 passthru (start_frame, end_frame, nframes, offset, declick, false);
2060 Route::silent_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset,
2061 bool can_record, bool rec_monitors_input)
2063 silence (nframes, offset);
2068 Route::toggle_monitor_input ()
2070 for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
2071 i->ensure_monitor_input( ! i->monitoring_input());
2076 Route::has_external_redirects () const
2078 boost::shared_ptr<const PortInsert> pi;
2080 for (RedirectList::const_iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2081 if ((pi = boost::dynamic_pointer_cast<const PortInsert>(*i)) != 0) {
2083 for (PortSet::const_iterator port = pi->outputs().begin();
2084 port != pi->outputs().end(); ++port) {
2086 string port_name = port->name();
2087 string client_name = port_name.substr (0, port_name.find(':'));
2089 /* only say "yes" if the redirect is actually in use */
2091 if (client_name != "ardour" && pi->active()) {
2102 Route::flush_redirects ()
2104 /* XXX shouldn't really try to take this lock, since
2105 this is called from the RT audio thread.
2108 Glib::RWLock::ReaderLock lm (redirect_lock);
2110 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2111 (*i)->deactivate ();
2117 Route::set_meter_point (MeterPoint p, void *src)
2119 if (_meter_point != p) {
2121 meter_change (src); /* EMIT SIGNAL */
2122 _session.set_dirty ();
2127 Route::update_total_latency ()
2131 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2132 if ((*i)->active ()) {
2133 _own_latency += (*i)->latency ();
2137 set_port_latency (_own_latency);
2139 /* this (virtual) function is used for pure Routes,
2140 not derived classes like AudioTrack. this means
2141 that the data processed here comes from an input
2142 port, not prerecorded material, and therefore we
2143 have to take into account any input latency.
2146 _own_latency += input_latency ();
2148 return _own_latency;
2152 Route::set_latency_delay (nframes_t longest_session_latency)
2154 _initial_delay = longest_session_latency - _own_latency;
2156 if (_session.transport_stopped()) {
2157 _roll_delay = _initial_delay;
2162 Route::automation_snapshot (nframes_t now)
2164 IO::automation_snapshot (now);
2166 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2167 (*i)->automation_snapshot (now);
2171 Route::ToggleControllable::ToggleControllable (std::string name, Route& s, ToggleType tp)
2172 : Controllable (name), route (s), type(tp)
2178 Route::ToggleControllable::set_value (float val)
2180 bool bval = ((val >= 0.5f) ? true: false);
2184 route.set_mute (bval, this);
2187 route.set_solo (bval, this);
2195 Route::ToggleControllable::get_value (void) const
2201 val = route.muted() ? 1.0f : 0.0f;
2204 val = route.soloed() ? 1.0f : 0.0f;
2214 Route::set_block_size (nframes_t nframes)
2216 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2217 (*i)->set_block_size (nframes);
2222 Route::redirect_active_proxy (Redirect* ignored, void* ignored_src)
2224 _session.update_latency_compensation (false, false);
2228 Route::protect_automation ()
2230 switch (gain_automation_state()) {
2233 set_gain_automation_state (Off);
2239 switch (panner().automation_state ()) {
2242 panner().set_automation_state (Off);
2248 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2249 boost::shared_ptr<PluginInsert> pi;
2250 if ((pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2251 pi->protect_automation ();
2257 Route::set_pending_declick (int declick)
2260 /* this call is not allowed to turn off a pending declick unless "force" is true */
2262 _pending_declick = declick;
2264 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
2266 _pending_declick = 0;