From d23a6de077181caa24af52229bb040c87ed34ebd Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 10 Dec 2011 19:20:15 +0000 Subject: fix for most (all? we can dream ...) issues involved in #4399 (editing multiply-applies operations to playlists used more than once), and as a side-issue, fix playlist selection which broke when we hid Diskstreams inside Tracks by using orig_track_id() rather than orig_diskstream_id() git-svn-id: svn://localhost/ardour2/branches/3.0@10968 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/playlist.h | 7 +++---- libs/ardour/ardour/session.h | 1 + libs/ardour/ardour/track.h | 3 +-- libs/ardour/audio_diskstream.cc | 2 -- libs/ardour/audio_track.cc | 2 +- libs/ardour/diskstream.cc | 12 ++---------- libs/ardour/midi_diskstream.cc | 2 -- libs/ardour/playlist.cc | 13 ++++++++----- libs/ardour/session.cc | 15 +++++++++++++++ libs/ardour/session_playlists.cc | 6 +++--- libs/ardour/track.cc | 24 +++++++++++++++++++----- 11 files changed, 53 insertions(+), 34 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 9e15b9cf5d..529ec25d14 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -201,9 +201,8 @@ public: void raise_region_to_top (boost::shared_ptr); void lower_region_to_bottom (boost::shared_ptr); - /* XXX: use of diskstream here is a little unfortunate */ - const PBD::ID& get_orig_diskstream_id () const { return _orig_diskstream_id; } - void set_orig_diskstream_id (const PBD::ID& did) { _orig_diskstream_id = did; } + const PBD::ID& get_orig_track_id () const { return _orig_track_id; } + void set_orig_track_id (const PBD::ID& did) { _orig_track_id = did; } /* destructive editing */ @@ -290,7 +289,7 @@ public: bool in_partition; bool _frozen; uint32_t subcnt; - PBD::ID _orig_diskstream_id; + PBD::ID _orig_track_id; uint64_t layer_op_counter; framecnt_t freeze_length; bool auto_partition; diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 3c1c9b564b..19935c5440 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -243,6 +243,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi boost::shared_ptr route_by_name (std::string); boost::shared_ptr route_by_id (PBD::ID); boost::shared_ptr route_by_remote_id (uint32_t id); + boost::shared_ptr track_by_diskstream_id (PBD::ID); void routes_using_input_from (const std::string& str, RouteList& rl); bool route_name_unique (std::string) const; diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 79e968c8ed..496b1e195b 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -98,8 +98,7 @@ class Track : public Route, public PublicDiskstream bool record_enabled() const; void set_record_enabled (bool yn, void *src); - /* XXX: unfortunate that this is exposed */ - PBD::ID const & diskstream_id () const; + bool using_diskstream_id (PBD::ID) const; void set_block_size (pframes_t); diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 51a3b72bf6..2ab7d9ec65 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -281,7 +281,6 @@ AudioDiskstream::use_new_playlist () if ((playlist = boost::dynamic_pointer_cast (PlaylistFactory::create (DataType::AUDIO, _session, newname, hidden()))) != 0) { - playlist->set_orig_diskstream_id (id()); return use_playlist (playlist); } else { @@ -309,7 +308,6 @@ AudioDiskstream::use_copy_playlist () newname = Playlist::bump_name (_playlist->name(), _session); if ((playlist = boost::dynamic_pointer_cast(PlaylistFactory::create (audio_playlist(), newname))) != 0) { - playlist->set_orig_diskstream_id (id()); return use_playlist (playlist); } else { return -1; diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index c15fcd9e9c..a8f43c4758 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -643,7 +643,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt) boost::shared_ptr region (RegionFactory::create (srcs, plist, false)); - new_playlist->set_orig_diskstream_id (_diskstream->id()); + new_playlist->set_orig_track_id (id()); new_playlist->add_region (region, _session.current_start_frame()); new_playlist->set_frozen (true); region->set_locked (true); diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index d5ecd3713b..1cf4048c69 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -504,16 +504,8 @@ Diskstream::set_state (const XMLNode& node, int /*version*/) return -1; } - { - bool had_playlist = (_playlist != 0); - - if (find_and_use_playlist (prop->value())) { - return -1; - } - - if (!had_playlist) { - _playlist->set_orig_diskstream_id (id()); - } + if (find_and_use_playlist (prop->value())) { + return -1; } if ((prop = node.property ("speed")) != 0) { diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 4f7778e09e..64fcf60925 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -252,7 +252,6 @@ MidiDiskstream::use_new_playlist () if ((playlist = boost::dynamic_pointer_cast (PlaylistFactory::create ( DataType::MIDI, _session, newname, hidden()))) != 0) { - playlist->set_orig_diskstream_id (id()); return use_playlist (playlist); } else { @@ -280,7 +279,6 @@ MidiDiskstream::use_copy_playlist () newname = Playlist::bump_name (_playlist->name(), _session); if ((playlist = boost::dynamic_pointer_cast(PlaylistFactory::create (midi_playlist(), newname))) != 0) { - playlist->set_orig_diskstream_id (id()); return use_playlist (playlist); } else { return -1; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 3bc5f57577..4aae95ea76 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -161,7 +161,7 @@ Playlist::Playlist (boost::shared_ptr other, string namestr, boo : SessionObject(other->_session, namestr) , regions (*this) , _type(other->_type) - , _orig_diskstream_id (other->_orig_diskstream_id) + , _orig_track_id (other->_orig_track_id) { init (hide); @@ -195,7 +195,7 @@ Playlist::Playlist (boost::shared_ptr other, framepos_t start, f : SessionObject(other->_session, str) , regions (*this) , _type(other->_type) - , _orig_diskstream_id (other->_orig_diskstream_id) + , _orig_track_id (other->_orig_track_id) { RegionLock rlock2 (const_cast (other.get())); @@ -2221,7 +2221,10 @@ Playlist::flush_notifications (bool from_undo) _name = prop->value(); _set_sort_id (); } else if (prop->name() == X_("orig-diskstream-id")) { - _orig_diskstream_id = prop->value (); + /* XXX legacy session: fix up later */ + _orig_track_id = prop->value (); + } else if (prop->name() == X_("orig-track-id")) { + _orig_track_id = prop->value (); } else if (prop->name() == X_("frozen")) { _frozen = string_is_affirmative (prop->value()); } else if (prop->name() == X_("combine-ops")) { @@ -2318,8 +2321,8 @@ Playlist::state (bool full_state) node->add_property (X_("name"), _name); node->add_property (X_("type"), _type.to_string()); - _orig_diskstream_id.print (buf, sizeof (buf)); - node->add_property (X_("orig-diskstream-id"), buf); + _orig_track_id.print (buf, sizeof (buf)); + node->add_property (X_("orig-track-id"), buf); node->add_property (X_("frozen"), _frozen ? "yes" : "no"); if (full_state) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4f5e8093bb..f2e224fee5 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2603,6 +2603,21 @@ Session::route_by_id (PBD::ID id) return boost::shared_ptr ((Route*) 0); } +boost::shared_ptr +Session::track_by_diskstream_id (PBD::ID id) +{ + boost::shared_ptr r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + boost::shared_ptr t = boost::dynamic_pointer_cast (*i); + if (t && t->using_diskstream_id (id)) { + return t; + } + } + + return boost::shared_ptr (); +} + boost::shared_ptr Session::route_by_remote_id (uint32_t id) { diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index 1e31801271..8e25cbfd9d 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -207,13 +207,13 @@ SessionPlaylists::unassigned (std::list > & list) Glib::Mutex::Lock lm (lock); for (List::iterator i = playlists.begin(); i != playlists.end(); ++i) { - if (!(*i)->get_orig_diskstream_id().to_s().compare ("0")) { + if (!(*i)->get_orig_track_id().to_s().compare ("0")) { list.push_back (*i); } } for (List::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ++i) { - if (!(*i)->get_orig_diskstream_id().to_s().compare ("0")) { + if (!(*i)->get_orig_track_id().to_s().compare ("0")) { list.push_back (*i); } } @@ -462,7 +462,7 @@ SessionPlaylists::playlists_for_track (boost::shared_ptr tr) const vector > pl_tr; for (vector >::iterator i = pl.begin(); i != pl.end(); ++i) { - if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) { + if (((*i)->get_orig_track_id() == tr->id()) || (tr->playlist()->id() == (*i)->id())) { pl_tr.push_back (*i); } } diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 9d6b82e4c0..8a4931d336 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -115,6 +115,8 @@ Track::set_state (const XMLNode& node, int version) } } + _diskstream->playlist()->set_orig_track_id (id()); + /* set rec-enable control *AFTER* setting up diskstream, because it may want to operate on the diskstream as it sets its own state */ @@ -694,13 +696,25 @@ Track::use_playlist (boost::shared_ptr p) int Track::use_copy_playlist () { - return _diskstream->use_copy_playlist (); + int ret = _diskstream->use_copy_playlist (); + + if (ret == 0) { + _diskstream->playlist()->set_orig_track_id (id()); + } + + return ret; } int Track::use_new_playlist () { - return _diskstream->use_new_playlist (); + int ret = _diskstream->use_new_playlist (); + + if (ret == 0) { + _diskstream->playlist()->set_orig_track_id (id()); + } + + return ret; } void @@ -715,10 +729,10 @@ Track::set_align_choice (AlignChoice s, bool force) _diskstream->set_align_choice (s, force); } -PBD::ID const & -Track::diskstream_id () const +bool +Track::using_diskstream_id (PBD::ID id) const { - return _diskstream->id (); + return (id == _diskstream->id ()); } void -- cgit v1.2.3