Better reporting of errors in Butler::prepare. v2.13.125
authorCarl Hetherington <cth@carlh.net>
Thu, 7 Mar 2019 00:58:43 +0000 (00:58 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 7 Mar 2019 00:58:53 +0000 (00:58 +0000)
src/lib/butler.cc
src/lib/butler.h
src/lib/signal_manager.h

index 444090fd46d1b047fe31acfd6b6f4dec5e32dd2f..cf39945b646ddfed1ee63a5c85804795785899d8 100644 (file)
@@ -268,7 +268,8 @@ Butler::seek_unlocked (DCPTime position, bool accurate)
 }
 
 void
-Butler::prepare (weak_ptr<PlayerVideo> weak_video) const
+Butler::prepare (weak_ptr<PlayerVideo> weak_video)
+try
 {
        shared_ptr<PlayerVideo> video = weak_video.lock ();
        /* If the weak_ptr cannot be locked the video obviously no longer requires any work */
@@ -278,6 +279,12 @@ Butler::prepare (weak_ptr<PlayerVideo> weak_video) const
                LOG_TIMING("finish-prepare in %1", thread_id());
        }
 }
+catch (...)
+{
+       store_current ();
+       boost::mutex::scoped_lock lm (_mutex);
+       _died = true;
+}
 
 void
 Butler::video (shared_ptr<PlayerVideo> video, DCPTime time)
index f1b86a1ab14aa9a3fa390fac16dc00a1b5958cb4..8c4d30efefbad224ce47731c353791511296160d 100644 (file)
@@ -68,7 +68,7 @@ private:
        void audio (boost::shared_ptr<AudioBuffers> audio, DCPTime time, int frame_rate);
        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 prepare (boost::weak_ptr<PlayerVideo> video);
        void player_change (ChangeType type, bool frequent);
        void seek_unlocked (DCPTime position, bool accurate);
 
index e3a66c1c6d5a56842b04cbc26471549ab9187aea..6ba4a94560b50cd79783a8b5d3e414c344f2f5fe 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef DCPOMATIC_SIGNAL_MANAGER_H
 #define DCPOMATIC_SIGNAL_MANAGER_H
 
+#include "exception_store.h"
 #include <boost/asio.hpp>
 #include <boost/thread.hpp>
 #include <boost/noncopyable.hpp>
@@ -30,7 +31,7 @@ class Signaller;
 /** A class to allow signals to be emitted from non-UI threads and handled
  *  by a UI thread.
  */
-class SignalManager : public boost::noncopyable
+class SignalManager : public boost::noncopyable, public ExceptionStore
 {
 public:
        /** Create a SignalManager.  Must be called from the UI thread */
@@ -72,7 +73,11 @@ private:
        void emit (T f) {
                if (boost::this_thread::get_id() == _ui_thread) {
                        /* already in the UI thread */
-                       f ();
+                       try {
+                               f ();
+                       } catch (...) {
+                               store_current ();
+                       }
                } else {
                        /* non-UI thread; post to the service and wake up the UI */
                        _service.post (f);