Catch exceptions from Encoder threads.
authorCarl Hetherington <cth@carlh.net>
Mon, 30 Dec 2013 23:01:54 +0000 (23:01 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 30 Dec 2013 23:01:54 +0000 (23:01 +0000)
src/lib/encoder.cc
src/lib/encoder.h

index ca75e4ca1caa7a0c93088f5e2470e3990755a92f..b78bcaeea7081bd12317608ff7e45a09695a18b7 100644 (file)
@@ -96,7 +96,6 @@ Encoder::process_begin ()
        ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
 }
 
-
 void
 Encoder::process_end ()
 {
@@ -200,6 +199,11 @@ Encoder::process_video (shared_ptr<PlayerImage> image, Eyes eyes, ColourConversi
        }
 
        _writer->rethrow ();
+       /* Re-throw any exception raised by one of our threads.  If more
+          than one has thrown an exception, only one will be rethrown, I think;
+          but then, if that happens something has gone badly wrong.
+       */
+       rethrow ();
 
        if (_writer->can_fake_write (_video_frames_out)) {
                _writer->fake_write (_video_frames_out, eyes);
@@ -255,6 +259,7 @@ Encoder::terminate_threads ()
 
 void
 Encoder::encoder_thread (optional<ServerDescription> server)
+try
 {
        /* Number of seconds that we currently wait between attempts
           to connect to the server; not relevant for localhost
@@ -336,6 +341,10 @@ Encoder::encoder_thread (optional<ServerDescription> server)
                _condition.notify_all ();
        }
 }
+catch (...)
+{
+       store_current ();
+}
 
 void
 Encoder::server_found (ServerDescription s)
index d43e4e1d33c7d24833568813a840275894aeea29..079174f89c96be258109ea339d97076261b3bc7e 100644 (file)
@@ -56,7 +56,7 @@ class PlayerImage;
  *  is supplied as uncompressed PCM in blocks of various sizes.
  */
 
-class Encoder : public boost::noncopyable
+class Encoder : public boost::noncopyable, public ExceptionStore
 {
 public:
        Encoder (boost::shared_ptr<const Film> f, boost::weak_ptr<Job>);