Make the set_state() function respect redirects already present on the route. Still...
[ardour.git] / libs / ardour / ardour / route.h
index 8271c1cf6ab02b3abe20cd791bb235f73b786c91..9bdd2cbca5c4b0df8e9966a9231b435fb5907a1d 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_route_h__
@@ -35,6 +34,7 @@
 #include <pbd/undo.h>
 #include <pbd/stateful.h> 
 #include <pbd/controllable.h>
+#include <pbd/destructible.h>
 
 #include <ardour/ardour.h>
 #include <ardour/io.h>
@@ -71,15 +71,14 @@ class Route : public IO
 
        Route (Session&, std::string name, int input_min, int input_max, int output_min, int output_max,
               Flag flags = Flag(0), DataType default_type = DataType::AUDIO);
-       
-       Route (Session&, const XMLNode&);
+       Route (Session&, const XMLNode&, DataType default_type = DataType::AUDIO);
        virtual ~Route();
 
        std::string comment() { return _comment; }
        void set_comment (std::string str, void *src);
 
-       long order_key(std::string name) const;
-       void set_order_key (std::string name, long n);
+       long order_key (const char* name) const;
+       void set_order_key (const char* name, long n);
 
        bool hidden() const { return _flags & Hidden; }
        bool master() const { return _flags & MasterOut; }
@@ -88,16 +87,16 @@ class Route : public IO
        /* these are the core of the API of a Route. see the protected sections as well */
 
 
-       virtual int  roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
-                          jack_nframes_t offset, int declick, bool can_record, bool rec_monitors_input);
+       virtual int  roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
+                          nframes_t offset, int declick, bool can_record, bool rec_monitors_input);
 
-       virtual int  no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
-                             jack_nframes_t offset, bool state_changing, bool can_record, bool rec_monitors_input);
+       virtual int  no_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
+                             nframes_t offset, bool state_changing, bool can_record, bool rec_monitors_input);
 
-       virtual int  silent_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, 
-                                 jack_nframes_t offset, bool can_record, bool rec_monitors_input);
+       virtual int  silent_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, 
+                                 nframes_t offset, bool can_record, bool rec_monitors_input);
        virtual void toggle_monitor_input ();
-       virtual bool can_record() const { return false; }
+       virtual bool can_record() { return false; }
        virtual void set_record_enable (bool yn, void *src) {}
        virtual bool record_enabled() const { return false; }
        virtual void handle_transport_stopped (bool abort, bool did_locate, bool flush_redirects);
@@ -121,6 +120,7 @@ class Route : public IO
 
        void set_mute (bool yn, void *src);
        bool muted() const { return _muted; }
+       bool solo_muted() const { return desired_solo_gain == 0.0; }
 
        void set_mute_config (mute_type, bool, void *src);
        bool get_mute_config (mute_type);
@@ -169,13 +169,13 @@ class Route : public IO
        int copy_redirects (const Route&, Placement, uint32_t* err_streams = 0);
        int sort_redirects (uint32_t* err_streams = 0);
 
-       void clear_redirects (void *src);
+       void clear_redirects (Placement, void *src);
        void all_redirects_flip();
-       void all_redirects_active (bool state);
+       void all_redirects_active (Placement, bool state);
 
-       virtual jack_nframes_t update_total_latency();
-       jack_nframes_t signal_latency() const { return _own_latency; }
-       virtual void set_latency_delay (jack_nframes_t);
+       virtual nframes_t update_total_latency();
+       nframes_t signal_latency() const { return _own_latency; }
+       virtual void set_latency_delay (nframes_t);
 
        sigc::signal<void,void*> solo_changed;
        sigc::signal<void,void*> solo_safe_changed;
@@ -192,8 +192,6 @@ class Route : public IO
        sigc::signal<void>       active_changed;
        sigc::signal<void,void*> meter_change;
 
-       sigc::signal<void> GoingAway;
-
        /* gui's call this for their own purposes. */
 
        sigc::signal<void,std::string,void*> gui_changed;
@@ -206,11 +204,6 @@ class Route : public IO
 
        sigc::signal<void,void*> SelectedChanged;
 
-       /* undo */
-
-       UndoAction get_memento() const;
-       void set_state (state_id_t);
-
        int set_control_outs (const vector<std::string>& ports);
        IO* control_outs() { return _control_outs; }
 
@@ -223,7 +216,7 @@ class Route : public IO
                    SoloControl
            };
            
-           ToggleControllable (Route&, ToggleType);
+           ToggleControllable (std::string name, Route&, ToggleType);
            void set_value (float);
            float get_value (void) const;
 
@@ -239,8 +232,7 @@ class Route : public IO
                return _mute_control;
        }
        
-       void automation_snapshot (jack_nframes_t now);
-
+       void automation_snapshot (nframes_t now);
        void protect_automation ();
        
        void set_remote_control_id (uint32_t id);
@@ -251,12 +243,12 @@ class Route : public IO
        friend class Session;
 
        void set_solo_mute (bool yn);
-       void set_block_size (jack_nframes_t nframes);
+       void set_block_size (nframes_t nframes);
        bool has_external_redirects() const;
        void curve_reallocate ();
 
   protected:
-       unsigned char _flags;
+       Flag _flags;
 
        /* tight cache-line access here is more important than sheer speed of
           access.
@@ -264,7 +256,6 @@ class Route : public IO
 
        bool                     _muted : 1;
        bool                     _soloed : 1;
-       bool                     _solo_muted : 1;
        bool                     _solo_safe : 1;
        bool                     _phase_invert : 1;
        bool                     _recordable : 1;
@@ -284,11 +275,11 @@ class Route : public IO
        gain_t                    desired_solo_gain;
        gain_t                    desired_mute_gain;
 
-       jack_nframes_t            check_initial_delay (jack_nframes_t, jack_nframes_t&, jack_nframes_t&);
+       nframes_t            check_initial_delay (nframes_t, nframes_t&, nframes_t&);
 
-       jack_nframes_t           _initial_delay;
-       jack_nframes_t           _roll_delay;
-       jack_nframes_t           _own_latency;
+       nframes_t           _initial_delay;
+       nframes_t           _roll_delay;
+       nframes_t           _own_latency;
        RedirectList             _redirects;
        Glib::RWLock      redirect_lock;
        IO                      *_control_outs;
@@ -301,12 +292,12 @@ class Route : public IO
        ToggleControllable _solo_control;
        ToggleControllable _mute_control;
        
-       void passthru (jack_nframes_t start_frame, jack_nframes_t end_frame, 
-                      jack_nframes_t nframes, jack_nframes_t offset, int declick, bool meter_inputs);
+       void passthru (nframes_t start_frame, nframes_t end_frame, 
+                      nframes_t nframes, nframes_t offset, int declick, bool meter_inputs);
 
        void process_output_buffers (vector<Sample*>& bufs, uint32_t nbufs,
-                                    jack_nframes_t start_frame, jack_nframes_t end_frame,
-                                    jack_nframes_t nframes, jack_nframes_t offset, bool with_redirects, int declick,
+                                    nframes_t start_frame, nframes_t end_frame,
+                                    nframes_t nframes, nframes_t offset, bool with_redirects, int declick,
                                     bool meter);
 
   protected:
@@ -314,21 +305,32 @@ class Route : public IO
 
        virtual XMLNode& state(bool);
 
-       void silence (jack_nframes_t nframes, jack_nframes_t offset);
+       void silence (nframes_t nframes, nframes_t offset);
        sigc::connection input_signal_connection;
 
-       state_id_t _current_state_id;
        uint32_t redirect_max_outs;
        uint32_t _remote_control_id;
 
        uint32_t pans_required() const;
        uint32_t n_process_buffers ();
 
+       virtual int  _set_state (const XMLNode&, bool call_base);
+       virtual void _set_redirect_states (const XMLNodeList&);
+
   private:
        void init ();
 
        static uint32_t order_key_cnt;
-       typedef std::map<std::string,long> OrderKeys;
+
+       struct ltstr
+       {
+           bool operator()(const char* s1, const char* s2) const
+           {
+                   return strcmp(s1, s2) < 0;
+           }
+       };
+
+       typedef std::map<const char*,long,ltstr> OrderKeys;
        OrderKeys order_keys;
 
        void input_change_handler (IOChange, void *src);