improve, cleanup, rationalize Session::cleanup_sources() and supporting infrastructure
[ardour.git] / libs / ardour / ardour / playlist.h
index b60fa62879da9d4c7a94537d47548dc0bd7b4505..e21199e6420817b9de2512c149c71bc9e419c443 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "ardour/ardour.h"
 #include "ardour/session_object.h"
-#include "ardour/crossfade_compare.h"
 #include "ardour/data_type.h"
 
 namespace ARDOUR  {
@@ -50,6 +49,7 @@ namespace ARDOUR  {
 class Session;
 class Region;
 class Playlist;
+class Crossfade;       
 
 namespace Properties {
         /* fake the type, since regions are handled by SequenceProperty which doesn't
@@ -63,10 +63,15 @@ class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_
   public:
         RegionListProperty (Playlist&);
 
-        boost::shared_ptr<Region> lookup_id (const PBD::ID& id);
+       RegionListProperty* clone () const;
+       void get_content_as_xml (boost::shared_ptr<Region>, XMLNode &) const;
+       boost::shared_ptr<Region> get_content_from_xml (XMLNode const &) const;
 
   private:
-       PBD::SequenceProperty<std::list<boost::shared_ptr<Region> > >* create () const;
+       RegionListProperty* create () const;
+
+       /* copy construction only by ourselves */
+       RegionListProperty (RegionListProperty const & p);
 
         friend class Playlist;
         /* we live and die with our playlist, no lifetime management needed */
@@ -87,10 +92,10 @@ public:
        virtual ~Playlist ();
 
         void update (const RegionListProperty::ChangeRecord&);
-        void clear_owned_history ();
-        void rdiff (std::vector<PBD::StatefulDiffCommand*>&) const;
+        void clear_owned_changes ();
+        void rdiff (std::vector<Command*>&) const;
 
-       boost::shared_ptr<Region> region_by_id (const PBD::ID&);
+       boost::shared_ptr<Region> region_by_id (const PBD::ID&) const;
 
        void set_region_ownership ();
 
@@ -112,7 +117,7 @@ public:
        bool hidden() const { return _hidden; }
        bool empty() const;
        uint32_t n_regions() const;
-       std::pair<framecnt_t, framecnt_t> get_extent () const;
+       std::pair<framepos_t, framepos_t> get_extent () const;
        layer_t top_layer() const;
 
        EditMode get_edit_mode() const { return _edit_mode; }
@@ -142,8 +147,10 @@ public:
        const RegionListProperty& region_list () const { return regions; }
 
        RegionList*                regions_at (framepos_t frame);
+        uint32_t                   count_regions_at (framepos_t);
        RegionList*                regions_touched (framepos_t start, framepos_t end);
        RegionList*                regions_to_read (framepos_t start, framepos_t end);
+       uint32_t                   region_use_count (boost::shared_ptr<Region>) const;
        boost::shared_ptr<Region>  find_region (const PBD::ID&) const;
        boost::shared_ptr<Region>  top_region_at (framepos_t frame);
        boost::shared_ptr<Region>  top_unmuted_region_at (framepos_t frame);
@@ -152,6 +159,7 @@ public:
        bool                       region_is_shuffle_constrained (boost::shared_ptr<Region>);
        bool                       has_region_at (framepos_t const) const;
 
+        bool uses_source (boost::shared_ptr<const Source> src) const;
 
        framepos_t find_next_transient (framepos_t position, int dir);
 
@@ -172,6 +180,11 @@ public:
        /** Emitted when regions have moved (not when regions have only been trimmed) */
        PBD::Signal2<void,std::list< Evoral::RangeMove<framepos_t> > const &, bool> RangesMoved;
 
+       /** Emitted when regions are extended; the ranges passed are the new extra time ranges
+           that these regions now occupy.
+       */
+       PBD::Signal1<void,std::list< Evoral::Range<framepos_t> > const &> RegionsExtended;
+
        static std::string bump_name (std::string old_name, Session&);
 
        void freeze ();
@@ -192,6 +205,8 @@ public:
 
        virtual bool destroy_region (boost::shared_ptr<Region>) = 0;
 
+        void sync_all_regions_with_regions ();
+
        /* special case function used by UI selection objects, which have playlists that actually own the regions
           within them.
        */
@@ -204,6 +219,12 @@ public:
 
        void set_explicit_relayering (bool e);
 
+       virtual boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &) const {
+               return boost::shared_ptr<Crossfade> ();
+       }
+
+       framepos_t find_next_top_layer_position (framepos_t) const;     
+
   protected:
        friend class Session;
 
@@ -247,6 +268,8 @@ public:
         *  do automation-follows-regions.
         */
        std::list< Evoral::RangeMove<framepos_t> > pending_range_moves;
+       /** Extra sections added to regions during trims */
+       std::list< Evoral::Range<framepos_t> >     pending_region_extensions;
        bool             save_on_thaw;
        std::string      last_save_reason;
        uint32_t         in_set_state;
@@ -295,6 +318,8 @@ public:
        void notify_contents_changed ();
        void notify_state_changed (const PBD::PropertyChange&);
        void notify_region_moved (boost::shared_ptr<Region>);
+       void notify_region_start_trimmed (boost::shared_ptr<Region>);
+       void notify_region_end_trimmed (boost::shared_ptr<Region>);
 
        void mark_session_dirty();
 
@@ -324,11 +349,11 @@ public:
        bool add_region_internal (boost::shared_ptr<Region>, framepos_t position);
 
        int remove_region_internal (boost::shared_ptr<Region>);
-       RegionList *find_regions_at (framepos_t frame);
+       RegionList *find_regions_at (framepos_t);
        void copy_regions (RegionList&) const;
        void partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist);
 
-       std::pair<framecnt_t, framecnt_t> _get_extent() const;
+       std::pair<framepos_t, framepos_t> _get_extent() const;
 
        boost::shared_ptr<Playlist> cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t, framecnt_t, bool),
                                              std::list<AudioRange>& ranges, bool result_is_hidden);