Selection of visible note range (full range vs fit contents, selectable from midi...
[ardour.git] / libs / ardour / ardour / session.h
index 39bb9c3e6848cd98343c9b7c2396bf3dd6946375..8a5165396832da0645519a63eb5c21aea45fc92f 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_session_h__
 #define __ardour_session_h__
 
-
 #include <string>
 #include <list>
 #include <map>
@@ -29,6 +27,7 @@
 #include <set>
 #include <stack>
 
+#include <boost/scoped_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <boost/dynamic_bitset.hpp>
 
@@ -56,6 +55,8 @@
 #include <ardour/gain.h>
 #include <ardour/io.h>
 
+#include <ardour/smpte.h>
+
 class XMLTree;
 class XMLNode;
 class AEffect;
@@ -73,29 +74,41 @@ namespace ARDOUR {
 class Port;
 class AudioEngine;
 class Slave;
-class Diskstream;      
-class AudioDiskstream; 
+class Diskstream;
 class Route;
 class AuxInput;
 class Source;
 class AudioSource;
+class BufferSet;
+
+class Diskstream;
+class AudioDiskstream;
+class MidiDiskstream;
 class AudioFileSource;
+class MidiSource;
 class Auditioner;
-class Insert;
+class Processor;
 class Send;
-class Redirect;
+class IOProcessor;
 class PortInsert;
 class PluginInsert;
-class Connection;
+class Bundle;
 class TempoMap;
 class AudioTrack;
 class NamedSelection;
 class AudioRegion;
+
 class Region;
 class Playlist;
 class VSTPlugin;
 class ControlProtocolInfo;
 
+class MidiTrack;
+class MidiRegion;
+class SMFSource;
+
+class SessionDirectory;
+
 struct AudioExportSpecification;
 struct RouteGroup;
 
@@ -105,7 +118,6 @@ using std::map;
 using std::set;
 
 class Session : public PBD::StatefulDestructible
-
 {
   private:
        typedef std::pair<boost::weak_ptr<Route>,bool> RouteBooleanState;
@@ -152,8 +164,8 @@ class Session : public PBD::StatefulDestructible
                    Replace,
                    Clear
            };
-
-           Type           type;
+               
+               Type           type;
            Action         action;
            nframes_t action_frame;
            nframes_t target_frame;
@@ -163,9 +175,10 @@ class Session : public PBD::StatefulDestructible
                        void*                ptr;
                        bool                 yes_or_no;
                        SlaveSource slave;
+                       Route*               route;
            };
 
-           boost::shared_ptr<Region>   region;
+           boost::shared_ptr<Region>     region;
 
            list<AudioRange>     audio_range;
            list<MusicRange>     music_range;
@@ -230,14 +243,10 @@ class Session : public PBD::StatefulDestructible
        
        virtual ~Session ();
 
-
-       static int find_session (string str, string& path, string& snapshot, bool& isnew);
-       
        string path() const { return _path; }
        string name() const { return _name; }
        string snap_name() const { return _current_snapshot_name; }
        string raid_path () const;
-       string export_dir () const;
 
        void set_snap_name ();
 
@@ -248,28 +257,23 @@ class Session : public PBD::StatefulDestructible
        bool deletion_in_progress() const { return _state_of_the_state & Deletion; }
        sigc::signal<void> DirtyChanged;
 
-       std::string sound_dir (bool with_path = true) const;
-       std::string peak_dir () const;
-       std::string dead_sound_dir () const;
-       std::string automation_dir () const;
+       const SessionDirectory& session_directory () const { return *(_session_dir.get()); }
 
-       string peak_path_from_audio_path (string) const;
+       std::string automation_dir () const;
 
-       static string suffixed_search_path (std::string suffix, bool data);
-       static string control_protocol_path ();
-       static string template_path ();
-       static string template_dir ();
-       static void get_template_list (list<string>&);
-       
        static string change_audio_path_by_name (string oldpath, string oldname, string newname, bool destructive);
+       static string change_midi_path_by_name (string oldpath, string oldname, string newname, bool destructive);
+       
+       string peak_path_from_audio_path (string) const;
        string audio_path_from_name (string, uint32_t nchans, uint32_t chan, bool destructive);
+       string midi_path_from_name (string);
 
        void process (nframes_t nframes);
 
-       vector<Sample*>& get_passthru_buffers() { return _passthru_buffers; }
-       vector<Sample*>& get_silent_buffers (uint32_t howmany);
-       vector<Sample*>& get_send_buffers () { return _send_buffers; }
-
+       BufferSet& get_silent_buffers (ChanCount count = ChanCount::ZERO);
+       BufferSet& get_scratch_buffers (ChanCount count = ChanCount::ZERO);
+       BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO);
+       
        void add_diskstream (boost::shared_ptr<Diskstream>);
        boost::shared_ptr<Diskstream> diskstream_by_id (const PBD::ID& id);
        boost::shared_ptr<Diskstream> diskstream_by_name (string name);
@@ -284,11 +288,11 @@ class Session : public PBD::StatefulDestructible
        
        typedef std::list<boost::shared_ptr<Diskstream> > DiskstreamList;
        typedef std::list<boost::shared_ptr<Route> >      RouteList; 
-
+       
        boost::shared_ptr<RouteList> get_routes() const {
                return routes.reader ();
        }
-
+       
        uint32_t nroutes() const { return routes.reader()->size(); }
        uint32_t ntracks () const;
        uint32_t nbusses () const;
@@ -324,6 +328,8 @@ class Session : public PBD::StatefulDestructible
        void disable_record (bool rt_context, bool force = false);
        void step_back_from_record ();
        
+       void maybe_write_autosave ();
+
        /* Proxy signal for region hidden changes */
 
        sigc::signal<void,boost::shared_ptr<Region> > RegionHiddenChange;
@@ -342,6 +348,7 @@ class Session : public PBD::StatefulDestructible
        sigc::signal<void,nframes_t> PositionChanged; /* sent after any non-sequential motion */
        sigc::signal<void> DurationChanged;
        sigc::signal<void> HaltOnXrun;
+       sigc::signal<void> TransportLooped;
 
        sigc::signal<void,RouteList&> RouteAdded;
 
@@ -359,6 +366,7 @@ class Session : public PBD::StatefulDestructible
        void set_session_start (nframes_t start) { start_location->set_start(start); }
        void set_session_end (nframes_t end) { end_location->set_start(end); _end_location_is_free = false; }
        void use_rf_shuttle_speed ();
+       void allow_auto_play (bool yn);
        void request_transport_speed (float speed);
        void request_overwrite_buffer (Diskstream*);
        void request_diskstream_speed (Diskstream&, float speed);
@@ -368,6 +376,7 @@ class Session : public PBD::StatefulDestructible
        bool transport_locked () const;
 
        int wipe ();
+       //int wipe_diskstream (AudioDiskstream *);
 
        int remove_region_from_region_list (boost::shared_ptr<Region>);
 
@@ -409,12 +418,10 @@ class Session : public PBD::StatefulDestructible
        int save_state (string snapshot_name, bool pending = false);
        int restore_state (string snapshot_name);
        int save_template (string template_name);
-        int save_history (string snapshot_name = "");
-        int restore_history (string snapshot_name);
-
-       static int rename_template (string old_name, string new_name);
-
-       static int delete_template (string name);
+       int save_history (string snapshot_name = "");
+       int restore_history (string snapshot_name);
+       void remove_state (string snapshot_name);
+       void rename_state (string old_name, string new_name);
        
        sigc::signal<void,string> StateSaved;
        sigc::signal<void> StateReady;
@@ -425,8 +432,10 @@ class Session : public PBD::StatefulDestructible
        XMLNode& get_state();
        int      set_state(const XMLNode& node); // not idempotent
        XMLNode& get_template();
-       
-       void add_instant_xml (XMLNode&, const std::string& dir);
+
+       /// The instant xml file is written to the session directory
+       void add_instant_xml (XMLNode&);
+       XMLNode * instant_xml (const std::string& str);
 
        enum StateOfTheState {
                Clean = 0x0,
@@ -470,12 +479,14 @@ class Session : public PBD::StatefulDestructible
 
        std::list<boost::shared_ptr<AudioTrack> > new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal, uint32_t how_many = 1);
        RouteList new_audio_route (int input_channels, int output_channels, uint32_t how_many);
+       
+       std::list<boost::shared_ptr<MidiTrack> > new_midi_track (TrackMode mode = Normal, uint32_t how_many = 1);
+       //boost::shared_ptr<Route>     new_midi_route (uint32_t how_many = 1);
 
        void   remove_route (boost::shared_ptr<Route>);
-
        void   resort_routes ();
        void   resort_routes_using (boost::shared_ptr<RouteList>);
-
+       
        void    set_remote_control_ids();
 
        AudioEngine &engine() { return _engine; };
@@ -537,19 +548,22 @@ class Session : public PBD::StatefulDestructible
        
        /* region info  */
 
-       sigc::signal<void,boost::weak_ptr<AudioRegion> > AudioRegionAdded;
-       sigc::signal<void,boost::weak_ptr<AudioRegion> > AudioRegionRemoved;
+       sigc::signal<void,boost::shared_ptr<Region> > RegionAdded;
+       sigc::signal<void,boost::shared_ptr<Region> > RegionRemoved;
 
        int region_name (string& result, string base = string(""), bool newlevel = false) const;
        string new_region_name (string);
        string path_from_region_name (string name, string identifier);
 
-       boost::shared_ptr<AudioRegion> find_whole_file_parent (boost::shared_ptr<AudioRegion const>);
+       boost::shared_ptr<Region> find_whole_file_parent (boost::shared_ptr<Region const>);
+       
        void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
 
-       boost::shared_ptr<AudioRegion> XMLRegionFactory (const XMLNode&, bool full);
+       boost::shared_ptr<Region>      XMLRegionFactory (const XMLNode&, bool full);
+       boost::shared_ptr<AudioRegion> XMLAudioRegionFactory (const XMLNode&, bool full);
+       boost::shared_ptr<MidiRegion>  XMLMidiRegionFactory (const XMLNode&, bool full);
 
-       template<class T> void foreach_audio_region (T *obj, void (T::*func)(boost::shared_ptr<AudioRegion>));
+       template<class T> void foreach_region (T *obj, void (T::*func)(boost::shared_ptr<Region>));
 
        /* source management */
 
@@ -563,8 +577,7 @@ class Session : public PBD::StatefulDestructible
            std::vector<Glib::ustring> paths;
            
            /* result */
-           std::vector<boost::shared_ptr<AudioRegion> > new_regions;
-           
+           std::vector<boost::shared_ptr<Region> > new_regions;
        };
 
        int import_audiofile (import_status&);
@@ -576,7 +589,8 @@ class Session : public PBD::StatefulDestructible
 
        int start_audio_export (ARDOUR::AudioExportSpecification&);
        int stop_audio_export (ARDOUR::AudioExportSpecification&);
-       
+       void finalize_audio_export ();
+
        void add_source (boost::shared_ptr<Source>);
        void remove_source (boost::weak_ptr<Source>);
 
@@ -608,7 +622,10 @@ class Session : public PBD::StatefulDestructible
        
        boost::shared_ptr<AudioFileSource> create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive);
 
+       boost::shared_ptr<MidiSource> create_midi_source_for_session (ARDOUR::MidiDiskstream&);
+
        boost::shared_ptr<Source> source_by_id (const PBD::ID&);
+       boost::shared_ptr<Source> source_by_path_and_channel (const Glib::ustring&, uint16_t);
 
        /* playlist management */
 
@@ -632,9 +649,11 @@ class Session : public PBD::StatefulDestructible
        sigc::signal<void> NamedSelectionAdded;
        sigc::signal<void> NamedSelectionRemoved;
 
-        /* Curves and AutomationLists (TODO when they go away) */
-        void add_curve(Curve*);
-        void add_automation_list(AutomationList*);
+       /* Curves and AutomationLists (TODO when they go away) */
+       void add_curve(Curve*);
+       void add_automation_list(AutomationList*);
+       
+       nframes_t automation_interval () const { return _automation_interval; }
 
        /* fade curves */
 
@@ -654,7 +673,7 @@ class Session : public PBD::StatefulDestructible
 
        /* flattening stuff */
 
-       int write_one_audio_track (AudioTrack&, nframes_t start, nframes_t cnt, bool overwrite, vector<boost::shared_ptr<AudioSource> >&,
+       int write_one_audio_track (AudioTrack&, nframes_t start, nframes_t cnt, bool overwrite, vector<boost::shared_ptr<Source> >&,
                                   InterThreadInfo& wot);
        int freeze (InterThreadInfo&);
 
@@ -691,15 +710,15 @@ class Session : public PBD::StatefulDestructible
        
        nframes_t available_capture_duration();
 
-       /* I/O Connections */
+       /* I/O bundles */
 
-       template<class T> void foreach_connection (T *obj, void (T::*func)(Connection *));
-       void add_connection (Connection *);
-       void remove_connection (Connection *);
-       Connection *connection_by_name (string) const;
+       template<class T> void foreach_bundle (T *obj, void (T::*func)(Bundle *));
+       void add_bundle (Bundle *);
+       void remove_bundle (Bundle *);
+       Bundle *bundle_by_name (string) const;
 
-       sigc::signal<void,Connection *> ConnectionAdded;
-       sigc::signal<void,Connection *> ConnectionRemoved;
+       sigc::signal<void,Bundle *> BundleAdded;
+       sigc::signal<void,Bundle *> BundleRemoved;
 
        /* MIDI */
 
@@ -736,6 +755,9 @@ class Session : public PBD::StatefulDestructible
 
        /* History (for editors, mixers, UIs etc.) */
 
+       /** Undo some transactions.
+        * @param n Number of transactions to undo.
+        */
        void undo (uint32_t n) {
                _history.undo (n);
        }
@@ -760,9 +782,9 @@ class Session : public PBD::StatefulDestructible
 
        std::map<PBD::ID, PBD::StatefulThingWithGoingAway*> registry;
 
-        // these commands are implemented in libs/ardour/session_command.cc
+       // these commands are implemented in libs/ardour/session_command.cc
        Command* memento_command_factory(XMLNode* n);
-        void register_with_memento_command_factory(PBD::ID, PBD::StatefulThingWithGoingAway*);
+       void register_with_memento_command_factory(PBD::ID, PBD::StatefulThingWithGoingAway*);
 
        Command* global_state_command_factory (const XMLNode& n);
 
@@ -872,23 +894,10 @@ class Session : public PBD::StatefulDestructible
        void request_play_range (bool yn);
        bool get_play_range () const { return _play_range; }
 
-       /* favorite dirs */
-       typedef vector<string> FavoriteDirs;
-
-       static int read_favorite_dirs (FavoriteDirs&);
-
-       static int write_favorite_dirs (FavoriteDirs&);
-       
-       /* file suffixes */
-
-       static const char* template_suffix() { return _template_suffix; }
-       static const char* statefile_suffix() { return _statefile_suffix; }
-       static const char* pending_suffix() { return _pending_suffix; }
-
        /* buffers for gain and pan */
 
        gain_t* gain_automation_buffer () const { return _gain_automation_buffer; }
-       pan_t** pan_automation_buffer() const { return _pan_automation_buffer; }
+       pan_t** pan_automation_buffer () const  { return _pan_automation_buffer; }
 
        /* buffers for conversion */
        enum RunContext {
@@ -906,23 +915,13 @@ class Session : public PBD::StatefulDestructible
                                  void* ptr,
                                  float opt);
 
-       typedef float (*compute_peak_t)                         (Sample *, nframes_t, float);
-       typedef void  (*apply_gain_to_buffer_t)         (Sample *, nframes_t, float);
-       typedef void  (*mix_buffers_with_gain_t)        (Sample *, Sample *, nframes_t, float);
-       typedef void  (*mix_buffers_no_gain_t)          (Sample *, Sample *, nframes_t);
-
-       static compute_peak_t                   compute_peak;
-       static apply_gain_to_buffer_t   apply_gain_to_buffer;
-       static mix_buffers_with_gain_t  mix_buffers_with_gain;
-       static mix_buffers_no_gain_t    mix_buffers_no_gain;
-
        static sigc::signal<void> SendFeedback;
 
        /* Controllables */
 
-       PBD::Controllable* controllable_by_id (const PBD::ID&);
+       boost::shared_ptr<PBD::Controllable> controllable_by_id (const PBD::ID&);
 
-       void add_controllable (PBD::Controllable*);
+       void add_controllable (boost::shared_ptr<PBD::Controllable>);
        void remove_controllable (PBD::Controllable*);
 
   protected:
@@ -941,14 +940,13 @@ class Session : public PBD::StatefulDestructible
        void update_latency_compensation (bool, bool);
        
   private:
-       int  create (bool& new_session, string* mix_template, nframes_t initial_length);
        void destroy ();
 
-       nframes_t compute_initial_length ();
+       void initialize_start_and_end_locations(nframes_t start, nframes_t end);
+       bool create_session_file();
+       bool create_session_file_from_template (const string& template_path);
 
-       static const char* _template_suffix;
-       static const char* _statefile_suffix;
-       static const char* _pending_suffix;
+       nframes_t compute_initial_length ();
 
        enum SubState {
                PendingDeclickIn   = 0x1,
@@ -967,6 +965,7 @@ class Session : public PBD::StatefulDestructible
 
        AudioEngine            &_engine;
        mutable gint            processing_prohibited;
+       /// the function called when the main JACK process callback happens
        process_function_type    process_function;
        process_function_type    last_process_function;
        bool                     waiting_for_sync_offset;
@@ -981,12 +980,13 @@ class Session : public PBD::StatefulDestructible
        volatile float          _transport_speed;
        volatile float          _desired_transport_speed;
        float                   _last_transport_speed;
+       bool                     auto_play_legal;
        nframes_t          _last_slave_transport_frame;
        nframes_t           maximum_output_latency;
        nframes_t           last_stop_frame;
-       vector<Sample *>        _passthru_buffers;
-       vector<Sample *>        _silent_buffers;
-       vector<Sample *>        _send_buffers;
+       BufferSet*              _scratch_buffers;
+       BufferSet*              _silent_buffers;
+       BufferSet*              _mix_buffers;
        nframes_t           current_block_size;
        nframes_t          _worst_output_latency;
        nframes_t          _worst_input_latency;
@@ -1003,7 +1003,7 @@ class Session : public PBD::StatefulDestructible
 
        void update_latency_compensation_proxy (void* ignored);
 
-       void ensure_passthru_buffers (uint32_t howmany);
+       void ensure_buffers (ChanCount howmany);
        
        void process_scrub          (nframes_t);
        void process_without_events (nframes_t);
@@ -1090,6 +1090,8 @@ class Session : public PBD::StatefulDestructible
        bool                     loop_changing;
        nframes_t           last_loopend;
 
+       boost::scoped_ptr<SessionDirectory>        _session_dir;
+
        RingBuffer<Event*> pending_events;
 
        void hookup_io ();
@@ -1224,7 +1226,7 @@ class Session : public PBD::StatefulDestructible
        void remove_empty_sounds ();
 
        void setup_midi_control ();
-       int  midi_read (MIDI::Port *);
+       //int  midi_read (MIDI::Port *);
 
        void enable_record ();
        
@@ -1250,13 +1252,13 @@ class Session : public PBD::StatefulDestructible
        void *do_work();
 
        void set_next_event ();
-       void process_event (Event *);
+       void process_event (Event *ev);
 
        /* MIDI Machine Control */
 
        void deliver_mmc (MIDI::MachineControl::Command, nframes_t);
-       void deliver_midi_message (MIDI::Port * port, MIDI::eventType ev, MIDI::channel_t, MIDI::EventTwoBytes);
-       void deliver_data (MIDI::Port* port, MIDI::byte*, int32_t size);
+       //void deliver_midi_message (MIDI::Port * port, MIDI::eventType ev, MIDI::channel_t, MIDI::EventTwoBytes);
+       //void deliver_data (MIDI::Port* port, MIDI::byte*, int32_t size);
 
        void spp_start (MIDI::Parser&);
        void spp_continue (MIDI::Parser&);
@@ -1299,22 +1301,16 @@ class Session : public PBD::StatefulDestructible
        nframes_t _smpte_offset;
        bool _smpte_offset_negative;
 
-       /* cache the most-recently requested time conversions.
-          this helps when we have multiple clocks showing the
-          same time (e.g. the transport frame)
-       */
-
-       bool       last_smpte_valid;
-       nframes_t  last_smpte_when;
-       SMPTE::Time last_smpte;
-
-       int send_full_time_code ();
-       int send_midi_time_code ();
+       /* cache the most-recently requested time conversions. This helps when we
+        * have multiple clocks showing the same time (e.g. the transport frame) */
+       bool           last_smpte_valid;
+       nframes_t last_smpte_when;
+       SMPTE::Time    last_smpte;
+       
+       bool _send_smpte_update; ///< Flag to send a full frame (SMPTE) MTC message this cycle
 
-       void send_full_time_code_in_another_thread ();
-       void send_midi_time_code_in_another_thread ();
-       void send_time_code_in_another_thread (bool full);
-       void send_mmc_in_another_thread (MIDI::MachineControl::Command, nframes_t frame = 0);
+       int send_full_time_code(nframes_t nframes);
+       int send_midi_time_code_for_cycle(nframes_t nframes);
 
        nframes_t adjust_apparent_position (nframes_t frames);
        
@@ -1369,17 +1365,8 @@ class Session : public PBD::StatefulDestructible
            static MultiAllocSingleReleasePool pool;
        };
 
-       Glib::Mutex       midi_lock;
-       pthread_t       midi_thread;
-       int             midi_request_pipe[2];
        mutable  gint   butler_active;
-       RingBuffer<MIDIRequest*> midi_requests;
-
-       int           start_midi_thread ();
-       void          terminate_midi_thread ();
-       void          poke_midi_thread ();
-       static void *_midi_thread_work (void *arg);
-       void          midi_thread_work ();
+       
        void          change_midi_ports ();
        int           use_config_midi_ports ();
 
@@ -1387,7 +1374,7 @@ class Session : public PBD::StatefulDestructible
 
        void set_play_loop (bool yn);
        void overwrite_some_buffers (Diskstream*);
-       void flush_all_redirects ();
+       void flush_all_inserts ();
        void locate (nframes_t, bool with_roll, bool with_flush, bool with_loop=false);
        void start_locate (nframes_t, bool with_roll, bool with_flush, bool with_loop=false);
        void force_locate (nframes_t frame, bool with_roll = false);
@@ -1451,8 +1438,8 @@ class Session : public PBD::StatefulDestructible
        /* REGION MANAGEMENT */
 
        mutable Glib::Mutex region_lock;
-       typedef map<PBD::ID,boost::shared_ptr<AudioRegion> > AudioRegionList;
-       AudioRegionList audio_regions;
+       typedef map<PBD::ID,boost::shared_ptr<Region> > RegionList;
+       RegionList regions;
        
        void add_region (boost::shared_ptr<Region>);
        void region_changed (Change, boost::weak_ptr<Region>);
@@ -1462,10 +1449,10 @@ class Session : public PBD::StatefulDestructible
 
        /* SOURCES */
        
-       mutable Glib::Mutex audio_source_lock;
-       typedef std::map<PBD::ID,boost::shared_ptr<AudioSource> > AudioSourceList;
+       mutable Glib::Mutex source_lock;
+       typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap;
 
-       AudioSourceList audio_sources;
+       SourceMap sources;
 
        int load_sources (const XMLNode& node);
        XMLNode& get_sources_as_xml ();
@@ -1501,9 +1488,9 @@ class Session : public PBD::StatefulDestructible
        NamedSelection *named_selection_factory (string name);
        NamedSelection *XMLNamedSelectionFactory (const XMLNode&);
 
-        /* CURVES and AUTOMATION LISTS */
-        std::map<PBD::ID, Curve*> curves;
-        std::map<PBD::ID, AutomationList*> automation_lists;
+       /* CURVES and AUTOMATION LISTS */
+       std::map<PBD::ID, Curve*> curves;
+       std::map<PBD::ID, AutomationList*> automation_lists;
 
        /* DEFAULT FADE CURVES */
 
@@ -1534,8 +1521,8 @@ class Session : public PBD::StatefulDestructible
        uint32_t          insert_cnt;
 
 
-       void add_redirect (Redirect *);
-       void remove_redirect (Redirect *);
+       void add_processor (Processor *);
+       void remove_processor (Processor *);
 
        /* S/W RAID */
 
@@ -1560,16 +1547,9 @@ class Session : public PBD::StatefulDestructible
        vector<space_and_path>::iterator last_rr_session_dir;
        uint32_t _total_free_4k_blocks;
        Glib::Mutex space_lock;
-
-       static const char* old_sound_dir_name;
-       static const char* sound_dir_name;
-       static const char* dead_sound_dir_name;
-       static const char* interchange_dir_name;
-       static const char* peak_dir_name;
-       static const char* export_dir_name;
-
-       string discover_best_sound_dir (bool destructive = false);
-       int ensure_sound_dir (string, string&);
+       
+       string old_sound_dir (bool with_path = true) const;
+       string get_best_session_directory_for_new_source ();
        void refresh_disk_space ();
 
        mutable gint _playback_load;
@@ -1577,12 +1557,12 @@ class Session : public PBD::StatefulDestructible
        mutable gint _playback_load_min;
        mutable gint _capture_load_min;
 
-       /* I/O Connections */
+       /* I/O bundles */
 
-       typedef list<Connection *> ConnectionList;
-       mutable Glib::Mutex connection_lock;
-       ConnectionList _connections;
-       int load_connections (const XMLNode&);
+       typedef list<Bundle *> BundleList;
+       mutable Glib::Mutex bundle_lock;
+       BundleList  _bundles;
+       int load_bundles (const XMLNode&);
 
        void reverse_diskstream_buffers ();
 
@@ -1601,6 +1581,7 @@ class Session : public PBD::StatefulDestructible
 
        void jack_timebase_callback (jack_transport_state_t, nframes_t, jack_position_t*, int);
        int  jack_sync_callback (jack_transport_state_t, jack_position_t*);
+       void reset_jack_connection (jack_client_t* jack);
        void record_enable_change_all (bool yn);
 
        XMLNode& state(bool);
@@ -1669,6 +1650,8 @@ class Session : public PBD::StatefulDestructible
        void allocate_pan_automation_buffers (nframes_t nframes, uint32_t howmany, bool force);
        uint32_t _npan_buffers;
 
+       nframes_t _automation_interval;
+
        /* VST support */
 
        long _vst_callback (VSTPlugin*,
@@ -1678,7 +1661,7 @@ class Session : public PBD::StatefulDestructible
                            void* ptr,
                            float opt);
 
-       /* number of hardware audio ports we're using,
+       /* number of hardware ports we're using,
           based on max (requested,available)
        */
 
@@ -1693,7 +1676,7 @@ class Session : public PBD::StatefulDestructible
        LayerModel layer_model;
        CrossfadeModel xfade_model;
 
-       typedef std::set<PBD::Controllable*> Controllables;
+       typedef std::set<boost::shared_ptr<PBD::Controllable> > Controllables;
        Glib::Mutex controllables_lock;
        Controllables controllables;