Distinguish master DoM encode threads count from the server count.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 Apr 2017 10:57:15 +0000 (11:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 Apr 2017 10:57:15 +0000 (11:57 +0100)
src/lib/config.cc
src/lib/config.h
src/lib/encoder.cc
src/lib/film.cc
src/lib/writer.cc
src/tools/dcpomatic_cli.cc
src/tools/dcpomatic_server.cc
src/tools/dcpomatic_server_cli.cc
src/wx/config_dialog.cc
test/digest_test.cc
test/test.cc

index de44c5c779e5cfe6daf34a1a2d0c7f8d6197e497..9fdf572070b79eee467d7b0613f46b4e8fe224e6 100644 (file)
@@ -72,7 +72,8 @@ Config::Config ()
 void
 Config::set_defaults ()
 {
-       _num_local_encoding_threads = max (2U, boost::thread::hardware_concurrency ());
+       _master_encoding_threads = max (2U, boost::thread::hardware_concurrency ());
+       _server_encoding_threads = max (2U, boost::thread::hardware_concurrency ());
        _server_port_base = 6192;
        _use_any_servers = true;
        _servers.clear ();
@@ -162,7 +163,13 @@ try
 
        optional<int> version = f.optional_number_child<int> ("Version");
 
-       _num_local_encoding_threads = f.number_child<int> ("NumLocalEncodingThreads");
+       if (f.optional_number_child<int>("NumLocalEncodingThreads")) {
+               _master_encoding_threads = _server_encoding_threads = f.optional_number_child<int>("NumLocalEncodingThreads").get();
+       } else {
+               _master_encoding_threads = f.number_child<int>("MasterEncodingThreads");
+               _server_encoding_threads = f.number_child<int>("ServerEncodingThreads");
+       }
+
        _default_directory = f.optional_string_child ("DefaultDirectory");
        if (_default_directory && _default_directory->empty ()) {
                /* We used to store an empty value for this to mean "none set" */
@@ -392,7 +399,8 @@ Config::write_config () const
        xmlpp::Element* root = doc.create_root_node ("Config");
 
        root->add_child("Version")->add_child_text ("2");
-       root->add_child("NumLocalEncodingThreads")->add_child_text (raw_convert<string> (_num_local_encoding_threads));
+       root->add_child("MasterEncodingThreads")->add_child_text (raw_convert<string> (_master_encoding_threads));
+       root->add_child("ServerEncodingThreads")->add_child_text (raw_convert<string> (_server_encoding_threads));
        if (_default_directory) {
                root->add_child("DefaultDirectory")->add_child_text (_default_directory->string ());
        }
index a574cc261a21793a34b8fd7e967aa2c3328b1f6c..40380f825f3247e7e545be4c4f5a12c4c3d6a79c 100644 (file)
@@ -47,9 +47,14 @@ class Film;
 class Config : public boost::noncopyable
 {
 public:
-       /** @return number of threads to use for J2K encoding on the local machine */
-       int num_local_encoding_threads () const {
-               return _num_local_encoding_threads;
+       /** @return number of threads which a master DoM should use for J2K encoding on the local machine */
+       int master_encoding_threads () const {
+               return _master_encoding_threads;
+       }
+
+       /** @return number of threads which a server should use for J2K encoding on the local machine */
+       int server_encoding_threads () const {
+               return _server_encoding_threads;
        }
 
        boost::optional<boost::filesystem::path> default_directory () const {
@@ -316,9 +321,12 @@ public:
                return _preview_sound_output;
        }
 
-       /** @param n New number of local encoding threads */
-       void set_num_local_encoding_threads (int n) {
-               maybe_set (_num_local_encoding_threads, n);
+       void set_master_encoding_threads (int n) {
+               maybe_set (_master_encoding_threads, n);
+       }
+
+       void set_server_encoding_threads (int n) {
+               maybe_set (_server_encoding_threads, n);
        }
 
        void set_default_directory (boost::filesystem::path d) {
@@ -628,8 +636,10 @@ private:
                changed (prop);
        }
 
-       /** number of threads to use for J2K encoding on the local machine */
-       int _num_local_encoding_threads;
+       /** number of threads which a master DoM should use for J2K encoding on the local machine */
+       int _master_encoding_threads;
+       /** number of threads which a server should use for J2K encoding on the local machine */
+       int _server_encoding_threads;
        /** default directory to put new films in */
        boost::optional<boost::filesystem::path> _default_directory;
        /** base port number to use for J2K encoding servers;
index e43325f58fde5ad4a7cc4fd97e620c8136ce0991..276ef8d3adccf1578223231e79c0818020f2bab0 100644 (file)
@@ -414,7 +414,7 @@ Encoder::servers_list_changed ()
 #endif
 
        if (!Config::instance()->only_servers_encode ()) {
-               for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) {
+               for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) {
                        boost::thread* t = new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<EncodeServerDescription> ()));
                        _threads.push_back (t);
 #ifdef BOOST_THREAD_PLATFORM_WIN32
index 82a40d5c4390eec070a47ba42b562793a60af8a6..218dc58efcc31e080eb4400ad0ef26f2d17cc729 100644 (file)
@@ -335,7 +335,7 @@ Film::make_dcp ()
        if (Config::instance()->only_servers_encode ()) {
                LOG_GENERAL_NC ("0 threads: ONLY SERVERS SET TO ENCODE");
        } else {
-               LOG_GENERAL ("%1 threads", Config::instance()->num_local_encoding_threads());
+               LOG_GENERAL ("%1 threads", Config::instance()->master_encoding_threads());
        }
        LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth());
 
index c507c552758bb4ca8ee9a0f081042b9de20f5f42..87cdac2d8c97bf3ce6dd4b0e47b93cf96fe4bdcb 100644 (file)
@@ -489,7 +489,7 @@ Writer::finish ()
 
        shared_ptr<boost::asio::io_service::work> work (new boost::asio::io_service::work (service));
 
-       int const threads = max (1, Config::instance()->num_local_encoding_threads ());
+       int const threads = max (1, Config::instance()->master_encoding_threads ());
 
        for (int i = 0; i < threads; ++i) {
                pool.create_thread (boost::bind (&boost::asio::io_service::run, &service));
index 00087d6a0c9425a2a0e9db46b757c6e7215dbbda..cfd8b3eaeeca57686c9a4f69ded64b28e5e618ab 100644 (file)
@@ -270,7 +270,7 @@ main (int argc, char* argv[])
        }
 
        if (threads) {
-               Config::instance()->set_num_local_encoding_threads (threads.get ());
+               Config::instance()->set_master_encoding_threads (threads.get ());
        }
 
        shared_ptr<Film> film;
index aff98912f46c55639488180e6a71c55efe86c05d..8e9ce7537cc3ff5ef50c65e0435de4a6d77670fa 100644 (file)
@@ -289,7 +289,7 @@ private:
 
        void main_thread ()
        try {
-               EncodeServer server (server_log, false, Config::instance()->num_local_encoding_threads());
+               EncodeServer server (server_log, false, Config::instance()->server_encoding_threads());
                server.run ();
        } catch (...) {
                store_current ();
index fa13ebb5fb8770fae62d16ccb898cebfa00da282..6dca8064c77163a730c8aa6b4846f6fe140a2e7b 100644 (file)
@@ -64,7 +64,7 @@ main (int argc, char* argv[])
        dcpomatic_setup_path_encoding ();
        dcpomatic_setup ();
 
-       int num_threads = Config::instance()->num_local_encoding_threads ();
+       int num_threads = Config::instance()->server_encoding_threads ();
        bool verbose = false;
        bool write_log = false;
 
index 613d8f6e1506f0051101a9f259d59376ab141b18..570d5e44806c3e2191bf45e76a518e7c2235f9cd 100644 (file)
@@ -194,9 +194,14 @@ private:
                restart->SetFont (font);
                ++r;
 
-               add_label_to_sizer (table, _panel, _("Threads to use for encoding on this host"), true, wxGBPosition (r, 0));
-               _num_local_encoding_threads = new wxSpinCtrl (_panel);
-               table->Add (_num_local_encoding_threads, wxGBPosition (r, 1));
+               add_label_to_sizer (table, _panel, _("Number of threads DCP-o-matic should use"), true, wxGBPosition (r, 0));
+               _master_encoding_threads = new wxSpinCtrl (_panel);
+               table->Add (_master_encoding_threads, wxGBPosition (r, 1));
+               ++r;
+
+               add_label_to_sizer (table, _panel, _("Number of threads DCP-o-matic encode server should use"), true, wxGBPosition (r, 0));
+               _server_encoding_threads = new wxSpinCtrl (_panel);
+               table->Add (_server_encoding_threads, wxGBPosition (r, 1));
                ++r;
 
                add_label_to_sizer (table, _panel, _("Cinema and screen database file"), true, wxGBPosition (r, 0));
@@ -256,8 +261,10 @@ private:
                _preview_sound->Bind        (wxEVT_CHECKBOX,           boost::bind (&GeneralPage::preview_sound_changed, this));
                _preview_sound_output->Bind (wxEVT_CHOICE,             boost::bind (&GeneralPage::preview_sound_output_changed, this));
 
-               _num_local_encoding_threads->SetRange (1, 128);
-               _num_local_encoding_threads->Bind (wxEVT_SPINCTRL, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
+               _master_encoding_threads->SetRange (1, 128);
+               _master_encoding_threads->Bind (wxEVT_SPINCTRL, boost::bind (&GeneralPage::master_encoding_threads_changed, this));
+               _server_encoding_threads->SetRange (1, 128);
+               _server_encoding_threads->Bind (wxEVT_SPINCTRL, boost::bind (&GeneralPage::server_encoding_threads_changed, this));
 
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
                _analyse_ebur128->Bind (wxEVT_CHECKBOX, boost::bind (&GeneralPage::analyse_ebur128_changed, this));
@@ -300,7 +307,8 @@ private:
 
                checked_set (_language, lang);
 
-               checked_set (_num_local_encoding_threads, config->num_local_encoding_threads ());
+               checked_set (_master_encoding_threads, config->master_encoding_threads ());
+               checked_set (_server_encoding_threads, config->server_encoding_threads ());
 #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
                checked_set (_analyse_ebur128, config->analyse_ebur128 ());
 #endif
@@ -398,9 +406,14 @@ private:
                Config::instance()->set_check_for_test_updates (_check_for_test_updates->GetValue ());
        }
 
-       void num_local_encoding_threads_changed ()
+       void master_encoding_threads_changed ()
+       {
+               Config::instance()->set_master_encoding_threads (_master_encoding_threads->GetValue ());
+       }
+
+       void server_encoding_threads_changed ()
        {
-               Config::instance()->set_num_local_encoding_threads (_num_local_encoding_threads->GetValue ());
+               Config::instance()->set_server_encoding_threads (_server_encoding_threads->GetValue ());
        }
 
        void issuer_changed ()
@@ -436,7 +449,8 @@ private:
 
        wxCheckBox* _set_language;
        wxChoice* _language;
-       wxSpinCtrl* _num_local_encoding_threads;
+       wxSpinCtrl* _master_encoding_threads;
+       wxSpinCtrl* _server_encoding_threads;
        FilePickerCtrl* _cinemas_file;
        wxCheckBox* _preview_sound;
        wxChoice* _preview_sound_output;
index b96cb7ad796f66a5dc5e823a1fa2ec51943c8a49..ce3edb95e55b89c33c5966d9307e7042cb2102b3 100644 (file)
@@ -72,10 +72,10 @@ BOOST_AUTO_TEST_CASE (digest_test)
        film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
        wait_for_jobs ();
 
-       Config::instance()->set_num_local_encoding_threads (4);
+       Config::instance()->set_master_encoding_threads (4);
        film->make_dcp ();
        wait_for_jobs ();
-       Config::instance()->set_num_local_encoding_threads (1);
+       Config::instance()->set_master_encoding_threads (1);
 
        dcp::DCP dcp (film->dir (film->dcp_name ()));
        dcp.read ();
index 3858dff11af091cc248d09eeb82a28dd3661e23d..b8d7070f8b960c6f89ee6bc4c30993f8dba662a0 100644 (file)
@@ -72,7 +72,8 @@ struct TestConfig
        {
                dcpomatic_setup ();
 
-               Config::instance()->set_num_local_encoding_threads (1);
+               Config::instance()->set_master_encoding_threads (1);
+               Config::instance()->set_server_encoding_threads (1);
                Config::instance()->set_server_port_base (61921);
                Config::instance()->set_default_isdcf_metadata (ISDCFMetadata ());
                Config::instance()->set_default_container (Ratio::from_id ("185"));