]> git.sesse.net Git - nageru/blobdiff - futatabi/midi_mapper.h
Log a warning when we kill a client that is not keeping up.
[nageru] / futatabi / midi_mapper.h
index fd16089c55e6ff7329b68f454e5c8ffeedab32b5..84ff404b1f0b956830a475f4cf18318680a5e461 100644 (file)
@@ -31,6 +31,7 @@ public:
        virtual void preview() = 0;
        virtual void queue() = 0;
        virtual void play() = 0;
+       virtual void next() = 0;
        virtual void toggle_lock() = 0;
        virtual void jog(int delta) = 0;
        virtual void switch_camera(unsigned camera_idx) = 0;
@@ -45,6 +46,13 @@ public:
 
 class MIDIMapper : public MIDIReceiver {
 public:
+       // Converts conveniently from a bool.
+       enum LightState {
+               Off = 0,
+               On = 1,
+               Blinking = 2
+       };
+
        MIDIMapper(ControllerReceiver *receiver);
        virtual ~MIDIMapper();
        void set_midi_mapping(const MIDIMappingProto &new_mapping);
@@ -56,7 +64,7 @@ public:
 
        void refresh_lights();
 
-       void set_preview_enabled(bool enabled) {
+       void set_preview_enabled(LightState enabled) {
                preview_enabled_light = enabled;
                refresh_lights();
        }
@@ -64,11 +72,15 @@ public:
                queue_enabled_light = enabled;
                refresh_lights();
        }
-       void set_play_enabled(bool enabled) {
+       void set_play_enabled(LightState enabled) {
                play_enabled_light = enabled;
                refresh_lights();
        }
-       void set_locked(bool locked) {
+       void set_next_ready(LightState enabled) {
+               next_ready_light = enabled;
+               refresh_lights();
+       }
+       void set_locked(LightState locked) {
                locked_light = locked;
                refresh_lights();
        }
@@ -76,6 +88,10 @@ public:
                current_highlighted_camera = stream_idx;
                refresh_lights();
        }
+       void set_speed_light(float speed) {  // Goes from 0.0 to 2.0.
+               current_speed = speed;
+               refresh_lights();
+       }
 
        // MIDIReceiver.
        void controller_received(int controller, int value) override;
@@ -91,7 +107,6 @@ private:
        void update_lights_lock_held();
 
        std::atomic<bool> should_quit{false};
-       int should_quit_fd;
 
        mutable std::mutex mu;
        ControllerReceiver *receiver;  // Under <mu>.
@@ -99,11 +114,13 @@ private:
        int num_controller_banks;  // Under <mu>.
        std::atomic<int> current_controller_bank{0};
 
-       std::atomic<bool> preview_enabled_light{false};
+       std::atomic<LightState> preview_enabled_light{Off};
        std::atomic<bool> queue_enabled_light{false};
-       std::atomic<bool> play_enabled_light{false};
-       std::atomic<bool> locked_light{true};
+       std::atomic<LightState> play_enabled_light{Off};
+       std::atomic<LightState> next_ready_light{Off};
+       std::atomic<LightState> locked_light{On};
        std::atomic<int> current_highlighted_camera{-1};
+       std::atomic<float> current_speed{1.0f};
 
        MIDIDevice midi_device;
 };