ensure that imported regions have names based on the files they are based on
[ardour.git] / libs / ardour / audio_playlist.cc
index eb4913e72778ab2f4e05991d93b0bc7b3ebf6642..6e8b35a07238e8661058cef8f5453f42ab9fa85d 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <cstdlib>
 
-#include <sigc++/bind.h>
 
 #include "ardour/types.h"
 #include "ardour/configuration.h"
@@ -35,7 +34,6 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
-using namespace sigc;
 using namespace std;
 using namespace PBD;
 
@@ -104,12 +102,6 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr<const AudioPlaylist> other, nfra
 
 AudioPlaylist::~AudioPlaylist ()
 {
-       GoingAway (); /* EMIT SIGNAL */
-
-       /* drop connections to signals */
-
-       notify_callbacks ();
-
        _crossfades.clear ();
 }
 
@@ -351,7 +343,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
        boost::shared_ptr<AudioRegion> top;
        boost::shared_ptr<AudioRegion> bottom;
        boost::shared_ptr<Crossfade>   xfade;
-       RegionList*  touched_regions;
+       RegionList*  touched_regions = 0;
 
        if (in_set_state || in_partition) {
                return;
@@ -401,6 +393,9 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
 
                OverlapType c = top->coverage (bottom->position(), bottom->last_frame());
 
+               delete touched_regions;
+               touched_regions = 0;
+
                try {
                        switch (c) {
                        case OverlapNone:
@@ -425,7 +420,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                                   audio engineering.
                                */
 
-                               xfade_length = min ((nframes_t) 720, top->length());
+                               xfade_length = min ((framecnt_t) 720, top->length());
 
                                if (top_region_at (top->first_frame()) == top) {
 
@@ -459,7 +454,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                                } else {
 
                                        touched_regions = regions_touched (top->first_frame(),
-                                                                          top->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
+                                                                          top->first_frame() + min ((framecnt_t) _session.config.get_short_xfade_seconds() * _session.frame_rate(),
                                                                                                     top->length()));
                                        if (touched_regions->size() <= 2) {
                                                xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active()));
@@ -485,7 +480,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
 
                                } else {
                                        touched_regions = regions_touched (bottom->first_frame(),
-                                                                          bottom->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
+                                                                          bottom->first_frame() + min ((framecnt_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(),
                                                                                                        bottom->length()));
                                        if (touched_regions->size() <= 2) {
                                                xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active()));
@@ -509,6 +504,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                }
 
        }
+
+       delete touched_regions;
 }
 
 void
@@ -527,8 +524,8 @@ AudioPlaylist::add_crossfade (boost::shared_ptr<Crossfade> xfade)
        } else {
                _crossfades.push_back (xfade);
 
-               xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated));
-               xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed));
+               xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1));
+               xfade->PropertyChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1));
 
                notify_crossfade_added (xfade);
        }
@@ -583,8 +580,8 @@ AudioPlaylist::set_state (const XMLNode& node, int version)
                try {
                        boost::shared_ptr<Crossfade> xfade = boost::shared_ptr<Crossfade> (new Crossfade (*((const Playlist *)this), *child));
                        _crossfades.push_back (xfade);
-                       xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated));
-                       xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed));
+                       xfade->Invalidated.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_invalidated, this, _1));
+                       xfade->PropertyChanged.connect_same_thread (*this, boost::bind (&AudioPlaylist::crossfade_changed, this, _1));
                        NewCrossfade(xfade);
                }
 
@@ -729,7 +726,7 @@ AudioPlaylist::destroy_region (boost::shared_ptr<Region> region)
 }
 
 void
-AudioPlaylist::crossfade_changed (Change)
+AudioPlaylist::crossfade_changed (const PropertyChange&)
 {
        if (in_flush || in_set_state) {
                return;
@@ -741,29 +738,32 @@ AudioPlaylist::crossfade_changed (Change)
           that occured.
        */
 
-       notify_modified ();
+       notify_contents_changed ();
 }
 
 bool
-AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
+AudioPlaylist::region_changed (const PropertyChange& what_changed, boost::shared_ptr<Region> region)
 {
        if (in_flush || in_set_state) {
                return false;
        }
 
-       Change our_interests = Change (AudioRegion::FadeInChanged|
-                                      AudioRegion::FadeOutChanged|
-                                      AudioRegion::FadeInActiveChanged|
-                                      AudioRegion::FadeOutActiveChanged|
-                                      AudioRegion::EnvelopeActiveChanged|
-                                      AudioRegion::ScaleAmplitudeChanged|
-                                      AudioRegion::EnvelopeChanged);
+       PropertyChange our_interests;
+
+       our_interests.add (Properties::fade_in_active);
+       our_interests.add (Properties::fade_out_active);
+       our_interests.add (Properties::scale_amplitude);
+       our_interests.add (Properties::envelope_active);
+       our_interests.add (Properties::envelope);
+       our_interests.add (Properties::fade_in);
+       our_interests.add (Properties::fade_out);
+
        bool parent_wants_notify;
 
        parent_wants_notify = Playlist::region_changed (what_changed, region);
 
-       if ((parent_wants_notify || (what_changed & our_interests))) {
-               notify_modified ();
+       if (parent_wants_notify || (what_changed.contains (our_interests))) {
+               notify_contents_changed ();
        }
 
        return true;
@@ -787,7 +787,7 @@ AudioPlaylist::crossfades_at (nframes_t frame, Crossfades& clist)
 }
 
 void
-AudioPlaylist::foreach_crossfade (sigc::slot<void, boost::shared_ptr<Crossfade> > s)
+AudioPlaylist::foreach_crossfade (boost::function<void (boost::shared_ptr<Crossfade>)> s)
 {
        RegionLock rl (this, false);
        for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {