Check port names for uniqueness
This commit is contained in:
@@ -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
Normal file
12
cvbase.cpp
Normal 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;
|
||||
}
|
2
cvbase.h
2
cvbase.h
@@ -22,6 +22,8 @@ public:
|
||||
m_mapping_list.push_back(m);
|
||||
}
|
||||
|
||||
bool find(const char *name) const;
|
||||
|
||||
void stop()
|
||||
{
|
||||
close();
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user