X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fmidi_device.h;h=5b1c3ade4c4ea8c884f9b131f5caa735b082268c;hb=f61426b86c37f873a52f0440537df8f9a35562a4;hp=a9f33d65c6516d835d909f3fa2407fa200b115c6;hpb=f1a8ab7eb34a89a104093c3931b1d51fcb2684e6;p=nageru diff --git a/shared/midi_device.h b/shared/midi_device.h index a9f33d6..5b1c3ad 100644 --- a/shared/midi_device.h +++ b/shared/midi_device.h @@ -47,7 +47,7 @@ public: void update_lights(const std::map &active_lights) { - std::lock_guard lock(mu); + std::lock_guard lock(mu); update_lights_lock_held(active_lights); } @@ -60,8 +60,10 @@ private: std::atomic should_quit{false}; int should_quit_fd; - mutable std::mutex mu; - MIDIReceiver *receiver; // Under . + // Recursive because the MIDI receiver may update_lights() back while we are sending it stuff. + // TODO: Do we need this anymore after receiver is not under the lock? + mutable std::recursive_mutex mu; + MIDIReceiver *receiver; // _Not_ under ; everything on it should be thread-safe. std::thread midi_thread; std::map current_light_status; // Keyed by note number. Under .