Check port names for uniqueness

master
Peter Nelson 2010-01-25 21:32:59 +00:00
parent 8b8e5e4e97
commit 5753b1f6ff
4 changed files with 23 additions and 0 deletions

View File

@ -10,6 +10,7 @@ pkg_check_modules(JACK jack>=0.118)
SET(SOURCES
client.cpp
client.h
cvbase.cpp
cvbase.h
cvin.cpp
cvin.h

12
cvbase.cpp 100644
View File

@ -0,0 +1,12 @@
#include <cstring>
#include "cvbase.h"
bool CVBase::find(const char *name) const
{
MappingList::const_iterator it;
for (it = m_mapping_list.begin(); it != m_mapping_list.end(); ++it) {
const Mapping *m = &(*it);
if (!strcmp(m->name.c_str(), name)) return true;
}
return false;
}

View File

@ -22,6 +22,8 @@ public:
m_mapping_list.push_back(m);
}
bool find(const char *name) const;
void stop()
{
close();

View File

@ -89,12 +89,20 @@ bool read_config(const char *filename)
std::clog << line << ": MIDI channel " << channel << " must be between -1 and 15." << std::endl;
continue;
}
if (cvout.find(name)) {
std::clog << line << ": Name '" << name << "' already defined." << std::endl;
continue;
}
cvout.add_mapping(Mapping(name, channel, itype, ccmsb, cclsb, mrl, mru, crl, cru, latency, has_lsb));
} else if (!strcmp(dir, "cvin")) {
if (channel < 0 || channel > 15) {
std::clog << line << ": MIDI channel " << channel << " must be between 0 and 15." << std::endl;
continue;
}
if (cvin.find(name)) {
std::clog << line << ": Name '" << name << "' already defined." << std::endl;
continue;
}
cvin.add_mapping(Mapping(name, channel, itype, ccmsb, cclsb, mrl, mru, crl, cru, latency, has_lsb));
}
}