Introduce global default-fade-shape configuration variable
[ardour.git] / libs / ardour / ardour / port_manager.h
index 5838ac66af8fd5491f6c2567689014f3c499e833..b36e98fe64504526426a5ef8aa179a668a257a5e 100644 (file)
 #include "pbd/rcu.h"
 
 #include "ardour/chan_count.h"
+#include "ardour/midiport_manager.h"
 #include "ardour/port.h"
-#include "ardour/port_engine.h"
 
 namespace ARDOUR {
 
-class PortManager 
+class PortEngine;
+class AudioBackend;
+
+class LIBARDOUR_API PortManager 
 {
   public:
     typedef std::map<std::string,boost::shared_ptr<Port> > Ports;
+    typedef std::list<boost::shared_ptr<Port> > PortList;
     
     PortManager ();
     virtual ~PortManager() {}
 
-    void set_port_engine (PortEngine& pe);
-    PortEngine& port_engine() { return *_impl; }
-    
+    PortEngine& port_engine();
+
+    uint32_t port_name_size() const;
+    std::string my_name() const;
+
     /* Port registration */
     
-    boost::shared_ptr<Port> register_input_port (DataType, const std::string& portname);
-    boost::shared_ptr<Port> register_output_port (DataType, const std::string& portname);
+    boost::shared_ptr<Port> register_input_port (DataType, const std::string& portname, bool async = false);
+    boost::shared_ptr<Port> register_output_port (DataType, const std::string& portname, bool async = false);
     int unregister_port (boost::shared_ptr<Port>);
     
     /* Port connectivity */
@@ -59,7 +65,6 @@ class PortManager
     int  connect (const std::string& source, const std::string& destination);
     int  disconnect (const std::string& source, const std::string& destination);
     int  disconnect (boost::shared_ptr<Port>);
-    bool has_connections (const std::string&);
     int  reestablish_ports ();
     int  reconnect_ports ();
 
@@ -85,7 +90,8 @@ class PortManager
     ChanCount n_physical_inputs () const;
 
     int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&);
-    
+    int get_ports (DataType, PortList&);
+
     void remove_all_ports ();
     
     /* per-Port monitoring */
@@ -115,6 +121,9 @@ class PortManager
 
     bool port_remove_in_progress() const { return _port_remove_in_progress; }
 
+    /** Emitted if the backend notifies us of a graph order event */
+    PBD::Signal0<void> GraphReordered;
+
     /** Emitted if a Port is registered or unregistered */
     PBD::Signal0<void> PortRegisteredOrUnregistered;
     
@@ -126,13 +135,35 @@ class PortManager
     PBD::Signal5<void, boost::weak_ptr<Port>, std::string, boost::weak_ptr<Port>, std::string, bool> PortConnectedOrDisconnected;
 
   protected:
-    boost::shared_ptr<PortEngine> _impl;
+    boost::shared_ptr<AudioBackend> _backend;
     SerializedRCUManager<Ports> ports;
     bool _port_remove_in_progress;
 
-    boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input);
+    boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input, bool async = false);
     void port_registration_failure (const std::string& portname);
+
+    /** List of ports to be used between ::cycle_start() and ::cycle_end()
+     */
+    boost::shared_ptr<Ports> _cycle_ports;
+
+    void fade_out (gain_t, gain_t, pframes_t);
+    void silence (pframes_t nframes);
+    void check_monitoring ();
+    /** Signal the start of an audio cycle.
+     * This MUST be called before any reading/writing for this cycle.
+     * Realtime safe.
+     */
+    void cycle_start (pframes_t nframes);
+       
+    /** Signal the end of an audio cycle.
+     * This signifies that the cycle began with @ref cycle_start has ended.
+     * This MUST be called at the end of each cycle.
+     * Realtime safe.
+     */
+    void cycle_end (pframes_t nframes);
 };
+
+
        
 } // namespace