Now that notify_length_changed() just calls
[ardour.git] / libs / ardour / ardour / session.h
index 004ff41f8326f8316d403387c2e7bbae1aa8ad96..2ef4960b8ef15aa4a7179bbbe2060a14bb69ecce 100644 (file)
 #include <glibmm/thread.h>
 
 #include "pbd/error.h"
+#include "pbd/event_loop.h"
 #include "pbd/rcu.h"
 #include "pbd/statefuldestructible.h"
 #include "pbd/signals.h"
 #include "pbd/undo.h"
 
+#include "evoral/types.hpp"
+
 #include "midi++/types.h"
 
 #include "timecode/time.h"
 
 #include "ardour/ardour.h"
-#include "ardour/click.h"
 #include "ardour/chan_count.h"
 #include "ardour/rc_configuration.h"
 #include "ardour/session_configuration.h"
 #include "ardour/session_event.h"
 #include "ardour/location.h"
 #include "ardour/interpolation.h"
-#include "ardour/speakers.h"
+#include "ardour/route_graph.h"
 
 #ifdef HAVE_JACK_SESSION
 #include <jack/session.h>
@@ -62,7 +64,8 @@
 
 class XMLTree;
 class XMLNode;
-class AEffect;
+struct _AEffect;
+typedef struct _AEffect AEffect;
 
 namespace MIDI {
        class Port;
@@ -92,16 +95,18 @@ class AuxInput;
 class BufferSet;
 class Bundle;
 class Butler;
+class Click;
 class Diskstream;
 class ExportHandler;
 class ExportStatus;
+class Graph;
 class IO;
 class IOProcessor;
 class ImportStatus;
+class MidiControlUI;
 class MidiRegion;
 class MidiSource;
 class MidiTrack;
-class MidiControlUI;
 class NamedSelection;
 class Playlist;
 class PluginInsert;
@@ -122,9 +127,8 @@ class Slave;
 class Source;
 class Speakers;
 class TempoMap;
-class VSTPlugin;
-class Graph;
 class Track;
+class WindowsVSTPlugin;
 
 extern void setup_enum_writer ();
 
@@ -234,10 +238,13 @@ 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;
        bool route_name_internal (std::string) const;
@@ -288,8 +295,18 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        PBD::Signal0<void> Located;
 
        PBD::Signal1<void,RouteList&> RouteAdded;
-       /** Emitted when anything about any of our route groups changes */
-       PBD::Signal0<void> RouteGroupChanged;
+       /** Emitted when a property of one of our route groups changes.
+        *  The parameter is the RouteGroup that has changed.
+        */
+       PBD::Signal1<void, RouteGroup *> RouteGroupPropertyChanged;
+       /** Emitted when a route is added to one of our route groups.
+        *  First parameter is the RouteGroup, second is the route.
+        */
+       PBD::Signal2<void, RouteGroup *, boost::weak_ptr<Route> > RouteAddedToRouteGroup;
+       /** Emitted when a route is removed from one of our route groups.
+        *  First parameter is the RouteGroup, second is the route.
+        */
+       PBD::Signal2<void, RouteGroup *, boost::weak_ptr<Route> > RouteRemovedFromRouteGroup;
 
        /* Step Editing status changed */
        PBD::Signal1<void,bool> StepEditStatusChange;
@@ -371,9 +388,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void remove_state (std::string snapshot_name);
        void rename_state (std::string old_name, std::string new_name);
        void remove_pending_capture_state ();
-
-       static int rename_template (std::string old_name, std::string new_name);
-       static int delete_template (std::string name);
+       int rename (const std::string&);
 
        PBD::Signal1<void,std::string> StateSaved;
        PBD::Signal0<void> StateReady;
@@ -608,6 +623,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        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_solo_isolated (boost::shared_ptr<RouteList>, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
+       void set_exclusive_input_active (boost::shared_ptr<Route> rt, bool others_on);
+       void set_monitoring (boost::shared_ptr<RouteList>, MonitorChoice, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false);
 
        PBD::Signal1<void,bool> SoloActive;
        PBD::Signal0<void> SoloChanged;
@@ -722,13 +739,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
+               );
+                       
        static PBD::Signal0<void> SendFeedback;
 
        /* Speakers */
@@ -801,6 +820,17 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        std::list<std::string> unknown_processors () const;
 
+       /** Emitted when a feedback cycle has been detected within Ardour's signal
+           processing path.  Until it is fixed (by the user) some (unspecified)
+           routes will not be run.
+       */
+       static PBD::Signal0<void> FeedbackDetected;
+
+       /** Emitted when a graph sort has successfully completed, which means
+           that it has no feedback cycles.
+       */
+       static PBD::Signal0<void> SuccessfulGraphSort;
+
        /* handlers can return an integer value:
           0: config.set_audio_search_path() or config.set_midi_search_path() was used
           to modify the search path and we should try to find it again.
@@ -882,6 +912,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        bool                    _writable;
        bool                    _was_seamless;
 
+       void initialize_latencies ();
        void set_worst_io_latencies ();
        void set_worst_playback_latency ();
        void set_worst_capture_latency ();
@@ -950,18 +981,6 @@ 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);
 
-       bool get_rec_monitors_input () {
-               if (actively_recording()) {
-                       return true;
-               } else {
-                       if (config.get_auto_input()) {
-                               return false;
-                       } else {
-                               return true;
-                       }
-               }
-       }
-
        int get_transport_declick_required () {
                if (transport_sub_state & PendingDeclickIn) {
                        transport_sub_state &= ~PendingDeclickIn;
@@ -1192,7 +1211,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        /* routes stuff */
 
-       boost::shared_ptr<Graph> route_graph;
+       boost::shared_ptr<Graph> _process_graph;
 
        SerializedRCUManager<RouteList>  routes;
 
@@ -1231,7 +1250,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        int load_regions (const XMLNode& node);
        int load_compounds (const XMLNode& node);
 
-       void route_group_changed ();
+       void route_added_to_route_group (RouteGroup *, boost::weak_ptr<Route>);
+       void route_removed_from_route_group (RouteGroup *, boost::weak_ptr<Route>);
+       void route_group_property_changed (RouteGroup *);
 
        /* SOURCES */
 
@@ -1335,8 +1356,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;
@@ -1356,7 +1375,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        XMLNode& state(bool);
 
        /* click track */
-
+       typedef std::list<Click*> Clicks;
        Clicks                 clicks;
        bool                  _clicking;
        boost::shared_ptr<IO> _click_io;
@@ -1392,14 +1411,16 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        boost::shared_ptr<Route> _master_out;
        boost::shared_ptr<Route> _monitor_out;
 
-       /* VST support */
+       /* 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)
@@ -1440,10 +1461,16 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        static int ask_about_playlist_deletion (boost::shared_ptr<Playlist>);
 
        /* realtime "apply to set of routes" operations */
-       SessionEvent* get_rt_event (
-               boost::shared_ptr<RouteList> rl, bool yn,
-               SessionEvent::RTeventCallback after, bool group_override,
-               void (Session::*method) (boost::shared_ptr<RouteList>, bool, bool));
+       template<typename T> SessionEvent*
+               get_rt_event (boost::shared_ptr<RouteList> rl, T targ, SessionEvent::RTeventCallback after, bool group_override,
+                             void (Session::*method) (boost::shared_ptr<RouteList>, T, bool)) {
+               SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0);
+               ev->rt_slot = boost::bind (method, this, rl, targ, group_override);
+               ev->rt_return = after;
+               ev->event_loop = PBD::EventLoop::get_event_loop_for_thread ();
+               
+               return ev;
+       }
 
        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*/ );
@@ -1451,6 +1478,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        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_monitoring (boost::shared_ptr<RouteList>, MonitorChoice, bool group_override);
 
        /** temporary list of Diskstreams used only during load of 2.X sessions */
        std::list<boost::shared_ptr<Diskstream> > _diskstreams_2X;
@@ -1477,6 +1505,11 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
 
        boost::shared_ptr<Speakers> _speakers;
        void load_nested_sources (const XMLNode& node);
+
+       /** The directed graph of routes that is currently being used for audio processing
+           and solo/mute computations.
+       */
+       GraphEdges _current_route_graph;
 };
 
 } // namespace ARDOUR