slightly improved fixes for MIDI issues
[ardour.git] / libs / ardour / playlist.cc
index eb36988d0efe7613f75a9dc79fffec30114ff6de..4af7e2b907febb489496a3199acaf9e9e8cf3c81 100644 (file)
@@ -71,7 +71,7 @@ struct RegionSortByLastLayerOp {
 };
 
 Playlist::Playlist (Session& sess, string nom, DataType type, bool hide)
-       : _session (sess)
+       : SessionObject(sess, nom)
        , _type(type)
 {
        init (hide);
@@ -81,7 +81,7 @@ Playlist::Playlist (Session& sess, string nom, DataType type, bool hide)
 }
 
 Playlist::Playlist (Session& sess, const XMLNode& node, DataType type, bool hide)
-       : _session (sess)
+       : SessionObject(sess, "unnamed playlist")
        , _type(type)
 {
        const XMLProperty* prop = node.property("type");
@@ -94,7 +94,7 @@ Playlist::Playlist (Session& sess, const XMLNode& node, DataType type, bool hide
 }
 
 Playlist::Playlist (boost::shared_ptr<const Playlist> other, string namestr, bool hide)
-       : _name (namestr), _session (other->_session), _type(other->_type), _orig_diskstream_id(other->_orig_diskstream_id)
+       : SessionObject(other->_session, namestr), _type(other->_type), _orig_diskstream_id(other->_orig_diskstream_id)
 {
        init (hide);
 
@@ -126,7 +126,7 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, string namestr, boo
 }
 
 Playlist::Playlist (boost::shared_ptr<const Playlist> other, nframes_t start, nframes_t cnt, string str, bool hide)
-       : _name (str), _session (other->_session), _type(other->_type), _orig_diskstream_id(other->_orig_diskstream_id)
+       : SessionObject(other->_session, str), _type(other->_type), _orig_diskstream_id(other->_orig_diskstream_id)
 {
        RegionLock rlock2 (const_cast<Playlist*> (other.get()));
 
@@ -217,9 +217,7 @@ Playlist::copy_regions (RegionList& newlist) const
        RegionLock rlock (const_cast<Playlist *> (this));
 
        for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
-               if (!(*i)->is_dependent()) {
-                       newlist.push_back (RegionFactory::RegionFactory::create (*i));
-               }
+               newlist.push_back (RegionFactory::RegionFactory::create (*i));
        }
 }
 
@@ -249,14 +247,14 @@ Playlist::init (bool hide)
 }
 
 Playlist::Playlist (const Playlist& pl)
-       : _session (pl._session)
+       : SessionObject(pl._session, pl._name)
        , _type(pl.data_type())
 {
        fatal << _("playlist const copy constructor called") << endmsg;
 }
 
 Playlist::Playlist (Playlist& pl)
-       : _session (pl._session)
+       : SessionObject(pl._session, pl._name)
        , _type(pl.data_type())
 {
        fatal << _("playlist non-const copy constructor called") << endmsg;
@@ -275,8 +273,8 @@ Playlist::~Playlist ()
        /* GoingAway must be emitted by derived classes */
 }
 
-void
-Playlist::set_name (string str)
+bool
+Playlist::set_name (const string& str)
 {
        /* in a typical situation, a playlist is being used
           by one diskstream and also is referenced by the
@@ -285,11 +283,10 @@ Playlist::set_name (string str)
        */
 
        if (_refcnt > 2) {
-               return;
+               return false;
+       } else {
+               return SessionObject::set_name(str);
        }
-
-       _name = str; 
-       NameChanged(); /* EMIT SIGNAL */
 }
 
 /***********************************************************************
@@ -1387,7 +1384,7 @@ Playlist::set_state (const XMLNode& node)
 
                child = *niter;
                
-               if (child->name() == Region::node_name()) {
+               if (child->name() == "Region") {
 
                        if ((prop = child->property ("id")) == 0) {
                                error << _("region state node has no ID, ignored") << endmsg;
@@ -1613,11 +1610,6 @@ Playlist::relayer ()
        
        for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) {
 
-               if ((*i)->is_dependent()) {
-                       /* handle dependent regions in a later pass */
-                       continue;
-               }
-
                /* find the lowest layer that this region can go on */
                size_t j = layers.size();
                while (j > 0) {
@@ -1655,50 +1647,6 @@ Playlist::relayer ()
                }
        }
 
-       /* second pass: set up layer numbers for all dependent regions */
-
-       for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) {
-               
-               cerr << "pass 2, looking at " << (*i)->name() << " dep? " << (*i)->is_dependent() << endl;
-
-               if ((*i)->is_dependent()) {
-                       
-                       size_t one_higher = (*i)->upper_layer() + 1;
-
-                       cerr << "Setting xfade to " << one_higher << endl;
-
-                       (*i)->set_layer (one_higher);
-
-                       if (one_higher < layers.size()) {
-
-                               /* find the layer list representing the next higher layer */
-                               
-                               vector<RegionList>::iterator x = layers.begin();
-                               for (size_t n = 0; n < one_higher; ++n) {
-                                       ++x;
-                               }
-                               
-                               /* add a new layer list containing just the dependent region
-                                  we set the layer for
-                               */
-
-                               layers.insert (x, RegionList());
-                               layers[one_higher].push_back (*i);
-
-                               /* move everything on higher layers one layer higher */
-
-                               for (size_t j = one_higher; j < layers.size(); ++j) {
-                                       for (RegionList::iterator i = layers[j].begin(); i != layers[j].end(); ++i) {
-                                               cerr << "Bumping " << (*i)->name() << " to " << j << endl;
-                                               (*i)->set_layer (j);
-                                       }
-                               }
-                       }
-
-                       
-               }
-       }
-
        /* sending Modified means that various kinds of layering
           models operate correctly at the GUI
           level. slightly inefficient, but only slightly.