swaroop: take ownership of config file if we're run as root.
[dcpomatic.git] / src / lib / butler.h
index a8b38ef2e83075e71464a426ff4e574b91467357..fb133d10809413298364faba4e02a8d62c42c5b1 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>
@@ -40,8 +41,15 @@ public:
        ~Butler ();
 
        void seek (DCPTime position, bool accurate);
-       std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video ();
-       bool get_audio (float* out, Frame frames);
+
+       enum Error {
+               NONE,
+               AGAIN
+       };
+
+       std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video (Error* e = 0);
+       boost::optional<DCPTime> get_audio (float* out, Frame frames);
+       boost::optional<TextRingBuffers::Data> get_closed_caption ();
 
        void disable_audio ();
 
@@ -50,22 +58,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, boost::optional<DCPTextTrack> track, DCPTimePeriod period);
        bool should_run () const;
        void prepare (boost::weak_ptr<PlayerVideo> video) const;
-       void player_changed (int);
+       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 and _audio for when we are clearing them and they both need to be
-           cleared together without any data being inserted in the interim.
+       /** 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 _video_audio_mutex;
+       boost::mutex _buffers_mutex;
        VideoRingBuffers _video;
        AudioRingBuffers _audio;
+       TextRingBuffers _closed_caption;
 
        boost::thread_group _prepare_pool;
        boost::asio::io_service _prepare_service;
@@ -77,6 +89,7 @@ private:
        boost::condition _arrived;
        boost::optional<DCPTime> _pending_seek_position;
        bool _pending_seek_accurate;
+       int _suspended;
        bool _finished;
        bool _died;
        bool _stop_thread;
@@ -93,5 +106,6 @@ private:
 
        boost::signals2::scoped_connection _player_video_connection;
        boost::signals2::scoped_connection _player_audio_connection;
-       boost::signals2::scoped_connection _player_changed_connection;
+       boost::signals2::scoped_connection _player_text_connection;
+       boost::signals2::scoped_connection _player_change_connection;
 };