c2750ccf98c1a4dbefaae59fb1a3968ab669e4d1
[ardour.git] / libs / ardour / track.cc
1 /*
2     Copyright (C) 2006 Paul Davis
3
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.
8
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.
13
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.
17 */
18 #include "pbd/error.h"
19
20 #include "ardour/amp.h"
21 #include "ardour/audioplaylist.h"
22 #include "ardour/audioregion.h"
23 #include "ardour/audiosource.h"
24 #include "ardour/debug.h"
25 #include "ardour/delivery.h"
26 #include "ardour/diskstream.h"
27 #include "ardour/io_processor.h"
28 #include "ardour/meter.h"
29 #include "ardour/port.h"
30 #include "ardour/processor.h"
31 #include "ardour/route_group_specialized.h"
32 #include "ardour/session.h"
33 #include "ardour/track.h"
34 #include "ardour/utils.h"
35
36 #include "i18n.h"
37
38 using namespace std;
39 using namespace ARDOUR;
40 using namespace PBD;
41
42 Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type)
43         : Route (sess, name, flag, default_type)
44         , _saved_meter_point (_meter_point)
45         , _mode (mode)
46         , _monitoring (MonitorAuto)
47 {
48         _freeze_record.state = NoFreeze;
49         _declickable = true;
50
51         Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1));
52 }
53
54 Track::~Track ()
55 {
56         DEBUG_TRACE (DEBUG::Destruction, string_compose ("track %1 destructor\n", _name));
57 }
58
59 int
60 Track::init ()
61 {
62         if (Route::init ()) {
63                 return -1;
64         }
65
66         boost::shared_ptr<Route> rp (shared_from_this());
67         boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
68         _rec_enable_control = boost::shared_ptr<RecEnableControl> (new RecEnableControl(rt));
69         _rec_enable_control->set_flags (Controllable::Toggle);
70
71         /* don't add rec_enable_control to controls because we don't want it to
72          * appear as an automatable parameter
73          */
74
75         return 0;
76 }
77
78 void
79 Track::use_new_diskstream ()
80 {
81         boost::shared_ptr<Diskstream> ds = create_diskstream ();
82
83         ds->do_refill_with_alloc ();
84         ds->set_block_size (_session.get_block_size ());
85         ds->playlist()->set_orig_track_id (id());
86
87         set_diskstream (ds);
88 }
89
90 XMLNode&
91 Track::get_state ()
92 {
93         return state (true);
94 }
95
96 XMLNode&
97 Track::state (bool full)
98 {
99         XMLNode& root (Route::state (full));
100         root.add_property (X_("monitoring"), enum_2_string (_monitoring));
101         root.add_property (X_("saved-meter-point"), enum_2_string (_saved_meter_point));
102         root.add_child_nocopy (_rec_enable_control->get_state());
103         root.add_child_nocopy (_diskstream->get_state ());
104
105         if (!_deactivated_processors.empty ()) {
106                 XMLNode* node = new XMLNode (X_("DeactivatedProcessors"));
107                 for (list<boost::weak_ptr<Processor> >::iterator i = _deactivated_processors.begin(); i != _deactivated_processors.end(); ++i) {
108                         boost::shared_ptr<Processor> p = i->lock ();
109                         if (p) {
110                                 XMLNode* c = new XMLNode (X_("Processor"));
111                                 c->add_property (X_("id"), p->id().to_s());
112                                 node->add_child_nocopy (*c);
113                         }
114                 }
115                 root.add_child_nocopy (*node);
116         }
117         
118         return root;
119 }       
120
121 int
122 Track::set_state (const XMLNode& node, int version)
123 {
124         if (Route::set_state (node, version)) {
125                 return -1;
126         }
127
128         XMLNode* child;
129
130         if (version >= 3000) {
131                 if ((child = find_named_node (node, X_("Diskstream"))) != 0) {
132                         boost::shared_ptr<Diskstream> ds = diskstream_factory (*child);
133                         ds->do_refill_with_alloc ();
134                         set_diskstream (ds);
135                 }
136         }
137
138         if (_diskstream) {
139                 _diskstream->playlist()->set_orig_track_id (id());
140         }
141
142         /* set rec-enable control *AFTER* setting up diskstream, because it may
143            want to operate on the diskstream as it sets its own state
144         */
145
146         XMLNodeList nlist = node.children();
147         for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
148                 child = *niter;
149
150                 XMLProperty* prop;
151                 if (child->name() == Controllable::xml_node_name && (prop = child->property ("name")) != 0) {
152                         if (prop->value() == X_("recenable")) {
153                                 _rec_enable_control->set_state (*child, version);
154                         }
155                 }
156
157                 if (child->name() == X_("DeactivatedProcessors")) {
158                         XMLNodeList dp = child->children ();
159                         for (XMLNodeConstIterator i = dp.begin(); i != dp.end(); ++i) {
160                                 assert ((*i)->name() == X_("Processor"));
161                                 XMLProperty* prop = (*i)->property (X_("id"));
162                                 boost::shared_ptr<Processor> p = processor_by_id (PBD::ID (prop->value ()));
163                                 if (p) {
164                                         _deactivated_processors.push_back (p);
165                                 }
166                         }
167                 }
168         }
169         
170         const XMLProperty* prop;
171
172         if ((prop = node.property (X_("monitoring"))) != 0) {
173                 _monitoring = MonitorChoice (string_2_enum (prop->value(), _monitoring));
174         } else {
175                 _monitoring = MonitorAuto;
176         }
177
178         if ((prop = node.property (X_("saved-meter-point"))) != 0) {
179                 _saved_meter_point = MeterPoint (string_2_enum (prop->value(), _saved_meter_point));
180         } else {
181                 _saved_meter_point = _meter_point;
182         }
183
184         return 0;
185 }
186
187 XMLNode&
188 Track::get_template ()
189 {
190         return state (false);
191 }
192
193 Track::FreezeRecord::~FreezeRecord ()
194 {
195         for (vector<FreezeRecordProcessorInfo*>::iterator i = processor_info.begin(); i != processor_info.end(); ++i) {
196                 delete *i;
197         }
198 }
199
200 Track::FreezeState
201 Track::freeze_state() const
202 {
203         return _freeze_record.state;
204 }
205
206 Track::RecEnableControl::RecEnableControl (boost::shared_ptr<Track> t)
207         : AutomationControl (t->session(), RecEnableAutomation, boost::shared_ptr<AutomationList>(), X_("recenable"))
208         , track (t)
209 {
210         boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(RecEnableAutomation)));
211         set_list (gl);
212 }
213
214 void
215 Track::RecEnableControl::set_value (double val)
216 {
217         boost::shared_ptr<Track> t = track.lock ();
218         if (!t) {
219                 return;
220         }
221         
222         t->set_record_enabled (val >= 0.5 ? true : false, this);
223 }
224
225 double
226 Track::RecEnableControl::get_value () const
227 {
228         boost::shared_ptr<Track> t = track.lock ();
229         if (!t) {
230                 return 0;
231         }
232         
233         return (t->record_enabled() ? 1.0 : 0.0);
234 }
235
236 bool
237 Track::record_enabled () const
238 {
239         return _diskstream && _diskstream->record_enabled ();
240 }
241
242 bool
243 Track::can_record()
244 {
245         bool will_record = true;
246         for (PortSet::iterator i = _input->ports().begin(); i != _input->ports().end() && will_record; ++i) {
247                 if (!i->connected())
248                         will_record = false;
249         }
250
251         return will_record;
252 }
253
254 /* Turn off visible processors (except Fader), keeping track of the old states */
255 void
256 Track::deactivate_visible_processors ()
257 {
258         _deactivated_processors.clear ();
259         Glib::RWLock::ReaderLock lm (_processor_lock);
260         
261         for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
262                 if ((*i)->active() && (*i)->display_to_user() && boost::dynamic_pointer_cast<Amp> (*i) == 0) {
263                         (*i)->deactivate ();
264                         _deactivated_processors.push_back (*i);
265                 }
266         }
267 }
268
269 /* Turn deactivated processors back on again */
270 void
271 Track::activate_deactivated_processors ()
272 {
273         for (list<boost::weak_ptr<Processor> >::iterator i = _deactivated_processors.begin(); i != _deactivated_processors.end(); ++i) {
274                 boost::shared_ptr<Processor> p = i->lock ();
275                 if (p) {
276                         p->activate ();
277                 }
278         }
279 }
280
281 void
282 Track::set_record_enabled (bool yn, void *src)
283 {
284         if (!_session.writable()) {
285                 return;
286         }
287
288         if (_freeze_record.state == Frozen) {
289                 return;
290         }
291
292         if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_recenable()) {
293                 _route_group->apply (&Track::set_record_enabled, yn, _route_group);
294                 return;
295         }
296
297         /* keep track of the meter point as it was before we rec-enabled */
298         if (!_diskstream->record_enabled()) {
299                 _saved_meter_point = _meter_point;
300         }
301
302         if (Config->get_do_not_record_plugins ()) {
303                 if (yn) {
304                         deactivate_visible_processors ();
305                 } else {
306                         activate_deactivated_processors ();
307                 }
308         }
309
310         _diskstream->set_record_enabled (yn);
311
312         if (_diskstream->record_enabled()) {
313                 if (_meter_point != MeterCustom) {
314                         set_meter_point (MeterInput);
315                 }
316         } else {
317                 set_meter_point (_saved_meter_point);
318         }
319
320         _rec_enable_control->Changed ();
321 }
322
323
324 bool
325 Track::set_name (const string& str)
326 {
327         bool ret;
328
329         if (record_enabled() && _session.actively_recording()) {
330                 /* this messes things up if done while recording */
331                 return false;
332         }
333
334         _diskstream->set_name (str);
335
336         /* save state so that the statefile fully reflects any filename changes */
337
338         if ((ret = Route::set_name (str)) == 0) {
339                 _session.save_state ("");
340         }
341
342         return ret;
343 }
344
345 void
346 Track::set_latency_compensation (framecnt_t longest_session_latency)
347 {
348         Route::set_latency_compensation (longest_session_latency);
349         _diskstream->set_roll_delay (_roll_delay);
350 }
351
352 int
353 Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
354 {
355         Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
356         if (!lm.locked()) {
357                 return 0;
358         }
359
360         bool can_record = _session.actively_recording ();
361
362         if (n_outputs().n_total() == 0) {
363                 return 0;
364         }
365
366         if (!_active) {
367                 silence (nframes);
368                 return 0;
369         }
370
371         if (session_state_changing) {
372                 if (_session.transport_speed() != 0.0f) {
373                         /* we're rolling but some state is changing (e.g. our diskstream contents)
374                            so we cannot use them. Be silent till this is over. Don't declick.
375
376                            XXX note the absurdity of ::no_roll() being called when we ARE rolling!
377                         */
378                         passthru_silence (start_frame, end_frame, nframes, 0);
379                         return 0;
380                 }
381                 /* we're really not rolling, so we're either delivery silence or actually
382                    monitoring, both of which are safe to do while session_state_changing is true.
383                 */
384         }
385
386         _diskstream->check_record_status (start_frame, can_record);
387
388         bool be_silent;
389
390         if (_have_internal_generator) {
391                 /* since the instrument has no input streams,
392                    there is no reason to send any signal
393                    into the route.
394                 */
395                 be_silent = true;
396         } else {
397                 MonitorState const s = monitoring_state ();
398                 /* we are not rolling, so be silent even if we are monitoring disk, as there
399                    will be no disk data coming in.
400                 */
401                 be_silent = (s == MonitoringSilence || s == MonitoringDisk);
402         }
403
404         if (!_have_internal_generator && metering_state() == MeteringInput) {
405                 _input->process_input (_meter, start_frame, end_frame, nframes);
406         }
407
408         _amp->apply_gain_automation(false);
409
410         /* if have_internal_generator, or .. */
411         //_input->process_input (_meter, start_frame, end_frame, nframes);
412
413         if (be_silent) {
414
415                 passthru_silence (start_frame, end_frame, nframes, 0);
416
417         } else {
418
419                 /* we're sending signal, but we may still want to meter the input.
420                  */
421
422                 passthru (start_frame, end_frame, nframes, false);
423         }
424
425         for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
426                 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
427                 if (d) {
428                         d->flush_buffers (nframes);
429                 }
430         }
431
432         return 0;
433 }
434
435 int
436 Track::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& need_butler)
437 {
438         Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
439         if (!lm.locked()) {
440                 return 0;
441         }
442
443         if (n_outputs().n_total() == 0 && _processors.empty()) {
444                 return 0;
445         }
446
447         if (!_active) {
448                 silence (nframes);
449                 return 0;
450         }
451
452         _silent = true;
453         _amp->apply_gain_automation(false);
454
455         silence (nframes);
456
457         framecnt_t playback_distance;
458         int const dret = _diskstream->process (_session.transport_frame(), nframes, playback_distance);
459         need_butler = _diskstream->commit (playback_distance);
460         return dret;
461 }
462
463 void
464 Track::set_diskstream (boost::shared_ptr<Diskstream> ds)
465 {
466         _diskstream = ds;
467
468         ds->PlaylistChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_playlist_changed, this));
469         diskstream_playlist_changed ();
470         ds->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_record_enable_changed, this));
471         ds->SpeedChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_speed_changed, this));
472         ds->AlignmentStyleChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_alignment_style_changed, this));
473 }
474
475 void
476 Track::diskstream_playlist_changed ()
477 {
478         PlaylistChanged (); /* EMIT SIGNAL */
479 }
480
481 void
482 Track::diskstream_record_enable_changed ()
483 {
484         RecordEnableChanged (); /* EMIT SIGNAL */
485 }
486
487 void
488 Track::diskstream_speed_changed ()
489 {
490         SpeedChanged (); /* EMIT SIGNAL */
491 }
492
493 void
494 Track::diskstream_alignment_style_changed ()
495 {
496         AlignmentStyleChanged (); /* EMIT SIGNAL */
497 }
498
499 boost::shared_ptr<Playlist>
500 Track::playlist ()
501 {
502         return _diskstream->playlist ();
503 }
504
505 void
506 Track::request_jack_monitors_input (bool m)
507 {
508         _diskstream->request_jack_monitors_input (m);
509 }
510
511 void
512 Track::ensure_jack_monitors_input (bool m)
513 {
514         _diskstream->ensure_jack_monitors_input (m);
515 }
516
517 bool
518 Track::destructive () const
519 {
520         return _diskstream->destructive ();
521 }
522
523 list<boost::shared_ptr<Source> > &
524 Track::last_capture_sources ()
525 {
526         return _diskstream->last_capture_sources ();
527 }
528
529 void
530 Track::set_capture_offset ()
531 {
532         _diskstream->set_capture_offset ();
533 }
534
535 list<boost::shared_ptr<Source> >
536 Track::steal_write_sources()
537 {
538         return _diskstream->steal_write_sources ();
539 }
540
541 void
542 Track::reset_write_sources (bool r, bool force)
543 {
544         _diskstream->reset_write_sources (r, force);
545 }
546
547 float
548 Track::playback_buffer_load () const
549 {
550         return _diskstream->playback_buffer_load ();
551 }
552
553 float
554 Track::capture_buffer_load () const
555 {
556         return _diskstream->capture_buffer_load ();
557 }
558
559 int
560 Track::do_refill ()
561 {
562         return _diskstream->do_refill ();
563 }
564
565 int
566 Track::do_flush (RunContext c, bool force)
567 {
568         return _diskstream->do_flush (c, force);
569 }
570
571 void
572 Track::set_pending_overwrite (bool o)
573 {
574         _diskstream->set_pending_overwrite (o);
575 }
576
577 int
578 Track::seek (framepos_t p, bool complete_refill)
579 {
580         return _diskstream->seek (p, complete_refill);
581 }
582
583 bool
584 Track::hidden () const
585 {
586         return _diskstream->hidden ();
587 }
588
589 int
590 Track::can_internal_playback_seek (framecnt_t p)
591 {
592         return _diskstream->can_internal_playback_seek (p);
593 }
594
595 int
596 Track::internal_playback_seek (framecnt_t p)
597 {
598         return _diskstream->internal_playback_seek (p);
599 }
600
601 void
602 Track::non_realtime_input_change ()
603 {
604         _diskstream->non_realtime_input_change ();
605 }
606
607 void
608 Track::non_realtime_locate (framepos_t p)
609 {
610         _diskstream->non_realtime_locate (p);
611 }
612
613 void
614 Track::non_realtime_set_speed ()
615 {
616         _diskstream->non_realtime_set_speed ();
617 }
618
619 int
620 Track::overwrite_existing_buffers ()
621 {
622         return _diskstream->overwrite_existing_buffers ();
623 }
624
625 framecnt_t
626 Track::get_captured_frames (uint32_t n) const
627 {
628         return _diskstream->get_captured_frames (n);
629 }
630
631 int
632 Track::set_loop (Location* l)
633 {
634         return _diskstream->set_loop (l);
635 }
636
637 void
638 Track::transport_looped (framepos_t p)
639 {
640         _diskstream->transport_looped (p);
641 }
642
643 bool
644 Track::realtime_set_speed (double s, bool g)
645 {
646         return _diskstream->realtime_set_speed (s, g);
647 }
648
649 void
650 Track::transport_stopped_wallclock (struct tm & n, time_t t, bool g)
651 {
652         _diskstream->transport_stopped_wallclock (n, t, g);
653 }
654
655 bool
656 Track::pending_overwrite () const
657 {
658         return _diskstream->pending_overwrite ();
659 }
660
661 double
662 Track::speed () const
663 {
664         return _diskstream->speed ();
665 }
666
667 void
668 Track::prepare_to_stop (framepos_t p)
669 {
670         _diskstream->prepare_to_stop (p);
671 }
672
673 void
674 Track::set_slaved (bool s)
675 {
676         _diskstream->set_slaved (s);
677 }
678
679 ChanCount
680 Track::n_channels ()
681 {
682         return _diskstream->n_channels ();
683 }
684
685 framepos_t
686 Track::get_capture_start_frame (uint32_t n) const
687 {
688         return _diskstream->get_capture_start_frame (n);
689 }
690
691 AlignStyle
692 Track::alignment_style () const
693 {
694         return _diskstream->alignment_style ();
695 }
696
697 AlignChoice
698 Track::alignment_choice () const
699 {
700         return _diskstream->alignment_choice ();
701 }
702
703 framepos_t
704 Track::current_capture_start () const
705 {
706         return _diskstream->current_capture_start ();
707 }
708
709 framepos_t
710 Track::current_capture_end () const
711 {
712         return _diskstream->current_capture_end ();
713 }
714
715 void
716 Track::playlist_modified ()
717 {
718         _diskstream->playlist_modified ();
719 }
720
721 int
722 Track::use_playlist (boost::shared_ptr<Playlist> p)
723 {
724         int ret = _diskstream->use_playlist (p);
725         if (ret == 0) {
726                 p->set_orig_track_id (id());
727         }
728         return ret;
729 }
730
731 int
732 Track::use_copy_playlist ()
733 {
734         int ret =  _diskstream->use_copy_playlist ();
735
736         if (ret == 0) {
737                 _diskstream->playlist()->set_orig_track_id (id());
738         }
739
740         return ret;
741 }
742
743 int
744 Track::use_new_playlist ()
745 {
746         int ret = _diskstream->use_new_playlist ();
747
748         if (ret == 0) {
749                 _diskstream->playlist()->set_orig_track_id (id());
750         }
751
752         return ret;
753 }
754
755 void
756 Track::set_align_style (AlignStyle s, bool force)
757 {
758         _diskstream->set_align_style (s, force);
759 }
760
761 void
762 Track::set_align_choice (AlignChoice s, bool force)
763 {
764         _diskstream->set_align_choice (s, force);
765 }
766
767 bool
768 Track::using_diskstream_id (PBD::ID id) const
769 {
770         return (id == _diskstream->id ());
771 }
772
773 void
774 Track::set_block_size (pframes_t n)
775 {
776         Route::set_block_size (n);
777         _diskstream->set_block_size (n);
778 }
779
780 void
781 Track::adjust_playback_buffering ()
782 {
783         if (_diskstream) {
784                 _diskstream->adjust_playback_buffering ();
785         }
786 }
787
788 void
789 Track::adjust_capture_buffering ()
790 {
791         if (_diskstream) {
792                 _diskstream->adjust_capture_buffering ();
793         }
794 }
795
796 MonitorState
797 Track::monitoring_state () const
798 {
799         /* Explicit requests */
800         
801         if (_monitoring & MonitorInput) {
802                 return MonitoringInput;
803         }
804                 
805         if (_monitoring & MonitorDisk) {
806                 return MonitoringDisk;
807         }
808
809         /* This is an implementation of the truth table in doc/monitor_modes.pdf;
810            I don't think it's ever going to be too pretty too look at.
811         */
812
813         bool const roll = _session.transport_rolling ();
814         bool const track_rec = _diskstream->record_enabled ();
815         bool const session_rec = _session.get_record_enabled ();
816         bool const auto_input = _session.config.get_auto_input ();
817         bool const software_monitor = Config->get_monitoring_model() == SoftwareMonitoring;
818         bool const tape_machine_mode = Config->get_tape_machine_mode ();
819
820         if (track_rec) {
821
822                 if (!session_rec && roll && auto_input) {
823                         return MonitoringDisk;
824                 } else {
825                         return software_monitor ? MonitoringInput : MonitoringSilence;
826                 }
827
828         } else {
829
830                 if (tape_machine_mode) {
831
832                         return MonitoringDisk;
833
834                 } else {
835
836                         if (!roll && auto_input) {
837                                 return software_monitor ? MonitoringInput : MonitoringSilence;
838                         } else {
839                                 return MonitoringDisk;
840                         }
841                         
842                 }
843         }
844
845         /* NOTREACHED */
846         return MonitoringSilence;
847 }
848
849 void
850 Track::maybe_declick (BufferSet& bufs, framecnt_t nframes, int declick)
851 {
852         /* never declick if there is an internal generator - we just want it to
853            keep generating sound without interruption.
854
855            ditto if we are monitoring inputs.
856         */
857
858         if (_have_internal_generator || monitoring_choice() == MonitorInput) {
859                 return;
860         }
861
862         if (!declick) {
863                 declick = _pending_declick;
864         }
865
866         if (declick != 0) {
867                 Amp::declick (bufs, nframes, declick);
868         }
869 }
870
871 framecnt_t
872 Track::check_initial_delay (framecnt_t nframes, framepos_t& transport_frame)
873 {
874         if (_roll_delay > nframes) {
875
876                 _roll_delay -= nframes;
877                 silence_unlocked (nframes);
878                 /* transport frame is not legal for caller to use */
879                 return 0;
880
881         } else if (_roll_delay > 0) {
882
883                 nframes -= _roll_delay;
884                 silence_unlocked (_roll_delay);
885                 transport_frame += _roll_delay;
886
887                 /* shuffle all the port buffers for things that lead "out" of this Route
888                    to reflect that we just wrote _roll_delay frames of silence.
889                 */
890
891                 Glib::RWLock::ReaderLock lm (_processor_lock);
892                 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
893                         boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
894                         if (iop) {
895                                 iop->increment_port_buffer_offset (_roll_delay);
896                         }
897                 }
898                 _output->increment_port_buffer_offset (_roll_delay);
899
900                 _roll_delay = 0;
901
902         }
903
904         return nframes; 
905 }
906
907 void
908 Track::set_monitoring (MonitorChoice mc)
909 {
910         if (mc !=  _monitoring) {
911                 _monitoring = mc;
912
913                 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
914                         (*i)->monitoring_changed ();
915                 }
916
917                 MonitoringChanged (); /* EMIT SIGNAL */
918         }
919 }
920
921 void
922 Track::parameter_changed (string p)
923 {
924         if (p != "do-not-record-plugins") {
925                 return;
926         }
927
928         if (record_enabled ()) {
929                 if (Config->get_do_not_record_plugins ()) {
930                         deactivate_visible_processors ();
931                 } else {
932                         activate_deactivated_processors ();
933                 }
934         }
935 }
936         
937 MeterState
938 Track::metering_state () const
939 {
940         return _diskstream->record_enabled() ? MeteringInput : MeteringRoute;
941 }