X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fmidi_device.h;h=a9f33d65c6516d835d909f3fa2407fa200b115c6;hb=2f20f863e6b334d300d69cc41ff93170199b2491;hp=9c76d18b9d1a667c18cf2111f9fc36d4ac63ee80;hpb=873c8b204ab70622f6e231556cc94d3aab1889ce;p=nageru diff --git a/shared/midi_device.h b/shared/midi_device.h index 9c76d18..a9f33d6 100644 --- a/shared/midi_device.h +++ b/shared/midi_device.h @@ -28,11 +28,24 @@ public: class MIDIDevice { public: + struct LightKey { + enum { NOTE, CONTROLLER } type; + unsigned number; + + bool operator< (const LightKey& other) const + { + if (type != other.type) { + return type < other.type; + } + return number < other.number; + } + }; + MIDIDevice(MIDIReceiver *receiver); ~MIDIDevice(); void start_thread(); - void update_lights(const std::map &active_lights) + void update_lights(const std::map &active_lights) { std::lock_guard lock(mu); update_lights_lock_held(active_lights); @@ -42,7 +55,7 @@ private: void thread_func(); void handle_event(snd_seq_t *seq, snd_seq_event_t *event); void subscribe_to_port_lock_held(snd_seq_t *seq, const snd_seq_addr_t &addr); - void update_lights_lock_held(const std::map &active_lights); + void update_lights_lock_held(const std::map &active_lights); std::atomic should_quit{false}; int should_quit_fd; @@ -51,7 +64,7 @@ private: MIDIReceiver *receiver; // Under . std::thread midi_thread; - std::map current_light_status; // Keyed by note number. Under . + std::map current_light_status; // Keyed by note number. Under . snd_seq_t *alsa_seq{nullptr}; // Under . int alsa_queue_id{-1}; // Under . std::atomic num_subscribed_ports{0};