infrastructure for MIDI-input-follows-selection
[ardour.git] / libs / ardour / ardour / port_manager.h
index 4678c5231aa5af8ae6f3f4da12cb77d1b244f3a4..7cc1125bcc5fa76689365d31973bb60fb9cddcde 100644 (file)
@@ -30,6 +30,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include "pbd/rcu.h"
+#include "pbd/ringbuffer.h"
 
 #include "ardour/chan_count.h"
 #include "ardour/midiport_manager.h"
@@ -39,6 +40,7 @@ namespace ARDOUR {
 
 class PortEngine;
 class AudioBackend;
+class Session;
 
 class LIBARDOUR_API PortManager
 {
@@ -56,8 +58,8 @@ class LIBARDOUR_API PortManager
 
        /* Port registration */
 
-       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);
+       boost::shared_ptr<Port> register_input_port (DataType, const std::string& portname, bool async = false, PortFlags extra_flags = PortFlags (0));
+       boost::shared_ptr<Port> register_output_port (DataType, const std::string& portname, bool async = false, PortFlags extra_flags = PortFlags (0));
        int unregister_port (boost::shared_ptr<Port>);
 
        /* Port connectivity */
@@ -80,7 +82,8 @@ class LIBARDOUR_API PortManager
        std::string             make_port_name_non_relative (const std::string& name) const;
        std::string             get_pretty_name_by_name (const std::string& portname) const;
        bool                    port_is_mine (const std::string& fullname) const;
-       bool                    port_name_prefix_is_unique (const std::string& first_part_of_port_name) const;
+
+       static bool port_is_control_only (std::string const &);
 
        /* other Port management */
 
@@ -94,6 +97,9 @@ class LIBARDOUR_API PortManager
        int get_ports (DataType, PortList&);
 
        void remove_all_ports ();
+       void clear_pending_port_deletions ();
+       virtual void add_pending_port_deletion (Port*) = 0;
+       RingBuffer<Port*>& port_deletions_pending () { return _port_deletions_pending; }
 
        /* per-Port monitoring */
 
@@ -122,6 +128,17 @@ class LIBARDOUR_API PortManager
 
        bool port_remove_in_progress() const { return _port_remove_in_progress; }
 
+       typedef std::vector<std::string> MidiSelectionPorts;
+
+       void get_midi_selection_ports (MidiSelectionPorts&) const;
+       void add_to_midi_selection_ports (std::string const&);
+       void remove_from_midi_selection_ports (std::string const&);
+       void clear_midi_selection_ports ();
+       bool port_is_for_midi_selection (std::string const&);
+
+       /** Emitted if the list of ports to be used for MIDI selection tracking changes */
+       PBD::Signal0<void> MidiSelectionPortsChanged;
+
        /** Emitted if the backend notifies us of a graph order event */
        PBD::Signal0<void> GraphReordered;
 
@@ -139,8 +156,9 @@ class LIBARDOUR_API PortManager
        boost::shared_ptr<AudioBackend> _backend;
        SerializedRCUManager<Ports> ports;
        bool _port_remove_in_progress;
+       RingBuffer<Port*> _port_deletions_pending;
 
-       boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input, bool async = false);
+       boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input, bool async = false, PortFlags extra_flags = PortFlags (0));
        void port_registration_failure (const std::string& portname);
 
        /** List of ports to be used between ::cycle_start() and ::cycle_end()
@@ -148,7 +166,7 @@ class LIBARDOUR_API PortManager
        boost::shared_ptr<Ports> _cycle_ports;
 
        void fade_out (gain_t, gain_t, pframes_t);
-       void silence (pframes_t nframes);
+       void silence (pframes_t nframes, Session *s = 0);
        void silence_outputs (pframes_t nframes);
        void check_monitoring ();
        /** Signal the start of an audio cycle.
@@ -163,6 +181,9 @@ class LIBARDOUR_API PortManager
         * Realtime safe.
         */
        void cycle_end (pframes_t nframes);
+
+       mutable Glib::Threads::Mutex midi_selection_ports_mutex;
+       MidiSelectionPorts _midi_selection_ports;
 };