From 25674c1e6a66715286f7f9a5116fdf3baff1c738 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 30 Dec 2013 21:46:10 +0000 Subject: Comment and slightly tidy ExceptionStore. --- src/lib/encoder.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/lib/encoder.cc') diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index eff38b6a5..ca75e4ca1 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -199,9 +199,7 @@ Encoder::process_video (shared_ptr image, Eyes eyes, ColourConversi return; } - if (_writer->thrown ()) { - _writer->rethrow (); - } + _writer->rethrow (); if (_writer->can_fake_write (_video_frames_out)) { _writer->fake_write (_video_frames_out, eyes); -- cgit v1.2.3 From f87a0f16f8cee026ee33c3a46b93b43d4b3cf5ff Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 30 Dec 2013 23:01:54 +0000 Subject: Catch exceptions from Encoder threads. --- src/lib/encoder.cc | 11 ++++++++++- src/lib/encoder.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/lib/encoder.cc') diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index ca75e4ca1..b78bcaeea 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -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 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 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 server) _condition.notify_all (); } } +catch (...) +{ + store_current (); +} void Encoder::server_found (ServerDescription s) diff --git a/src/lib/encoder.h b/src/lib/encoder.h index d43e4e1d3..079174f89 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -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 f, boost::weak_ptr); -- cgit v1.2.3