introduce the idea of a "default transport speed", used whenever Session::start_trans...
[ardour.git] / libs / ardour / ardour / session.h
index 973374ab32976205d050170b8a52141c36f8ded2..7f73d3ae775e8629074a3b7b5f3a5c9c0b5b2ea9 100644 (file)
@@ -52,6 +52,7 @@
 #include "ardour/ardour.h"
 #include "ardour/chan_count.h"
 #include "ardour/delivery.h"
+#include "ardour/interthread_info.h"
 #include "ardour/rc_configuration.h"
 #include "ardour/session_configuration.h"
 #include "ardour/session_event.h"
@@ -176,9 +177,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        const SessionDirectory& session_directory () const { return *(_session_dir.get()); }
 
-       static PBD::Signal0<void> AutoBindingOn;
-       static PBD::Signal0<void> AutoBindingOff;
-
        static PBD::Signal1<void,std::string> Dialog;
 
        int ensure_subdirs ();
@@ -331,8 +329,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void goto_start ();
        void use_rf_shuttle_speed ();
        void allow_auto_play (bool yn);
-       void request_transport_speed (double speed);
-       void request_transport_speed_nonzero (double);
+        void request_transport_speed (double speed, bool as_default = false);
+        void request_transport_speed_nonzero (double, bool as_default = false);
        void request_overwrite_buffer (Track *);
        void adjust_playback_buffering();
        void adjust_capture_buffering();
@@ -456,6 +454,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                );
 
        std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
+               const ChanCount& input, const ChanCount& output,
                boost::shared_ptr<PluginInfo> instrument = boost::shared_ptr<PluginInfo>(),
                TrackMode mode = Normal, 
                RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = ""
@@ -531,14 +530,14 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* source management */
 
-       void import_audiofiles (ImportStatus&);
+       void import_files (ImportStatus&);
        bool sample_rate_convert (ImportStatus&, std::string infile, std::string& outfile);
        std::string build_tmp_convert_name (std::string file);
 
        boost::shared_ptr<ExportHandler> get_export_handler ();
        boost::shared_ptr<ExportStatus> get_export_status ();
 
-       int start_audio_export (framepos_t position, bool realtime);
+       int start_audio_export (framepos_t position);
 
        PBD::Signal1<int, framecnt_t> ProcessExport;
        static PBD::Signal2<void,std::string, std::string> Exported;
@@ -607,8 +606,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* flattening stuff */
 
        boost::shared_ptr<Region> write_one_track (AudioTrack&, framepos_t start, framepos_t end,
-                       bool overwrite, std::vector<boost::shared_ptr<Source> >&, InterThreadInfo& wot,
-                       bool enable_processing = true);
+                                                  bool overwrite, std::vector<boost::shared_ptr<Source> >&, InterThreadInfo& wot,
+                                                  boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export);
        int freeze_all (InterThreadInfo&);
 
        /* session-wide solo/mute/rec-enable */
@@ -671,7 +670,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* s/w "RAID" management */
 
-       framecnt_t available_capture_duration();
+       boost::optional<framecnt_t> available_capture_duration();
 
        /* I/O bundles */
 
@@ -718,6 +717,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                return _current_trans_quarks;
        }
 
+       bool operation_in_progress (GQuark) const;
+
        void add_commands (std::vector<Command*> const & cmds);
 
        std::map<PBD::ID,PBD::StatefulDestructible*> registry;
@@ -745,6 +746,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* buffers for gain and pan */
 
        gain_t* gain_automation_buffer () const;
+       gain_t* send_gain_automation_buffer () const;
        pan_t** pan_automation_buffer () const;
 
        void ensure_buffer_set (BufferSet& buffers, const ChanCount& howmany);
@@ -776,8 +778,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        boost::shared_ptr<PBD::Controllable> solo_cut_control() const;
 
-       SessionMetadata & metadata () { return *_metadata; }
-
        SessionConfiguration config;
 
        bool exporting () const {
@@ -872,10 +872,12 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void destroy ();
 
        enum SubState {
-               PendingDeclickIn   = 0x1,
-               PendingDeclickOut  = 0x2,
-               StopPendingCapture = 0x4,
-               PendingLocate      = 0x20,
+               PendingDeclickIn      = 0x1,  ///< pending de-click fade-in for start
+               PendingDeclickOut     = 0x2,  ///< pending de-click fade-out for stop
+               StopPendingCapture    = 0x4,
+               PendingLoopDeclickIn  = 0x8,  ///< pending de-click fade-in at the start of a loop
+               PendingLoopDeclickOut = 0x10, ///< pending de-click fade-out at the end of a loop
+               PendingLocate         = 0x20,
        };
 
        /* stuff used in process() should be close together to
@@ -903,6 +905,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        // varispeed playback
        double                  _transport_speed;
+       double                  _default_transport_speed;
        double                  _last_transport_speed;
        double                  _target_transport_speed;
        CubicInterpolation       interpolation;
@@ -983,6 +986,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        int  pre_export ();
        int  stop_audio_export ();
        void finalize_audio_export ();
+       bool _pre_export_mmc_enabled;
 
        PBD::ScopedConnection export_freewheel_connection;
 
@@ -990,12 +994,25 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        int  process_routes (pframes_t, bool& need_butler);
        int  silent_process_routes (pframes_t, bool& need_butler);
 
+       /** @return 1 if there is a pending declick fade-in,
+                  -1 if there is a pending declick fade-out,
+                   0 if there is no pending declick.
+       */
        int get_transport_declick_required () {
                if (transport_sub_state & PendingDeclickIn) {
                        transport_sub_state &= ~PendingDeclickIn;
                        return 1;
                } else if (transport_sub_state & PendingDeclickOut) {
+                       /* XXX: not entirely sure why we don't clear this */
+                       return -1;
+               } else if (transport_sub_state & PendingLoopDeclickOut) {
+                       /* Return the declick out first ... */
+                       transport_sub_state &= ~PendingLoopDeclickOut;
                        return -1;
+               } else if (transport_sub_state & PendingLoopDeclickIn) {
+                       /* ... then the declick in on the next call */
+                       transport_sub_state &= ~PendingLoopDeclickIn;
+                       return 1;
                } else {
                        return 0;
                }
@@ -1085,6 +1102,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        PBD::ScopedConnectionList loop_connections;
        void             auto_loop_changed (Location *);
+       void             auto_loop_declick_range (Location *, framepos_t &, framepos_t &);
 
        void first_stage_init (std::string path, std::string snapshot_name);
        int  second_stage_init ();
@@ -1124,9 +1142,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* MIDI Machine Control */
 
-       void spp_start (MIDI::Parser&, framepos_t timestamp);
-       void spp_continue (MIDI::Parser&, framepos_t timestamp);
-       void spp_stop (MIDI::Parser&, framepos_t timestamp);
+       void spp_start ();
+       void spp_continue ();
+       void spp_stop ();
 
        void mmc_deferred_play (MIDI::MachineControl &);
        void mmc_stop (MIDI::MachineControl &);
@@ -1193,7 +1211,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void start_locate (framepos_t, bool with_roll, bool with_flush, bool with_loop=false, bool force=false);
        void force_locate (framepos_t frame, bool with_roll = false);
        void set_track_speed (Track *, double speed);
-       void set_transport_speed (double speed, bool abort = false, bool clear_state = false);
+        void set_transport_speed (double speed, bool abort = false, bool clear_state = false, bool as_default = false);
        void stop_transport (bool abort = false, bool clear_state = false);
        void start_transport ();
        void realtime_stop (bool abort, bool clear_state);
@@ -1223,7 +1241,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        SerializedRCUManager<RouteList>  routes;
 
-       void add_routes (RouteList&, bool auto_connect, bool save);
+       void add_routes (RouteList&, bool input_auto_connect, bool output_auto_connect, bool save);
        uint32_t destructive_index;
 
        boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&, int);
@@ -1331,16 +1349,21 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* S/W RAID */
 
        struct space_and_path {
-               uint32_t blocks; /* 4kB blocks */
+               uint32_t blocks;     ///< 4kB blocks
+               bool blocks_unknown; ///< true if blocks is unknown
                std::string path;
 
-               space_and_path() {
-                       blocks = 0;
-               }
+               space_and_path ()
+                       : blocks (0)
+                       , blocks_unknown (true)
+               {}
        };
 
        struct space_and_path_ascending_cmp {
                bool operator() (space_and_path a, space_and_path b) {
+                       if (a.blocks_unknown != b.blocks_unknown) {
+                               return !a.blocks_unknown;
+                       }
                        return a.blocks > b.blocks;
                }
        };
@@ -1350,6 +1373,11 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        std::vector<space_and_path> session_dirs;
        std::vector<space_and_path>::iterator last_rr_session_dir;
        uint32_t _total_free_4k_blocks;
+       /** If this is true, _total_free_4k_blocks is not definite,
+           as one or more of the session directories' filesystems
+           could not report free space.
+       */
+       bool _total_free_4k_blocks_uncertain;
        Glib::Mutex space_lock;
 
        bool no_questions_about_missing_files;
@@ -1464,8 +1492,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        static bool _disable_all_loaded_plugins;
 
-       SessionMetadata * _metadata;
-
        mutable bool have_looped; ///< Used in ::audible_frame(*)
 
        void update_have_rec_enabled_track ();