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