#include "ardour/filesystem_paths.h"
#include "ardour/port_manager.h"
#include "ardouralsautil/devicelist.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace ARDOUR;
int
AlsaAudioBackend::set_port_name (PortEngine::PortHandle port, const std::string& name)
{
+ std::string newname (_instance_name + ":" + name);
if (!valid_port (port)) {
- PBD::error << _("AlsaBackend::set_port_name: Invalid Port(s)") << endmsg;
+ PBD::error << _("AlsaBackend::set_port_name: Invalid Port") << endmsg;
return -1;
}
- return static_cast<AlsaPort*>(port)->set_name (_instance_name + ":" + name);
+ if (find_port (newname)) {
+ PBD::error << _("AlsaBackend::set_port_name: Port with given name already exists") << endmsg;
+ return -1;
+ }
+
+ AlsaPort* p = static_cast<AlsaPort*>(port);
+ _portmap.erase (p->name());
+ _portmap.insert (make_pair (newname, p));
+ return p->set_name (newname);
}
std::string
}
}
- for (PortIndex::iterator i = _ports.begin (); i != _ports.end (); ++i) {
+ for (PortIndex::const_iterator i = _ports.begin (); i != _ports.end (); ++i) {
AlsaPort* port = *i;
if ((port->type () == type) && flags == (port->flags () & flags)) {
if (!use_regexp || !regexec (&port_regex, port->name ().c_str (), 0, NULL, 0)) {
return;
}
AlsaPort* port = static_cast<AlsaPort*>(port_handle);
- PortIndex::iterator i = _ports.find (static_cast<AlsaPort*>(port_handle));
+ PortIndex::iterator i = std::find (_ports.begin(), _ports.end(), static_cast<AlsaPort*>(port_handle));
if (i == _ports.end ()) {
PBD::error << _("AlsaBackend::unregister_port: Failed to find port") << endmsg;
return;
{
int n_midi = 0;
int n_audio = 0;
- for (PortIndex::iterator i = _ports.begin (); i != _ports.end (); ++i) {
+ for (PortIndex::const_iterator i = _ports.begin (); i != _ports.end (); ++i) {
AlsaPort* port = *i;
if (port->is_output () && port->is_physical ()) {
switch (port->type ()) {
{
int n_midi = 0;
int n_audio = 0;
- for (PortIndex::iterator i = _ports.begin (); i != _ports.end (); ++i) {
+ for (PortIndex::const_iterator i = _ports.begin (); i != _ports.end (); ++i) {
AlsaPort* port = *i;
if (port->is_input () && port->is_physical ()) {
switch (port->type ()) {