diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-10-09 00:43:22 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-10-09 00:43:22 +0200 |
| commit | 1580bdc52a257870c908f32d2abe6fed84d83c50 (patch) | |
| tree | de57d49257fd4805b0674b2a041736e0e3b5cb58 /src/lib/film.h | |
| parent | 940b4a72b6242c19570acc7a629ce271de565322 (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 6f1294b29..0c1959056 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> @@ -59,8 +61,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 @@ -74,7 +100,7 @@ public: explicit Film (boost::optional<boost::filesystem::path> dir); ~Film (); - boost::filesystem::path info_file (dcpomatic::DCPTimePeriod p) const; + boost::shared_ptr<InfoFileHandle> info_file_handle (dcpomatic::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 (dcpomatic::DCPTimePeriod p) const; @@ -369,6 +395,8 @@ private: friend struct ::isdcf_name_test; template <typename> friend class ChangeSignaller; + boost::filesystem::path info_file (dcpomatic::DCPTimePeriod p) const; + void signal_change (ChangeType, Property); void signal_change (ChangeType, int); std::string video_identifier () const; @@ -445,6 +473,8 @@ private: */ bool _tolerant; + 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; |
