Handle butler thread exceptions properly.
[dcpomatic.git] / src / lib / butler.h
index e02351b0fd45fbfa608b20f263b3c94b57dce6f1..101677558ab8128360d053548648a048e7b997b4 100644 (file)
@@ -19,6 +19,9 @@
 */
 
 #include "video_ring_buffers.h"
+#include "audio_ring_buffers.h"
+#include "audio_mapping.h"
+#include "exception_store.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <boost/thread.hpp>
@@ -29,18 +32,20 @@ class Film;
 class Player;
 class PlayerVideo;
 
-class Butler : public boost::noncopyable
+class Butler : public ExceptionStore, public boost::noncopyable
 {
 public:
-       Butler (boost::weak_ptr<const Film> film, boost::shared_ptr<Player> player);
+       Butler (boost::weak_ptr<const Film> film, boost::shared_ptr<Player> player, AudioMapping map, int audio_channels);
        ~Butler ();
 
        void seek (DCPTime position, bool accurate);
        std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video ();
+       void get_audio (float* out, Frame frames);
 
 private:
        void thread ();
        void video (boost::shared_ptr<PlayerVideo> video, DCPTime time);
+       void audio (boost::shared_ptr<AudioBuffers> audio, DCPTime time);
        void player_changed ();
 
        boost::weak_ptr<const Film> _film;
@@ -48,6 +53,7 @@ private:
        boost::thread* _thread;
 
        VideoRingBuffers _video;
+       AudioRingBuffers _audio;
 
        boost::mutex _mutex;
        boost::condition _summon;
@@ -57,6 +63,12 @@ private:
 
        bool _finished;
 
+       AudioMapping _audio_mapping;
+       int _audio_channels;
+
+       bool _stop_thread;
+
        boost::signals2::scoped_connection _player_video_connection;
+       boost::signals2::scoped_connection _player_audio_connection;
        boost::signals2::scoped_connection _player_changed_connection;
 };