Don't start thread in constructor. (Writer)
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Sep 2015 20:05:25 +0000 (21:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Sep 2015 20:05:25 +0000 (21:05 +0100)
src/lib/transcoder.cc
src/lib/writer.cc
src/lib/writer.h

index 27e35ac528b37f0609f915be2d6ffb15ae309a5c..4e8932268634ed6fe3f1fe0bb873bb1417a09023 100644 (file)
@@ -62,6 +62,7 @@ Transcoder::Transcoder (shared_ptr<const Film> film, shared_ptr<Job> j)
 void
 Transcoder::go ()
 {
 void
 Transcoder::go ()
 {
+       _writer->start ();
        _encoder->begin ();
 
        DCPTime const frame = DCPTime::from_frames (1, _film->video_frame_rate ());
        _encoder->begin ();
 
        DCPTime const frame = DCPTime::from_frames (1, _film->video_frame_rate ());
index 9c4a194e806f02677f4caf4d76155aa2c79e0b09..0e15edeca0e8bbffdad0c5e09ce199faadaf7102 100644 (file)
@@ -148,12 +148,11 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
        }
 
        job->sub (_("Encoding image data"));
        }
 
        job->sub (_("Encoding image data"));
+}
 
 
-       /* Do this last; if something after this line were to throw an exception
-          (say if Job::sub was interrupted by cancel) this thread would never
-          get properly cleaned up but the Writer object would go away underneath
-          it.
-       */
+void
+Writer::start ()
+{
        _thread = new boost::thread (boost::bind (&Writer::thread, this));
 }
 
        _thread = new boost::thread (boost::bind (&Writer::thread, this));
 }
 
index be1d3f69ea623c935f40ad687008181bf5290865..cec6ba527b07a49f98ddcf4765e450c1a6ab4ae5 100644 (file)
@@ -97,6 +97,8 @@ public:
        Writer (boost::shared_ptr<const Film>, boost::weak_ptr<Job>);
        ~Writer ();
 
        Writer (boost::shared_ptr<const Film>, boost::weak_ptr<Job>);
        ~Writer ();
 
+       void start ();
+
        bool can_fake_write (int) const;
 
        void write (Data, int, Eyes);
        bool can_fake_write (int) const;
 
        void write (Data, int, Eyes);