properly handle integer steps in plugin controls
[ardour.git] / libs / ardour / port_manager.cc
index c7adefc531c7528d8a1bd3eab74ddfe7335201ac..f2f2334c273d59720f632044848c857ec76c0a18 100644 (file)
@@ -108,6 +108,23 @@ PortManager::make_port_name_non_relative (const string& portname) const
        return str;
 }
 
+std::string
+PortManager::get_pretty_name_by_name(const std::string& portname) const
+{
+       PortEngine::PortHandle ph = _backend->get_port_by_name (portname);
+       if (ph) {
+               std::string value;
+               std::string type;
+               if (0 == _backend->get_port_property (ph,
+                                       "http://jackaudio.org/metadata/pretty-name",
+                                       value, type))
+               {
+                       return value;
+               }
+       }
+       return "";
+}
+
 bool
 PortManager::port_is_mine (const string& portname) const
 {
@@ -244,6 +261,8 @@ PortManager::get_ports (DataType type, PortList& pl)
 int
 PortManager::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s)
 {
+       s.clear();
+
        if (!_backend) {
                return 0;
        }
@@ -451,7 +470,7 @@ PortManager::reestablish_ports ()
        for (i = p->begin(); i != p->end(); ++i) {
                if (i->second->reestablish ()) {
                        error << string_compose (_("Re-establising port %1 failed"), i->second->name()) << endmsg;
-                       cerr << string_compose (_("Re-establising port %1 failed"), i->second->name()) << endl;
+                       std::cerr << string_compose (_("Re-establising port %1 failed"), i->second->name()) << std::endl;
                        break;
                }
        }
@@ -621,6 +640,45 @@ PortManager::silence (pframes_t nframes)
        }
 }
 
+void
+PortManager::silence_outputs (pframes_t nframes)
+{
+       std::vector<std::string> port_names;
+       if (get_ports("", DataType::AUDIO, IsOutput, port_names)) {
+               for (std::vector<std::string>::iterator p = port_names.begin(); p != port_names.end(); ++p) {
+                       if (!port_is_mine(*p)) {
+                               continue;
+                       }
+                       PortEngine::PortHandle ph = _backend->get_port_by_name (*p);
+                       if (!ph) {
+                               continue;
+                       }
+                       void *buf = _backend->get_buffer(ph, nframes);
+                       if (!buf) {
+                               continue;
+                       }
+                       memset (buf, 0, sizeof(float) * nframes);
+               }
+       }
+
+       if (get_ports("", DataType::MIDI, IsOutput, port_names)) {
+               for (std::vector<std::string>::iterator p = port_names.begin(); p != port_names.end(); ++p) {
+                       if (!port_is_mine(*p)) {
+                               continue;
+                       }
+                       PortEngine::PortHandle ph = _backend->get_port_by_name (*p);
+                       if (!ph) {
+                               continue;
+                       }
+                       void *buf = _backend->get_buffer(ph, nframes);
+                       if (!buf) {
+                               continue;
+                       }
+                       _backend->midi_clear (buf);
+               }
+       }
+}
+
 void
 PortManager::check_monitoring ()
 {