Add API to query hardware port name

In case of internal backends this allows to retrieve the
Device name for a given (hashed unique) port-name.

As opposed to "pretty-name" (which defaults to hw-port-name),
this cannot be changed by the user.

It is intended to be used when probing for control surfaces.
This commit is contained in:
Robin Gareus 2023-05-02 23:35:31 +02:00
parent 2bdf51e02d
commit 287a21c09e
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 27 additions and 0 deletions

View file

@ -160,6 +160,7 @@ public:
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;
std::string get_hardware_port_name_by_name (const std::string& portname) const;
std::string short_port_name_from_port_name (std::string const& full_name) const;
bool port_is_mine (const std::string& fullname) const;

View file

@ -616,6 +616,12 @@ PortEngineSharedImpl::get_port_property (PortEngine::PortHandle port, const std:
return 0;
}
}
if (key == "http://ardour.org/metadata/hardware-port-name") {
value = std::static_pointer_cast<BackendPort>(port)->hw_port_name ();
if (!value.empty()) {
return 0;
}
}
return -1;
}

View file

@ -355,6 +355,26 @@ PortManager::get_pretty_name_by_name (const std::string& portname) const
return string ();
}
std::string
PortManager::get_hardware_port_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://ardour.org/metadata/hardware-port-name", value, type)) {
return value;
} else {
return short_port_name_from_port_name (portname);
}
}
return string ();
}
bool
PortManager::port_is_mine (const string& portname) const
{