(merge from 2.0-ongoing -r1911:1912) fix audio clock handling of key press; fix crash...
[ardour.git] / libs / ardour / ardour / route.h
index d1db818e4004c1d29a755a7b6b1458e0436e235f..34fa7b5463313e88752d47a9c002f77cc1018dda 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,14 +87,14 @@ 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() { return false; }
        virtual void set_record_enable (bool yn, void *src) {}
@@ -121,12 +120,10 @@ 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);
-
-       void set_phase_invert (bool yn, void *src);
-       bool phase_invert() const { return _phase_invert; }
        
        void       set_edit_group (RouteGroup *, void *);
        void       drop_edit_group (void *);
@@ -161,21 +158,28 @@ class Route : public IO
                }
        }
        
-       uint32_t max_redirect_outs () const { return redirect_max_outs; }
-               
+       ChanCount max_redirect_outs () const { return redirect_max_outs; }
+       
+       // FIXME: remove/replace err_streams parameters with something appropriate
+       // they are used by 'wierd_plugin_dialog'(sic) to display the number of input streams
+       // at the insertion point if the insert fails
        int add_redirect (boost::shared_ptr<Redirect>, void *src, uint32_t* err_streams = 0);
        int add_redirects (const RedirectList&, void *src, uint32_t* err_streams = 0);
        int remove_redirect (boost::shared_ptr<Redirect>, void *src, uint32_t* err_streams = 0);
        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 disable_redirects (Placement);
+       void disable_redirects ();
+       void disable_plugins (Placement);
+       void disable_plugins ();
+       void ab_plugins (bool forward);
+       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 +196,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;
@@ -204,12 +206,10 @@ class Route : public IO
        int set_state(const XMLNode& node);
        virtual XMLNode& get_template();
 
-       sigc::signal<void,void*> SelectedChanged;
-
-       /* undo */
+       XMLNode& get_redirect_state ();
+       int set_redirect_state (const XMLNode&);
 
-       UndoAction get_memento() const;
-       void set_state (state_id_t);
+       sigc::signal<void,void*> SelectedChanged;
 
        int set_control_outs (const vector<std::string>& ports);
        IO* control_outs() { return _control_outs; }
@@ -223,7 +223,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 +239,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 +250,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,9 +263,7 @@ 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;
        bool                     _active : 1;
        bool                     _mute_affects_pre_fader : 1;
@@ -284,11 +281,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,34 +298,49 @@ 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,
+       virtual void process_output_buffers (BufferSet& bufs,
+                                    nframes_t start_frame, nframes_t end_frame,
+                                    nframes_t nframes, nframes_t offset, bool with_redirects, int declick,
                                     bool meter);
 
   protected:
-       /* for derived classes */
 
        virtual XMLNode& state(bool);
 
-       void silence (jack_nframes_t nframes, jack_nframes_t offset);
+       void passthru_silence (nframes_t start_frame, nframes_t end_frame,
+                              nframes_t nframes, nframes_t offset, int declick,
+                              bool meter);
+       
+       void silence (nframes_t nframes, nframes_t offset);
+       
        sigc::connection input_signal_connection;
 
-       state_id_t _current_state_id;
-       uint32_t redirect_max_outs;
+       ChanCount redirect_max_outs;
        uint32_t _remote_control_id;
 
        uint32_t pans_required() const;
-       uint32_t n_process_buffers ();
+       ChanCount 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);