diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-10-09 00:43:22 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-10-15 11:55:56 +0000 |
| commit | 0e0696155ba56a2c7d4adde87b70bd2739d334f9 (patch) | |
| tree | f3090125cd4ef57eb5e2a1f49c045ee7f64c920b /src/lib/film.h | |
| parent | b6f681b802642ba38625a4d574c0a9e4f630fa3d (diff) | |
Fix cross-thread access to info files. May help with #1618.
Diffstat (limited to 'src/lib/film.h')
| -rw-r--r-- | src/lib/film.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/lib/film.h b/src/lib/film.h index b77ce7a76..e1260f26a 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -36,7 +36,9 @@ #include <dcp/encrypted_kdm.h> #include <boost/signals2.hpp> #include <boost/enable_shared_from_this.hpp> +#include <boost/thread.hpp> #include <boost/filesystem.hpp> +#include <boost/thread/mutex.hpp> #include <string> #include <vector> #include <inttypes.h> @@ -56,8 +58,32 @@ class AudioMapping; class Ratio; class Job; class ScreenKDM; +class Film; struct isdcf_name_test; +class InfoFileHandle +{ +public: + ~InfoFileHandle (); + + FILE* get () const { + return _handle; + } + + boost::filesystem::path file () const { + return _file; + } + +private: + friend class Film; + + InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read); + + boost::mutex::scoped_lock _lock; + FILE* _handle; + boost::filesystem::path _file; +}; + /** @class Film * * @brief A representation of some audio and video content, and details of @@ -71,7 +97,7 @@ public: explicit Film (boost::optional<boost::filesystem::path> dir); ~Film (); - boost::filesystem::path info_file (DCPTimePeriod p) const; + boost::shared_ptr<InfoFileHandle> info_file_handle (DCPTimePeriod period, bool read) const; boost::filesystem::path j2c_path (int, Frame, Eyes, bool) const; boost::filesystem::path internal_video_asset_dir () const; boost::filesystem::path internal_video_asset_filename (DCPTimePeriod p) const; @@ -345,6 +371,8 @@ private: friend struct ::isdcf_name_test; template <typename> friend class ChangeSignaller; + boost::filesystem::path info_file (DCPTimePeriod p) const; + void signal_change (ChangeType, Property); void signal_change (ChangeType, int); std::string video_identifier () const; @@ -415,6 +443,8 @@ private: boost::shared_ptr<Film> _template_film; + mutable boost::mutex _info_file_mutex; + boost::signals2::scoped_connection _playlist_change_connection; boost::signals2::scoped_connection _playlist_order_changed_connection; boost::signals2::scoped_connection _playlist_content_change_connection; |
