X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=image_input.h;h=02be497ff40e2dccee5f569a5be2e1e98a6ae4c5;hp=659404ea7c5954a191aeda2faf72e3ef774544e7;hb=703e00da89118df9be0354dda621bed023e6030e;hpb=7017a3bd997cbf5d7c327187afecfecd610bf24d diff --git a/image_input.h b/image_input.h index 659404e..02be497 100644 --- a/image_input.h +++ b/image_input.h @@ -1,16 +1,18 @@ #ifndef _IMAGE_INPUT_H #define _IMAGE_INPUT_H 1 +#include +#include +#include +#include +#include +#include #include #include #include #include #include -#include - -#include - // An output that takes its input from a static image, loaded with ffmpeg. // comes from a single 2D array with chunky pixels. The image is refreshed // from disk about every second. @@ -24,20 +26,24 @@ public: private: struct Image { + unsigned width, height; std::unique_ptr pixels; timespec last_modified; }; - std::string filename; + std::string filename, pathname; std::shared_ptr current_image; - static std::shared_ptr load_image(const std::string &filename); - static std::shared_ptr load_image_raw(const std::string &filename); - static void update_thread_func(const std::string &filename, const timespec &first_modified); + static std::shared_ptr load_image(const std::string &filename, const std::string &pathname); + static std::shared_ptr load_image_raw(const std::string &pathname); + static void update_thread_func(const std::string &filename, const std::string &pathname, const timespec &first_modified); static std::mutex all_images_lock; static std::map> all_images; static std::map update_threads; - static volatile bool threads_should_quit; + + static std::mutex threads_should_quit_mu; + static bool threads_should_quit; // Under threads_should_quit_mu. + static std::condition_variable threads_should_quit_modified; // Signals when threads_should_quit is set. }; #endif // !defined(_IMAGE_INPUT_H)