Tracks calls tracks "Tracks"; Ardour uses type-names
[ardour.git] / libs / ardour / ardour / session.h
index 6329b29ad27420a53b3b793028eae52d25e09a20..c90c83cca86d181433ca00fcee49e7ef87018797 100644 (file)
@@ -148,6 +148,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
                Recording = 2
        };
 
+    static const char * default_trx_track_name_pattern;
+    static const char * default_ardour_track_name_pattern;
+    
        /* a new session might have non-empty mix_template, an existing session should always have an empty one.
           the bus profile can be null if no master out bus is required.
        */
@@ -183,6 +186,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
 
        static PBD::Signal1<void,std::string> Dialog;
 
+       PBD::Signal0<void> BatchUpdateStart;
+       PBD::Signal0<void> BatchUpdateEnd;
+
        int ensure_subdirs ();
 
        std::string automation_dir () const;  ///< Automation data
@@ -211,6 +217,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO);
 
        bool have_rec_enabled_track () const;
+    bool have_rec_disabled_track () const;
 
        bool have_captured() const { return _have_captured; }
 
@@ -392,8 +399,37 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        framecnt_t worst_input_latency ()  const { return _worst_input_latency; }
        framecnt_t worst_track_latency ()  const { return _worst_track_latency; }
        framecnt_t worst_playback_latency () const { return _worst_output_latency + _worst_track_latency; }
+       
+       struct SaveAs {
+               std::string new_parent_folder;  /* parent folder where new session folder will be created */
+               std::string new_name;           /* name of newly saved session */
+               bool        switch_to;     /* true if we should be working on newly saved session after save-as; false otherwise */
+               bool        include_media; /* true if the newly saved session should contain references to media */
+               bool        copy_media;    /* true if media files (audio, media, etc) should be copied into newly saved session; false otherwise */
+               bool        copy_external; /* true if external media should be consolidated into the newly saved session; false otherwise */
+
+               std::string final_session_folder_name; /* filled in by * Session::save_as(), provides full path to newly saved session */
+               
+               /* emitted as we make progress. 3 arguments passed to signal
+                * handler:
+                *
+                *  1: percentage complete measured as a fraction (0-1.0) of
+                *     total data copying done.
+                *  2: number of files copied so far
+                *  3: total number of files to copy
+                *
+                * Handler should return true for save-as to continue, or false
+                * to stop (and remove all evidence of partial save-as).
+                */
+               PBD::Signal3<bool,float,int64_t,int64_t> Progress;
+
+               /* if save_as() returns non-zero, this string will indicate the reason why.
+                */
+               std::string failure_message;
+       };
 
-       int save_state (std::string snapshot_name, bool pending = false, bool switch_to_snapshot = false);
+       int save_as (SaveAs&);
+       int save_state (std::string snapshot_name, bool pending = false, bool switch_to_snapshot = false, bool template_only = false);
        int restore_state (std::string snapshot_name);
        int save_template (std::string template_name);
        int save_history (std::string snapshot_name = "");
@@ -553,18 +589,20 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        static PBD::Signal1<void, framepos_t> EndTimeChanged;
 
        void   request_sync_source (Slave*);
-       bool   synced_to_engine() const { return config.get_external_sync() && Config->get_sync_source() == Engine; }
+       bool   synced_to_engine() const { return _slave && config.get_external_sync() && Config->get_sync_source() == Engine; }
 
        double transport_speed() const { return _transport_speed; }
        bool   transport_stopped() const { return _transport_speed == 0.0f; }
        bool   transport_rolling() const { return _transport_speed != 0.0f; }
 
-       void set_silent (bool yn);
        bool silent () { return _silent; }
 
        TempoMap&       tempo_map()       { return *_tempo_map; }
        const TempoMap& tempo_map() const { return *_tempo_map; }
 
+       unsigned int    get_xrun_count () const {return _xrun_count; }
+       void            reset_xrun_count () {_xrun_count = 0; }
+
        /* region info  */
 
        boost::shared_ptr<Region> find_whole_file_parent (boost::shared_ptr<Region const>) const;
@@ -666,6 +704,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        void set_mute (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_listen (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_record_enabled (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
+       void set_record_safe (boost::shared_ptr<RouteList>, bool yn, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_solo_isolated (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_monitoring (boost::shared_ptr<RouteList>, MonitorChoice, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_exclusive_input_active (boost::shared_ptr<RouteList> rt, bool onoff, bool flip_others=false);
@@ -677,6 +716,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        /* monitor/master out */
 
        void add_monitor_section ();
+       void reset_monitor_section ();
        void remove_monitor_section ();
 
        boost::shared_ptr<Route> monitor_out() const { return _monitor_out; }
@@ -791,6 +831,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        /* buffers for gain and pan */
 
        gain_t* gain_automation_buffer () const;
+       gain_t* trim_automation_buffer () const;
        gain_t* send_gain_automation_buffer () const;
        pan_t** pan_automation_buffer () const;
 
@@ -942,6 +983,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
     
        MIDI::MachineControl& mmc() { return *_mmc; }
 
+       void reconnect_midi_scene_ports (bool);
+
   protected:
        friend class AudioEngine;
        void set_block_size (pframes_t nframes);
@@ -1011,6 +1054,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        bool                    _writable;
        bool                    _was_seamless;
        bool                    _under_nsm_control;
+       unsigned int            _xrun_count;
 
        void initialize_latencies ();
        void set_worst_io_latencies ();
@@ -1240,6 +1284,21 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
 
        void *do_work();
 
+       /* Signal Forwarding */
+       void emit_route_signals ();
+       void emit_thread_run ();
+       static void *emit_thread (void *);
+       void emit_thread_start ();
+       void emit_thread_terminate ();
+
+       pthread_t       _rt_emit_thread;
+       bool            _rt_thread_active;
+
+       pthread_mutex_t _rt_emit_mutex;
+       pthread_cond_t  _rt_emit_cond;
+       bool            _rt_emit_pending;
+
+
        /* SessionEventManager interface */
 
        void process_event (SessionEvent*);
@@ -1438,8 +1497,10 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap;
 
   private:
+       void reset_write_sources (bool mark_write_complete, bool force = false);
        SourceMap sources;
 
+
   private:
        int load_sources (const XMLNode& node);
        XMLNode& get_sources_as_xml ();
@@ -1621,8 +1682,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
 
        mutable bool have_looped; ///< Used in ::audible_frame(*)
 
-       void update_have_rec_enabled_track ();
+       void update_route_record_state ();
        gint _have_rec_enabled_track;
+       gint _have_rec_disabled_track;
 
        static int ask_about_playlist_deletion (boost::shared_ptr<Playlist>);
 
@@ -1645,6 +1707,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        void rt_set_listen (boost::shared_ptr<RouteList>, bool yn, bool group_override);
        void rt_set_solo_isolated (boost::shared_ptr<RouteList>, bool yn, bool group_override);
        void rt_set_record_enabled (boost::shared_ptr<RouteList>, bool yn, bool group_override);
+       void rt_set_record_safe (boost::shared_ptr<RouteList>, bool yn, bool group_override);
        void rt_set_monitoring (boost::shared_ptr<RouteList>, MonitorChoice, bool group_override);
 
        /** temporary list of Diskstreams used only during load of 2.X sessions */
@@ -1700,6 +1763,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        void setup_click_state (const XMLNode*);
        void setup_bundles ();
        
+       void save_as_bring_callback (uint32_t, uint32_t, std::string);
+
        static int get_session_info_from_path (XMLTree& state_tree, const std::string& xmlpath);
 };