radically rethink export/bounce/freeze code design. probably not 100% done by freeze...
[ardour.git] / libs / ardour / ardour / session.h
index fd607cd6f67e704f40a017b97149d2fd4a051593..adb000c615383a1e2eb2ce062aa3c40307d76f63 100644 (file)
@@ -51,6 +51,8 @@
 
 #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"
@@ -64,7 +66,8 @@
 
 class XMLTree;
 class XMLNode;
-class AEffect;
+struct _AEffect;
+typedef struct _AEffect AEffect;
 
 namespace MIDI {
        class Port;
@@ -83,6 +86,7 @@ namespace Evoral {
 
 namespace ARDOUR {
 
+class Amp;
 class AudioEngine;
 class AudioFileSource;
 class AudioRegion;
@@ -102,6 +106,7 @@ class Graph;
 class IO;
 class IOProcessor;
 class ImportStatus;
+class MidiClockTicker;
 class MidiControlUI;
 class MidiRegion;
 class MidiSource;
@@ -109,6 +114,7 @@ class MidiTrack;
 class NamedSelection;
 class Playlist;
 class PluginInsert;
+class PluginInfo;
 class Port;
 class PortInsert;
 class ProcessThread;
@@ -127,7 +133,7 @@ class Source;
 class Speakers;
 class TempoMap;
 class Track;
-class VSTPlugin;
+class WindowsVSTPlugin;
 
 extern void setup_enum_writer ();
 
@@ -178,9 +184,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        int ensure_subdirs ();
 
-       std::string automation_dir () const;
-       std::string analysis_dir() const;
-       std::string plugins_dir() const;
+       std::string automation_dir () const;  ///< Automation data
+       std::string analysis_dir () const;    ///< Analysis data
+       std::string plugins_dir () const;     ///< Plugin state
+       std::string externals_dir () const;   ///< Links to external files
 
        std::string peak_path (std::string) const;
 
@@ -237,10 +244,12 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
        template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
 
+       static char session_name_is_legal (const std::string&);
        bool io_name_is_legal (const std::string&);
        boost::shared_ptr<Route> route_by_name (std::string);
        boost::shared_ptr<Route> route_by_id (PBD::ID);
        boost::shared_ptr<Route> route_by_remote_id (uint32_t id);
+       boost::shared_ptr<Track> track_by_diskstream_id (PBD::ID);
        void routes_using_input_from (const std::string& str, RouteList& rl);
 
        bool route_name_unique (std::string) const;
@@ -366,8 +375,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void set_auto_loop_location (Location *);
        int location_name(std::string& result, std::string base = std::string(""));
 
-       void reset_input_monitor_state ();
-
        pframes_t get_block_size()        const { return current_block_size; }
        framecnt_t worst_output_latency () const { return _worst_output_latency; }
        framecnt_t worst_input_latency ()  const { return _worst_input_latency; }
@@ -387,9 +394,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void remove_pending_capture_state ();
        int rename (const std::string&);
 
-       static int rename_template (std::string old_name, std::string new_name);
-       static int delete_template (std::string name);
-
        PBD::Signal1<void,std::string> StateSaved;
        PBD::Signal0<void> StateReady;
 
@@ -453,7 +457,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                );
 
        std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
-               TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = ""
+               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 = ""
                );
 
        void   remove_route (boost::shared_ptr<Route>);
@@ -514,9 +520,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        TempoMap& tempo_map() { return *_tempo_map; }
 
-       /// signals the current transport position in frames, bbt and timecode time (in that order)
-       PBD::Signal3<void, const framepos_t &, const Timecode::BBT_Time&, const Timecode::Time&> tick;
-
        /* region info  */
 
        boost::shared_ptr<Region> find_whole_file_parent (boost::shared_ptr<Region const>) const;
@@ -605,8 +608,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 */
@@ -619,6 +622,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        void set_solo (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
        void set_just_one_solo (boost::shared_ptr<Route>, bool, SessionEvent::RTeventCallback after = rt_cleanup);
+       void cancel_solo_after_disconnect (boost::shared_ptr<Route>, bool upstream, SessionEvent::RTeventCallback after = rt_cleanup);
        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);
@@ -630,7 +634,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        PBD::Signal0<void> SoloChanged;
        PBD::Signal0<void> IsolatedChanged;
 
-       /* control/master out */
+       /* monitor/master out */
+
+       void add_monitor_section ();
+       void remove_monitor_section ();
 
        boost::shared_ptr<Route> monitor_out() const { return _monitor_out; }
        boost::shared_ptr<Route> master_out() const { return _master_out; }
@@ -640,6 +647,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void globally_set_send_gains_to_zero (boost::shared_ptr<Route> dest);
        void globally_set_send_gains_to_unity (boost::shared_ptr<Route> dest);
        void add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost::shared_ptr<RouteList> senders);
+       void add_internal_send (boost::shared_ptr<Route>, int, boost::shared_ptr<Route>);
+       void add_internal_send (boost::shared_ptr<Route>, boost::shared_ptr<Processor>, boost::shared_ptr<Route>);
 
        static void set_disable_all_loaded_plugins (bool yn) {
                _disable_all_loaded_plugins = yn;
@@ -649,12 +658,15 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        }
 
        uint32_t next_send_id();
+       uint32_t next_aux_send_id();
        uint32_t next_return_id();
        uint32_t next_insert_id();
        void mark_send_id (uint32_t);
+       void mark_aux_send_id (uint32_t);
        void mark_return_id (uint32_t);
        void mark_insert_id (uint32_t);
        void unmark_send_id (uint32_t);
+       void unmark_aux_send_id (uint32_t);
        void unmark_return_id (uint32_t);
        void unmark_insert_id (uint32_t);
 
@@ -719,6 +731,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* clicking */
 
        boost::shared_ptr<IO> click_io() { return _click_io; }
+       boost::shared_ptr<Amp> click_gain() { return _click_gain; }
 
        /* disk, buffer loads */
 
@@ -739,22 +752,15 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* VST support */
 
-       static long vst_callback (AEffect* effect,
-                       long opcode,
-                       long index,
-                       long value,
-                       void* ptr,
-                       float opt);
+       static intptr_t vst_callback (
+               AEffect* effect,
+               int32_t opcode,
+               int32_t index,
+               intptr_t value,
+               void* ptr,
+               float opt
+               );
                        
-       /*Native linuxVST support*/
-       
-       static intptr_t lxvst_callback (AEffect* effect,
-                                 int32_t opcode,
-                                 int32_t index,
-                                 intptr_t value,
-                                 void* ptr,
-                                 float opt);
-
        static PBD::Signal0<void> SendFeedback;
 
        /* Speakers */
@@ -944,9 +950,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void unblock_processing() { g_atomic_int_set (&processing_prohibited, 0); }
        bool processing_blocked() const { return g_atomic_int_get (&processing_prohibited); }
 
-       Glib::Mutex                process_thread_lock;
-       std::list<ProcessThread*>  process_threads;
-
        /* slave tracking */
 
        static const int delta_accumulator_size = 25;
@@ -981,6 +984,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;
 
@@ -1181,7 +1185,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        MidiControlUI* midi_control_ui;
 
        int           start_midi_thread ();
-       void          terminate_midi_thread ();
 
        void set_play_loop (bool yn);
        void unset_play_loop ();
@@ -1222,7 +1225,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);
@@ -1323,6 +1326,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* INSERT AND SEND MANAGEMENT */
 
        boost::dynamic_bitset<uint32_t> send_bitset;
+       boost::dynamic_bitset<uint32_t> aux_send_bitset;
        boost::dynamic_bitset<uint32_t> return_bitset;
        boost::dynamic_bitset<uint32_t> insert_bitset;
 
@@ -1363,8 +1367,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        XMLNode* _bundle_xml_node;
        int load_bundles (XMLNode const &);
 
-       void reverse_track_buffers ();
-
        UndoHistory      _history;
        /** current undo transaction, or 0 */
        UndoTransaction* _current_trans;
@@ -1385,14 +1387,15 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* click track */
        typedef std::list<Click*> Clicks;
-       Clicks                 clicks;
-       bool                  _clicking;
-       boost::shared_ptr<IO> _click_io;
-       Sample*                click_data;
-       Sample*                click_emphasis_data;
-       framecnt_t             click_length;
-       framecnt_t             click_emphasis_length;
-       mutable Glib::RWLock   click_lock;
+       Clicks                  clicks;
+       bool                   _clicking;
+       boost::shared_ptr<IO>  _click_io;
+       boost::shared_ptr<Amp> _click_gain;
+       Sample*                 click_data;
+       Sample*                 click_emphasis_data;
+       framecnt_t              click_length;
+       framecnt_t              click_emphasis_length;
+       mutable Glib::RWLock    click_lock;
 
        static const Sample     default_click[];
        static const framecnt_t default_click_length;
@@ -1400,6 +1403,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        static const framecnt_t default_click_emphasis_length;
 
        Click *get_click();
+       framepos_t _clicks_cleared;
        void   setup_click_sounds (int which);
        void   setup_click_sounds (Sample**, Sample const *, framecnt_t*, framecnt_t, std::string const &);
        void   clear_clicks ();
@@ -1420,14 +1424,18 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        boost::shared_ptr<Route> _master_out;
        boost::shared_ptr<Route> _monitor_out;
 
-       /* VST support */
+       void auto_connect_master_bus ();
+
+       /* Windows VST support */
 
-       long _vst_callback (VSTPlugin*,
-                       long opcode,
-                       long index,
-                       long value,
-                       void* ptr,
-                       float opt);
+       long _windows_vst_callback (
+               WindowsVSTPlugin*,
+               long opcode,
+               long index,
+               long value,
+               void* ptr,
+               float opt
+               );
 
        /* number of hardware ports we're using,
           based on max (requested,available)
@@ -1479,6 +1487,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                return ev;
        }
 
+       void rt_cancel_solo_after_disconnect (boost::shared_ptr<RouteList>, bool upstream, bool /* ignored*/ );
        void rt_set_solo (boost::shared_ptr<RouteList>, bool yn, bool group_override);
        void rt_set_just_one_solo (boost::shared_ptr<RouteList>, bool yn, bool /* ignored*/ );
        void rt_set_mute (boost::shared_ptr<RouteList>, bool yn, bool group_override);
@@ -1517,6 +1526,11 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
            and solo/mute computations.
        */
        GraphEdges _current_route_graph;
+
+       uint32_t next_control_id () const;
+       bool ignore_route_processor_changes;
+
+       MidiClockTicker* midi_clock;
 };
 
 } // namespace ARDOUR