]> git.sesse.net Git - nageru/blobdiff - image_input.h
Add the two final missing MIDI mappings, namely buttons for toggling limiter and...
[nageru] / image_input.h
index edc86c8fbbf76ed7562fc93cf340952144ae5cbf..3b3c1873763577c2250a48b883cc214b04620592 100644 (file)
@@ -1,22 +1,43 @@
 #ifndef _IMAGE_INPUT_H
 #define _IMAGE_INPUT_H 1
 
+#include <map>
 #include <memory>
+#include <mutex>
 #include <string>
+#include <thread>
 
-#include <movit/flat_input.h>
+#include <time.h>
 
+#include <movit/flat_input.h>
 
 // An output that takes its input from a static image, loaded with ffmpeg.
-// comes from a single 2D array with chunky pixels.
+// comes from a single 2D array with chunky pixels. The image is refreshed
+// from disk about every second.
 class ImageInput : public movit::FlatInput {
 public:
-       ImageInput(const std::string &filename);
+       ImageInput(const std::string &pathname);
 
        std::string effect_type_id() const override { return "ImageInput"; }
-
+       void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override;
+       static void shutdown_updaters();
+       
 private:
-       std::unique_ptr<uint8_t[]> image_data;
+       struct Image {
+               std::unique_ptr<uint8_t[]> pixels;
+               timespec last_modified;
+       };
+
+       std::string pathname;
+       std::shared_ptr<const Image> current_image;
+
+       static std::shared_ptr<const Image> load_image(const std::string &pathname);
+       static std::shared_ptr<const Image> load_image_raw(const std::string &pathname);
+       static void update_thread_func(const std::string &pathname, const timespec &first_modified);
+       static std::mutex all_images_lock;
+       static std::map<std::string, std::shared_ptr<const Image>> all_images;
+       static std::map<std::string, std::thread> update_threads;
+       static volatile bool threads_should_quit;
 };
 
 #endif // !defined(_IMAGE_INPUT_H)