Store mtime in Content.
[dcpomatic.git] / src / lib / butler.h
index a61011f4019fa1ddcc5e6e01f184a9e9011a3fb0..b10c93e7984c5a581615d73ac6ab959a86074c1c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "video_ring_buffers.h"
 #include "audio_ring_buffers.h"
+#include "text_ring_buffers.h"
 #include "audio_mapping.h"
 #include "exception_store.h"
 #include <boost/shared_ptr.hpp>
@@ -41,7 +42,8 @@ public:
 
        void seek (DCPTime position, bool accurate);
        std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video ();
-       bool get_audio (float* out, Frame frames);
+       boost::optional<DCPTime> get_audio (float* out, Frame frames);
+       boost::optional<std::pair<PlayerText, DCPTimePeriod> > get_closed_caption ();
 
        void disable_audio ();
 
@@ -50,16 +52,26 @@ public:
 private:
        void thread ();
        void video (boost::shared_ptr<PlayerVideo> video, DCPTime time);
-       void audio (boost::shared_ptr<AudioBuffers> audio);
+       void audio (boost::shared_ptr<AudioBuffers> audio, DCPTime time);
+       void text (PlayerText pt, TextType type, DCPTimePeriod period);
        bool should_run () const;
        void prepare (boost::weak_ptr<PlayerVideo> video) const;
+       void player_change (ChangeType type, bool frequent);
+       void seek_unlocked (DCPTime position, bool accurate);
 
        boost::shared_ptr<Player> _player;
        boost::shared_ptr<Log> _log;
        boost::thread* _thread;
 
+       /** mutex to protect _video, _audio and _closed_caption for when we are clearing them and they all need to be
+           cleared together without any data being inserted in the interim;
+           XXX: is this necessary now that all butler output data is timestamped? Perhaps the locked clear-out
+           is only required if we guarantee that get_video() and get_audio() calls are in sync.
+       */
+       boost::mutex _buffers_mutex;
        VideoRingBuffers _video;
        AudioRingBuffers _audio;
+       TextRingBuffers _closed_caption;
 
        boost::thread_group _prepare_pool;
        boost::asio::io_service _prepare_service;
@@ -71,6 +83,7 @@ private:
        boost::condition _arrived;
        boost::optional<DCPTime> _pending_seek_position;
        bool _pending_seek_accurate;
+       int _suspended;
        bool _finished;
        bool _died;
        bool _stop_thread;
@@ -80,6 +93,13 @@ private:
 
        bool _disable_audio;
 
+       /** If we are waiting to be refilled following a seek, this is the time we were
+           seeking to.
+       */
+       boost::optional<DCPTime> _awaiting;
+
        boost::signals2::scoped_connection _player_video_connection;
        boost::signals2::scoped_connection _player_audio_connection;
+       boost::signals2::scoped_connection _player_text_connection;
+       boost::signals2::scoped_connection _player_change_connection;
 };