basics of managing a list of port names for MIDI-input-follows-selection
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 19 Oct 2016 19:12:49 +0000 (15:12 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 19 Oct 2016 21:49:35 +0000 (17:49 -0400)
libs/ardour/ardour/port_manager.h
libs/ardour/port_manager.cc

index 03484c598b9f061afe7d869b4a96eb0a4fe400fd..6433b1bd6d4ceab5b0bf518d51b1d88dac70490d 100644 (file)
@@ -128,6 +128,13 @@ 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 ();
+
        /** Emitted if the backend notifies us of a graph order event */
        PBD::Signal0<void> GraphReordered;
 
@@ -170,6 +177,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;
 };
 
 
index 7a13756daba7639464e84c4422e3b9256fe5e471..d24c929930c25a5c0dcca746cdcff0c7342e8a2d 100644 (file)
@@ -851,3 +851,36 @@ PortManager::port_is_control_only (std::string const& name)
 
        return regexec (&compiled_pattern, name.c_str(), 0, 0, 0) == 0;
 }
+
+void
+PortManager::get_midi_selection_ports (MidiSelectionPorts& copy) const
+{
+       Glib::Threads::Mutex::Lock lm (midi_selection_ports_mutex);
+       copy = _midi_selection_ports;
+}
+
+void
+PortManager::add_to_midi_selection_ports (string const & port)
+{
+       Glib::Threads::Mutex::Lock lm (midi_selection_ports_mutex);
+       if (find (_midi_selection_ports.begin(), _midi_selection_ports.end(), port) == _midi_selection_ports.end()) {
+               _midi_selection_ports.push_back (port);
+       }
+}
+
+void
+PortManager::remove_from_midi_selection_ports (string const & port)
+{
+       Glib::Threads::Mutex::Lock lm (midi_selection_ports_mutex);
+       MidiSelectionPorts::iterator x = find (_midi_selection_ports.begin(), _midi_selection_ports.end(), port);
+       if (x != _midi_selection_ports.end()) {
+               _midi_selection_ports.erase (x);
+       }
+}
+
+void
+PortManager::clear_midi_selection_ports ()
+{
+       Glib::Threads::Mutex::Lock lm (midi_selection_ports_mutex);
+       _midi_selection_ports.clear ();
+}