From f89123b28b38cf51193e3dce0bbf9f88fe8de868 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 8 Mar 2015 17:24:53 +0100 Subject: [PATCH] libardour API to exercise get_port_property --- libs/ardour/ardour/port.h | 3 +++ libs/ardour/ardour/port_manager.h | 1 + libs/ardour/port.cc | 20 ++++++++++++++++++++ libs/ardour/port_manager.cc | 17 +++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 6a05314843..97f8a4e778 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -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 */ diff --git a/libs/ardour/ardour/port_manager.h b/libs/ardour/ardour/port_manager.h index b36e98fe64..6ced0e7dd1 100644 --- a/libs/ardour/ardour/port_manager.h +++ b/libs/ardour/ardour/port_manager.h @@ -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 */ diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index 8e9db708a8..3252134ac3 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -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 () { diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc index a8d8da0067..de78dfd319 100644 --- a/libs/ardour/port_manager.cc +++ b/libs/ardour/port_manager.cc @@ -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 {