libardour API to exercise get_port_property

This commit is contained in:
Robin Gareus 2015-03-08 17:24:53 +01:00
parent 0f736feee0
commit f89123b28b
4 changed files with 41 additions and 0 deletions

View 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 */

View 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 */

View 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 ()
{

View 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
{