libardour API to exercise get_port_property
authorRobin Gareus <robin@gareus.org>
Sun, 8 Mar 2015 16:24:53 +0000 (17:24 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 8 Mar 2015 18:02:31 +0000 (19:02 +0100)
libs/ardour/ardour/port.h
libs/ardour/ardour/port_manager.h
libs/ardour/port.cc
libs/ardour/port_manager.cc

index 6a05314843180f077803af2235d68804347c0f6e..97f8a4e77853fa18b49c003af55ac72d2c7a32e1 100644 (file)
@@ -55,6 +55,9 @@ public:
                return _name;
        }
 
+       /** @return Port human readable name */
+       std::string pretty_name (bool fallback_to_name = false) const;
+
        int set_name (std::string const &);
 
        /** @return flags */
index b36e98fe64504526426a5ef8aa179a668a257a5e..6ced0e7dd1d1a222089e4ba146d7b9140ca13f58 100644 (file)
@@ -79,6 +79,7 @@ class LIBARDOUR_API PortManager
     void                    port_renamed (const std::string&, const std::string&);
     std::string             make_port_name_relative (const std::string& name) const;
     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;
 
     /* other Port management */
index 8e9db708a8087a3834f45d5f3cbae371860482a0..3252134ac3d48031153088f54d4cb3ab68eaf3bf 100644 (file)
@@ -83,6 +83,26 @@ Port::~Port ()
        drop ();
 }
 
+
+std::string
+Port::pretty_name(bool fallback_to_name) const
+{
+       if (_port_handle) {
+               std::string value;
+               std::string type;
+               if (0 == port_engine.get_port_property (_port_handle,
+                                       "http://jackaudio.org/metadata/pretty-name",
+                                       value, type))
+               {
+                       return value;
+               }
+       }
+       if (fallback_to_name) {
+               return name ();
+       }
+       return "";
+}
+
 void
 Port::drop ()
 {
index a8d8da00672d117faba964b7e9f18bdce46438ca..de78dfd319b042dc504731f98a2e74489a10d5e3 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
 {