summaryrefslogtreecommitdiff
path: root/libs/backends/alsa/alsa_audiobackend.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-26 02:26:20 +0200
committerRobin Gareus <robin@gareus.org>2016-04-26 02:26:20 +0200
commit2169de3975e8276233e2640391c8b526ec9e97fd (patch)
treed97f83aa87ce7e46567cc0519251e59df03295db /libs/backends/alsa/alsa_audiobackend.cc
parent11a69068af7b5ea182996a2ddba15f5131aa003b (diff)
keep portmap & portindex in sync when renaming ports
Fixes crash on session re-load (introduced in 800c8182 and fde99e68)
Diffstat (limited to 'libs/backends/alsa/alsa_audiobackend.cc')
-rw-r--r--libs/backends/alsa/alsa_audiobackend.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc
index 8f8eaa75a3..a3ba3f36c4 100644
--- a/libs/backends/alsa/alsa_audiobackend.cc
+++ b/libs/backends/alsa/alsa_audiobackend.cc
@@ -1210,11 +1210,20 @@ AlsaAudioBackend::port_name_size () const
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