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