Protect the public API of Player with a mutex, since
[dcpomatic.git] / src / lib / player.h
index 223db86b3d442e7cd7540d0c60442d1e426570bc..4a91c4c529011434800afc2ed899397db2c6b3bd 100644 (file)
@@ -73,6 +73,7 @@ public:
        std::list<boost::shared_ptr<Font> > get_subtitle_fonts ();
        std::list<ReferencedReelAsset> get_reel_assets ();
        dcp::Size video_container_size () const {
+               boost::mutex::scoped_lock lm (_mutex);
                return _video_container_size;
        }
 
@@ -141,6 +142,12 @@ private:
        void do_emit_video (boost::shared_ptr<PlayerVideo> pv, DCPTime time);
        void emit_audio (boost::shared_ptr<AudioBuffers> data, DCPTime time);
 
+       /** Mutex to protect the whole Player state.  When it's used for the preview we have
+           seek() and pass() called from the Butler thread and lots of other stuff called
+           from the GUI thread.
+       */
+       mutable boost::mutex _mutex;
+
        boost::shared_ptr<const Film> _film;
        boost::shared_ptr<const Playlist> _playlist;