summaryrefslogtreecommitdiff
path: root/src/midimapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/midimapper.cc')
-rw-r--r--src/midimapper.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc
index 05f69e5..ab3d8d7 100644
--- a/src/midimapper.cc
+++ b/src/midimapper.cc
@@ -28,20 +28,26 @@
int MidiMapper::lookup(int note)
{
+ std::lock_guard<std::mutex> guard(mutex);
+
if(midimap.find(note) == midimap.end())
{
return -1;
}
- std::string instr = midimap[note];
+
+ const std::string& instr = midimap[note];
if(instrmap.find(instr) == instrmap.end())
{
return -1;
}
+
return instrmap[instr];
}
-void MidiMapper::clear()
+void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap)
{
- midimap.clear();
- instrmap.clear();
+ std::lock_guard<std::mutex> guard(mutex);
+
+ std::swap(this->instrmap, instrmap);
+ std::swap(this->midimap, midimap);
}