+ string diskstream_name = "";
+ if (_session.config.get_track_name_take () && !_session.config.get_take_name ().empty()) {
+ // Note: any text is fine, legalize_for_path() fixes this later
+ diskstream_name += _session.config.get_take_name ();
+ diskstream_name += "_";
+ }
+ const int64_t tracknumber = track_number();
+ if (tracknumber > 0 && _session.config.get_track_name_number()) {
+ char num[64], fmt[10];
+ snprintf(fmt, sizeof(fmt), "%%0%d" PRId64, _session.track_number_decimals());
+ snprintf(num, sizeof(num), fmt, tracknumber);
+ diskstream_name += num;
+ diskstream_name += "_";
+ }
+ diskstream_name += str;
+
+ if (diskstream_name == _diskstream_name) {
+ return true;
+ }
+ _diskstream_name = diskstream_name;
+
+ _diskstream->set_write_source_name (diskstream_name);
+
+ boost::shared_ptr<Track> me = boost::dynamic_pointer_cast<Track> (shared_from_this ());
+ if (_diskstream->playlist()->all_regions_empty () && _session.playlists->playlists_for_track (me).size() == 1) {
+ /* Only rename the diskstream (and therefore the playlist) if
+ a) the playlist has never had a region added to it and
+ b) there is only one playlist for this track.
+
+ If (a) is not followed, people can get confused if, say,
+ they have notes about a playlist with a given name and then
+ it changes (see mantis #4759).
+
+ If (b) is not followed, we rename the current playlist and not
+ the other ones, which is a bit confusing (see mantis #4977).
+ */
+ _diskstream->set_name (str);
+ }