(Source List) Region List rewrite (libardour part)
[ardour.git] / libs / ardour / ardour / session.h
index b5997a3a8365eb0c1f4e3eed31714cbb81298cf0..dac08af29bc7e8272368063a9c299c7c7952d53c 100644 (file)
@@ -213,16 +213,21 @@ public:
        bool path_is_within_session (const std::string&);
 
        bool writable() const { return _writable; }
-       void set_dirty ();
-       void set_clean ();
-       bool dirty() const { return _state_of_the_state & Dirty; }
-       void set_deletion_in_progress ();
-       void clear_deletion_in_progress ();
-       bool reconnection_in_progress() const { return _reconnecting_routes_in_progress; }
-       bool deletion_in_progress() const { return _state_of_the_state & Deletion; }
-       bool routes_deletion_in_progress() const { return _route_deletion_in_progress; }
-       bool peaks_cleanup_in_progres() const { return _state_of_the_state & PeakCleanup; }
-       bool loading () const { return _state_of_the_state & Loading; }
+       void set_clean ();   // == Clean and emit DirtyChanged IFF session was Dirty
+       void set_dirty ();   // |= Dirty and emit DirtyChanged (unless already dirty or Loading, Deletion)
+       void unset_dirty (bool emit_dirty_changed = false); // &= ~Dirty
+       void set_deletion_in_progress ();   // |= Deletion
+       void clear_deletion_in_progress (); // &= ~Deletion
+
+       bool reconnection_in_progress () const         { return _reconnecting_routes_in_progress; }
+       bool routes_deletion_in_progress () const      { return _route_deletion_in_progress; }
+       bool dirty () const                            { return _state_of_the_state & Dirty; }
+       bool deletion_in_progress () const             { return _state_of_the_state & Deletion; }
+       bool peaks_cleanup_in_progres () const         { return _state_of_the_state & PeakCleanup; }
+       bool loading () const                          { return _state_of_the_state & Loading; }
+       bool cannot_save () const                      { return _state_of_the_state & CannotSave; }
+       bool in_cleanup () const                       { return _state_of_the_state & InCleanup; }
+       bool inital_connect_or_deletion_in_progress () { return _state_of_the_state & (InitialConnecting | Deletion); }
 
        PBD::Signal0<void> DirtyChanged;
 
@@ -287,7 +292,7 @@ public:
 
        boost::shared_ptr<RTTaskList> rt_tasklist () { return _rt_tasklist; }
 
-       RouteList get_routelist (bool mixer_order = false) const;
+       RouteList get_routelist (bool mixer_order = false, PresentationInfo::Flag fl = PresentationInfo::MixerRoutes) const;
 
        CoreSelection& selection () { return *_selection; }
 
@@ -298,7 +303,7 @@ public:
         * with get_routes()
         */
 
-       void get_stripables (StripableList&) const;
+       void get_stripables (StripableList&, PresentationInfo::Flag fl = PresentationInfo::MixerStripables) const;
        StripableList get_stripables () const;
        boost::shared_ptr<RouteList> get_tracks() const;
        boost::shared_ptr<RouteList> get_routes_with_internal_returns() const;
@@ -468,8 +473,8 @@ public:
        void set_auto_punch_location (Location *);
        void set_auto_loop_location (Location *);
        void set_session_extents (samplepos_t start, samplepos_t end);
-       bool end_is_free () const { return _session_range_end_is_free; }
-       void set_end_is_free (bool);
+       bool session_range_is_free () const { return _session_range_is_free; }
+       void set_session_range_is_free (bool);
 
        pframes_t get_block_size () const         { return current_block_size; }
        samplecnt_t worst_output_latency () const { return _worst_output_latency; }
@@ -583,8 +588,6 @@ public:
                PeakCleanup = 0x40
        };
 
-       StateOfTheState state_of_the_state() const { return _state_of_the_state; }
-
        class StateProtector {
                public:
                        StateProtector (Session* s) : _session (s) {
@@ -873,15 +876,14 @@ public:
        PBD::Signal0<void> MuteChanged;
        PBD::Signal0<void> IsolatedChanged;
        PBD::Signal0<void> MonitorChanged;
+       PBD::Signal0<void> MonitorBusAddedOrRemoved;
 
        PBD::Signal0<void> session_routes_reconnected;
 
        /* monitor/master out */
        int add_master_bus (ChanCount const&);
 
-       void add_monitor_section ();
        void reset_monitor_section ();
-       void remove_monitor_section ();
        bool monitor_active() const { return (_monitor_out && _monitor_out->monitor_control () && _monitor_out->monitor_control ()->monitor_active()); }
 
        boost::shared_ptr<Route> monitor_out() const { return _monitor_out; }
@@ -1077,7 +1079,6 @@ public:
        boost::shared_ptr<AutomationControl> automation_control_by_id (const PBD::ID&);
 
        void add_controllable (boost::shared_ptr<PBD::Controllable>);
-       void remove_controllable (PBD::Controllable*);
 
        boost::shared_ptr<PBD::Controllable> solo_cut_control() const;
 
@@ -1105,17 +1106,17 @@ public:
                PostTransportRoll               = 0x8,
                PostTransportAbort              = 0x10,
                PostTransportOverWrite          = 0x20,
-               /* was ... PostTransportSpeed              = 0x40, */
+               /* PostTransportSpeed           = 0x40, */
                PostTransportAudition           = 0x80,
                PostTransportReverse            = 0x100,
-               PostTransportInputChange        = 0x200,
-               PostTransportCurveRealloc       = 0x400,
+               /* PostTransportInputChange     = 0x200, */
+               /*PostTransportCurveRealloc       = 0x400, */
                PostTransportClearSubstate      = 0x800,
                PostTransportAdjustPlaybackBuffering  = 0x1000,
                PostTransportAdjustCaptureBuffering   = 0x2000
        };
 
-       boost::shared_ptr<SessionPlaylists> playlists;
+       boost::shared_ptr<SessionPlaylists> playlists () const { return _playlists; }
 
        void send_mmc_locate (samplepos_t);
        void queue_full_time_code () { _send_timecode_update = true; }
@@ -1200,6 +1201,7 @@ public:
 
        double compute_speed_from_master (pframes_t nframes);
        bool   transport_master_is_external() const;
+       bool   transport_master_no_external_or_using_engine() const;
        boost::shared_ptr<TransportMaster> transport_master() const;
 
        void import_pt (PTFFormat& ptf, ImportStatus& status);
@@ -1214,7 +1216,6 @@ protected:
 #endif
 
        friend class Route;
-       void schedule_curve_reallocation ();
        void update_latency_compensation (bool force = false);
 
 private:
@@ -1225,6 +1226,8 @@ private:
        static void init_name_id_counter (guint n);
        static unsigned int name_id_counter ();
 
+       boost::shared_ptr<SessionPlaylists> _playlists;
+
        /* stuff used in process() should be close together to
           maximise cache hits
        */
@@ -1237,7 +1240,7 @@ private:
        process_function_type    last_process_function;
        bool                    _bounce_processing_active;
        bool                     waiting_for_sync_offset;
-       samplecnt_t              _base_sample_rate;     // sample-rate of the session at creation time, "native" SR
+       samplecnt_t             _base_sample_rate;     // sample-rate of the session at creation time, "native" SR
        samplecnt_t             _nominal_sample_rate;  // overridden by audioengine setting
        samplecnt_t             _current_sample_rate;  // this includes video pullup offset
        int                      transport_sub_state;
@@ -1245,7 +1248,7 @@ private:
        samplepos_t             _transport_sample;
        gint                    _seek_counter;
        Location*               _session_range_location; ///< session range, or 0 if there is nothing in the session yet
-       bool                    _session_range_end_is_free;
+       bool                    _session_range_is_free;
        bool                    _silent;
        samplecnt_t             _remaining_latency_preroll;
 
@@ -1276,6 +1279,9 @@ private:
 
        std::string             _missing_file_replacement;
 
+       void add_monitor_section ();
+       void remove_monitor_section ();
+
        void initialize_latencies ();
        void update_latency (bool playback);
        bool update_route_latency (bool reverse, bool apply_to_delayline);
@@ -1359,7 +1365,7 @@ private:
        pframes_t               _pframes_since_last_mtc;
        bool                     play_loop;
        bool                     loop_changing;
-       samplepos_t               last_loopend;
+       samplepos_t              last_loopend;
 
        boost::scoped_ptr<SessionDirectory> _session_dir;
 
@@ -1413,9 +1419,7 @@ private:
 
        static const PostTransportWork ProcessCannotProceedMask =
                PostTransportWork (
-                       PostTransportInputChange|
                        PostTransportReverse|
-                       PostTransportCurveRealloc|
                        PostTransportAudition|
                        PostTransportStop|
                        PostTransportClearSubstate);
@@ -1428,12 +1432,6 @@ private:
        void schedule_playback_buffering_adjustment ();
        void schedule_capture_buffering_adjustment ();
 
-       uint32_t    cumulative_rf_motion;
-       uint32_t    rf_scale;
-
-       void set_rf_speed (float speed);
-       void reset_rf_scale (samplecnt_t samples_moved);
-
        Locations*       _locations;
        void location_added (Location*);
        void location_removed (Location*);
@@ -1620,13 +1618,13 @@ private:
 
        double            ltc_speed;
        int32_t           ltc_enc_byte;
-       samplepos_t        ltc_enc_pos;
+       samplepos_t       ltc_enc_pos;
        double            ltc_enc_cnt;
-       samplepos_t        ltc_enc_off;
+       samplepos_t       ltc_enc_off;
        bool              restarting;
-       samplepos_t        ltc_prev_cycle;
+       samplepos_t       ltc_prev_cycle;
 
-       samplepos_t        ltc_timecode_offset;
+       samplepos_t       ltc_timecode_offset;
        bool              ltc_timecode_negative_offset;
 
        LatencyRange      ltc_out_latency;
@@ -1654,6 +1652,7 @@ private:
        int           start_midi_thread ();
 
        bool should_ignore_transport_request (TransportRequestSource, TransportRequestType) const;
+       bool declick_in_progress () const;
 
        void set_play_loop (bool yn, double speed);
        void unset_play_loop ();
@@ -1755,8 +1754,22 @@ private:
        mutable Glib::Threads::Mutex source_lock;
 
 public:
+
+       /* Emited when a new source is added to the session */
+       PBD::Signal1< void, boost::shared_ptr<Source> > SourceAdded;
+       PBD::Signal1< void, boost::shared_ptr<Source> > SourceRemoved;
+
        typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap;
 
+       void foreach_source (boost::function<void( boost::shared_ptr<Source> )> f) {
+               Glib::Threads::Mutex::Lock ls (source_lock);
+               for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) {
+                       f ( (*i).second );
+               }
+       }
+       
+       bool playlist_is_active( boost::shared_ptr<Playlist>);
+       
 private:
        void reset_write_sources (bool mark_write_complete, bool force = false);
        SourceMap sources;
@@ -1877,32 +1890,32 @@ private:
        XMLNode& get_template ();
 
        /* click track */
-       typedef std::list<Click*> Clicks;
-       Clicks                  clicks;
-       bool                   _clicking;
-       bool                   _click_rec_only;
-       boost::shared_ptr<IO>  _click_io;
-       boost::shared_ptr<Amp> _click_gain;
-       Sample*                 click_data;
-       Sample*                 click_emphasis_data;
-       samplecnt_t              click_length;
-       samplecnt_t              click_emphasis_length;
-       mutable Glib::Threads::RWLock    click_lock;
+       typedef std::list<Click*>     Clicks;
+       Clicks                        clicks;
+       bool                         _clicking;
+       bool                         _click_rec_only;
+       boost::shared_ptr<IO>        _click_io;
+       boost::shared_ptr<Amp>       _click_gain;
+       Sample*                       click_data;
+       Sample*                       click_emphasis_data;
+       samplecnt_t                   click_length;
+       samplecnt_t                   click_emphasis_length;
+       mutable Glib::Threads::RWLock click_lock;
 
        static const Sample     default_click[];
        static const samplecnt_t default_click_length;
        static const Sample     default_click_emphasis[];
        static const samplecnt_t default_click_emphasis_length;
 
-       Click *get_click();
+       Clickget_click();
        samplepos_t _clicks_cleared;
-       void   setup_click_sounds (int which);
-       void   setup_click_sounds (Sample**, Sample const *, samplecnt_t*, samplecnt_t, std::string const &);
-       void   clear_clicks ();
-       void   click (samplepos_t start, samplecnt_t nframes);
-       void   run_click (samplepos_t start, samplecnt_t nframes);
-       void   add_click (samplepos_t pos, bool emphasis);
        samplecnt_t _count_in_samples;
+       void setup_click_sounds (int which);
+       void setup_click_sounds (Sample**, Sample const *, samplecnt_t*, samplecnt_t, std::string const &);
+       void clear_clicks ();
+       void click (samplepos_t start, samplecnt_t nframes);
+       void run_click (samplepos_t start, samplecnt_t nframes);
+       void add_click (samplepos_t pos, bool emphasis);
 
        /* range playback */