Browse Source

Check port names for uniqueness

master
Peter Nelson 12 years ago
parent
commit
5753b1f6ff
  1. 1
      CMakeLists.txt
  2. 12
      cvbase.cpp
  3. 2
      cvbase.h
  4. 8
      jm2cv.cpp

1
CMakeLists.txt

@ -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

@ -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

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

8
jm2cv.cpp

@ -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));
}
}

Loading…
Cancel
Save