Fix crash due to static initialisation order nastiness.
authorCarl Hetherington <cth@carlh.net>
Fri, 24 Apr 2015 21:26:13 +0000 (22:26 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 24 Apr 2015 21:26:13 +0000 (22:26 +0100)
src/lib/writer.cc
src/lib/writer.h

index 4270a42a7684a76f2f64a34392e26e28bffb501f..8d73b31267a368f768598a9e3e5ab1343f024bef 100644 (file)
@@ -71,8 +71,6 @@ using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 
-int const Writer::_maximum_frames_in_memory = Config::instance()->num_local_encoding_threads() + 4;
-
 Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
        : _film (f)
        , _job (j)
@@ -151,7 +149,7 @@ Writer::write (shared_ptr<const EncodedData> encoded, int frame, Eyes eyes)
 {
        boost::mutex::scoped_lock lock (_mutex);
 
-       while (_queued_full_in_memory > _maximum_frames_in_memory) {
+       while (_queued_full_in_memory > maximum_frames_in_memory ()) {
                /* The queue is too big; wait until that is sorted out */
                _full_condition.wait (lock);
        }
@@ -184,7 +182,7 @@ Writer::fake_write (int frame, Eyes eyes)
 {
        boost::mutex::scoped_lock lock (_mutex);
 
-       while (_queued_full_in_memory > _maximum_frames_in_memory) {
+       while (_queued_full_in_memory > maximum_frames_in_memory ()) {
                /* The queue is too big; wait until that is sorted out */
                _full_condition.wait (lock);
        }
@@ -266,7 +264,7 @@ try
 
                while (true) {
                        
-                       if (_finish || _queued_full_in_memory > _maximum_frames_in_memory || have_sequenced_image_at_queue_head ()) {
+                       if (_finish || _queued_full_in_memory > maximum_frames_in_memory () || have_sequenced_image_at_queue_head ()) {
                                /* We've got something to do: go and do it */
                                break;
                        }
@@ -352,7 +350,7 @@ try
                        }
                }
 
-               while (_queued_full_in_memory > _maximum_frames_in_memory) {
+               while (_queued_full_in_memory > maximum_frames_in_memory ()) {
                        done_something = true;
                        /* Too many frames in memory which can't yet be written to the stream.
                           Write some FULL frames to disk.
@@ -685,3 +683,9 @@ operator== (QueueItem const & a, QueueItem const & b)
 {
        return a.frame == b.frame && a.eyes == b.eyes;
 }
+
+int
+Writer::maximum_frames_in_memory () const
+{
+       return Config::instance()->num_local_encoding_threads() + 4;
+}
index 6aa0f4c1f38a28812600d6eb2f10efb521ec2f83..68ac972eec866923221185422d6f220c81afc0c0 100644 (file)
@@ -107,6 +107,10 @@ private:
        void check_existing_picture_mxf ();
        bool check_existing_picture_mxf_frame (FILE *, int, Eyes);
        bool have_sequenced_image_at_queue_head ();
+       /** maximum number of frames to hold in memory, for when we are managing
+        *  ordering
+        */
+       int maximum_frames_in_memory () const;
 
        /** our Film */
        boost::shared_ptr<const Film> _film;
@@ -133,10 +137,6 @@ private:
        /** the index of the last written frame */
        int _last_written_frame;
        Eyes _last_written_eyes;
-       /** maximum number of frames to hold in memory, for when we are managing
-           ordering
-       */
-       static const int _maximum_frames_in_memory;
 
        /** number of FULL written frames */
        int _full_written;