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