From 7daf620a8dba0772c51b8034ee917a3a73ea3475 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 21 Jan 2017 18:20:04 +0000 Subject: [PATCH] add some comments --- .../generic_midi/generic_midi_control_protocol.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index 10b52027e8..78e6dd789d 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -341,6 +341,10 @@ GenericMidiControlProtocol::start_learning (Controllable* c) Glib::Threads::Mutex::Lock lm2 (controllables_lock); DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Learn binding: Controlable number: %1\n", c)); + /* drop any existing mappings for the same controllable for which + * learning has just started. + */ + MIDIControllables::iterator tmp; for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) { tmp = i; @@ -352,6 +356,10 @@ GenericMidiControlProtocol::start_learning (Controllable* c) i = tmp; } + /* check pending controllables (those for which a learn is underway) to + * see if it is for the same one for which learning has just started. + */ + { Glib::Threads::Mutex::Lock lm (pending_lock); @@ -386,6 +394,8 @@ GenericMidiControlProtocol::start_learning (Controllable* c) own_mc = true; } + /* stuff the new controllable into pending */ + { Glib::Threads::Mutex::Lock lm (pending_lock); @@ -419,6 +429,10 @@ GenericMidiControlProtocol::learning_stopped (MIDIControllable* mc) i = tmp; } + /* add the controllable for which learning stopped to our list of + * controllables + */ + controllables.push_back (mc); }