diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h index 2e838ff628..2614b8061c 100644 --- a/libs/ardour/ardour/audio_diskstream.h +++ b/libs/ardour/ardour/audio_diskstream.h @@ -108,6 +108,7 @@ class LIBARDOUR_API AudioDiskstream : public Diskstream int remove_channel (uint32_t how_many); bool set_name (std::string const &); + bool set_write_source_name (const std::string& str); /* stateful */ diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index dd74d5cb52..055a298d84 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -70,6 +70,15 @@ class LIBARDOUR_API Diskstream : public SessionObject, public PublicDiskstream virtual ~Diskstream(); virtual bool set_name (const std::string& str); + virtual bool set_write_source_name (const std::string& str); + + std::string write_source_name () const { + if (_write_source_name.empty()) { + return name(); + } else { + return _write_source_name; + } + } virtual std::string steal_write_source_name () { return std::string(); } @@ -312,6 +321,8 @@ class LIBARDOUR_API Diskstream : public SessionObject, public PublicDiskstream bool in_set_state; + std::string _write_source_name; + Glib::Threads::Mutex state_lock; PBD::ScopedConnectionList playlist_connections; diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index 50ad7419e6..91fb891f17 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -76,6 +76,7 @@ class LIBARDOUR_API MidiDiskstream : public Diskstream int use_copy_playlist (); bool set_name (std::string const &); + bool set_write_source_name (const std::string& str); /* stateful */ XMLNode& get_state(void); diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 095bbf075a..0d2c664e48 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -1908,7 +1908,7 @@ AudioDiskstream::use_new_write_source (uint32_t n) try { if ((chan->write_source = _session.create_audio_source_for_session ( - n_channels().n_audio(), name(), n, destructive())) == 0) { + n_channels().n_audio(), write_source_name(), n, destructive())) == 0) { throw failed_constructor(); } } @@ -2451,6 +2451,9 @@ AudioDiskstream::ChannelInfo::~ChannelInfo () bool AudioDiskstream::set_name (string const & name) { + if (_name == name) { + return true; + } Diskstream::set_name (name); /* get a new write source so that its name reflects the new diskstream name */ @@ -2465,3 +2468,24 @@ AudioDiskstream::set_name (string const & name) return true; } + +bool +AudioDiskstream::set_write_source_name (const std::string& str) { + if (_write_source_name == str) { + return true; + } + + Diskstream::set_write_source_name (str); + + if (_write_source_name == name()) { + return true; + } + boost::shared_ptr c = channels.reader(); + ChannelList::iterator i; + int n = 0; + + for (n = 0, i = c->begin(); i != c->end(); ++i, ++n) { + use_new_write_source (n); + } + return true; +} diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 87a71b8dbe..aacb0ce1c9 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -437,7 +437,13 @@ Diskstream::set_name (const string& str) playlist()->set_name (str); SessionObject::set_name(str); } - return true; + return true; +} + +bool +Diskstream::set_write_source_name (const std::string& str) { + _write_source_name = str; + return true; } XMLNode& diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 1cc69263f0..a104d98f26 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -1223,7 +1223,7 @@ MidiDiskstream::use_new_write_source (uint32_t n) try { _write_source = boost::dynamic_pointer_cast( - _session.create_midi_source_for_session (name ())); + _session.create_midi_source_for_session (write_source_name ())); if (!_write_source) { throw failed_constructor(); @@ -1441,6 +1441,9 @@ MidiDiskstream::get_playback (MidiBuffer& dst, framecnt_t nframes) bool MidiDiskstream::set_name (string const & name) { + if (_name == name) { + return true; + } Diskstream::set_name (name); /* get a new write source so that its name reflects the new diskstream name */ @@ -1449,6 +1452,19 @@ MidiDiskstream::set_name (string const & name) return true; } +bool +MidiDiskstream::set_write_source_name (const std::string& str) { + if (_write_source_name == str) { + return true; + } + Diskstream::set_write_source_name (str); + if (_write_source_name == name()) { + return true; + } + use_new_write_source (0); + return true; +} + boost::shared_ptr MidiDiskstream::get_gui_feed_buffer () const { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 8b1a183de5..b7a8d3cf48 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3562,14 +3562,14 @@ Route::save_as_template (const string& path, const string& name) bool Route::set_name (const string& str) { - bool ret; - string ioproc_name; - string name; + if (str == name()) { + return true; + } - name = Route::ensure_track_or_route_name (str, _session); + string name = Route::ensure_track_or_route_name (str, _session); SessionObject::set_name (name); - ret = (_input->set_name(name) && _output->set_name(name)); + bool ret = (_input->set_name(name) && _output->set_name(name)); if (ret) { /* rename the main outs. Leave other IO processors