5b5c36d28d07e8cd93af5a3f766fd95f2a506beb from master; increase the number of images...
authorCarl Hetherington <cth@carlh.net>
Mon, 25 May 2015 13:38:31 +0000 (14:38 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 25 May 2015 13:38:31 +0000 (14:38 +0100)
ChangeLog
TO_PORT
src/lib/encoder.cc
src/lib/writer.cc
src/lib/writer.h

index 1472137f0df077f4428d9f7785e3b9e67a4a2f6e..58f0d68d4fa86443855318358376fa0ff7e02594 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-05-25  Carl Hetherington  <cth@carlh.net>
 
+       * Increase the number of images that DCP-o-matic will
+       keep around in memory before resorting to pushing them
+       to disk.
+
        * Display DCP container size beside the choice
        in the DCP tab.
 
diff --git a/TO_PORT b/TO_PORT
index bb6fef4e170b3bc90ab12126023d865a22818caf..4ba5dfaa33c7874be8eda014a073cc92feef5314 100644 (file)
--- a/TO_PORT
+++ b/TO_PORT
@@ -1,4 +1,3 @@
-468a7437c8ec82a8f74ae30197a2c5b04100b75d
 2bf46f7c75c59e4cd3d91f1ddd322bdabb19b6f4
 f952568be9c4438d5b024c133b18b2590de968e7
 349e2950e5541d41e5491c2865734cf6a86e2cbd
@@ -10,3 +9,4 @@ c040b70eb777630ef0fdbb80cd419f6b3da4b46e
 ea2becf3a859bc38c783d15f165d71f2ccb8c1d6
 21cb435ed5eb250a7f94887ddd75f6b367ea231f
 Multi-stream audio stuff.
+77d7a03cf0785140caf37276edac9a1a0c9a8799
index 2a60268791134ae37d956face1349a2847f5450f..7a0295e4c52dc9a85e7d20980cd7fa6840eb7eab 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -84,6 +84,8 @@ Encoder::add_worker_threads (ServerDescription d)
        for (int i = 0; i < d.threads(); ++i) {
                _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, d)));
        }
+
+       _writer->set_encoder_threads (_threads.size ());
 }
 
 void
@@ -93,6 +95,8 @@ Encoder::begin ()
                _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
        }
 
+       _writer->set_encoder_threads (_threads.size ());
+
        if (!ServerFinder::instance()->disabled ()) {
                _server_found_connection = ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
        }
index b71ff28918a3086efbf728fe1e6cb9ec54c03d23..5922752818bc094203926e8f03bf79954f6297b8 100644 (file)
@@ -83,6 +83,7 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
        , _queued_full_in_memory (0)
        , _last_written_frame (-1)
        , _last_written_eyes (EYES_RIGHT)
+       , _maximum_frames_in_memory (0)
        , _full_written (0)
        , _fake_written (0)
        , _pushed_to_disk (0)
@@ -152,7 +153,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);
        }
@@ -185,7 +186,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);
        }
@@ -267,7 +268,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;
                        }
@@ -353,7 +354,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.
@@ -708,8 +709,8 @@ operator== (QueueItem const & a, QueueItem const & b)
        return a.frame == b.frame && a.eyes == b.eyes;
 }
 
-int
-Writer::maximum_frames_in_memory () const
+void
+Writer::set_encoder_threads (int threads)
 {
-       return Config::instance()->num_local_encoding_threads() + 4;
+       _maximum_frames_in_memory = rint (threads * 1.1);
 }
index 41d4d4474bae3dde1e97e35f9d6392aeb165315b..e63591a8a338d50351b8ed4f0f45ad48e794c148 100644 (file)
@@ -100,6 +100,8 @@ public:
        void repeat (int f, Eyes);
        void finish ();
 
+       void set_encoder_threads (int threads);
+
 private:
 
        void thread ();
@@ -107,10 +109,6 @@ 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;
@@ -137,7 +135,11 @@ 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
+        */
+       int _maximum_frames_in_memory;
+       
        /** number of FULL written frames */
        int _full_written;
        /** number of FAKE written frames */