Return silence from read_from_sources() if we try to read a channel that our source...
[ardour.git] / libs / ardour / track.cc
index f7f0e6fdbeb80cd5f0ef5b530f4cdab0447400e4..0ad59d1b31b93db50340e3a095044a5a9def0cea 100644 (file)
 #include "pbd/error.h"
 
 #include "ardour/amp.h"
-#include "ardour/audioplaylist.h"
-#include "ardour/audioregion.h"
-#include "ardour/audiosource.h"
 #include "ardour/debug.h"
 #include "ardour/delivery.h"
 #include "ardour/diskstream.h"
 #include "ardour/io_processor.h"
 #include "ardour/meter.h"
+#include "ardour/playlist.h"
 #include "ardour/port.h"
 #include "ardour/processor.h"
 #include "ardour/route_group_specialized.h"
@@ -214,13 +212,23 @@ Track::RecEnableControl::RecEnableControl (boost::shared_ptr<Track> t)
 void
 Track::RecEnableControl::set_value (double val)
 {
-       track->set_record_enabled (val >= 0.5 ? true : false, this);
+       boost::shared_ptr<Track> t = track.lock ();
+       if (!t) {
+               return;
+       }
+       
+       t->set_record_enabled (val >= 0.5 ? true : false, this);
 }
 
 double
-Track::RecEnableControl::get_value (void) const
+Track::RecEnableControl::get_value () const
 {
-       return (track->record_enabled() ? 1.0 : 0.0);
+       boost::shared_ptr<Track> t = track.lock ();
+       if (!t) {
+               return 0;
+       }
+       
+       return (t->record_enabled() ? 1.0 : 0.0);
 }
 
 bool
@@ -321,7 +329,15 @@ Track::set_name (const string& str)
                return false;
        }
 
-       _diskstream->set_name (str);
+       if (_diskstream->playlist()->all_regions_empty ()) {
+               /* Only rename the diskstream (and therefore the playlist) if
+                  the playlist has never had a region added to it.  Otherwise
+                  people can get confused if, say, they have notes about a
+                  playlist with a given name and then it changes (see mantis
+                  #4759).
+               */
+               _diskstream->set_name (str);
+       }
 
        /* save state so that the statefile fully reflects any filename changes */
 
@@ -577,13 +593,13 @@ Track::hidden () const
 }
 
 int
-Track::can_internal_playback_seek (framepos_t p)
+Track::can_internal_playback_seek (framecnt_t p)
 {
        return _diskstream->can_internal_playback_seek (p);
 }
 
 int
-Track::internal_playback_seek (framepos_t p)
+Track::internal_playback_seek (framecnt_t p)
 {
        return _diskstream->internal_playback_seek (p);
 }
@@ -859,7 +875,7 @@ Track::maybe_declick (BufferSet& bufs, framecnt_t nframes, int declick)
 }
 
 framecnt_t
-Track::check_initial_delay (framecnt_t nframes, framecnt_t& transport_frame)
+Track::check_initial_delay (framecnt_t nframes, framepos_t& transport_frame)
 {
        if (_roll_delay > nframes) {