]> git.sesse.net Git - nageru/blobdiff - shared/midi_device.h
Fix a MIDI-related deadlock in the GUI code.
[nageru] / shared / midi_device.h
index a9f33d65c6516d835d909f3fa2407fa200b115c6..ec6bf9b5a160b5ededf14600744435a96ef0e951 100644 (file)
@@ -47,7 +47,7 @@ public:
 
        void update_lights(const std::map<LightKey, uint8_t> &active_lights)
        {
-               std::lock_guard<std::mutex> lock(mu);
+               std::lock_guard<std::recursive_mutex> lock(mu);
                update_lights_lock_held(active_lights);
        }
 
@@ -60,7 +60,7 @@ private:
        std::atomic<bool> should_quit{false};
        int should_quit_fd;
 
-       mutable std::mutex mu;
+       mutable std::recursive_mutex mu;  // Recursive because the MIDI receiver may update_lights() back while we are sending it stuff.
        MIDIReceiver *receiver;  // Under <mu>.
 
        std::thread midi_thread;