No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / lib / encoder.cc
index e7277d0dd41bc36a2851d802b11e63f83317f956..36e4fe55d4adba72ca2aff7416393c6a5e7bf85c 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 #include "log.h"
 #include "config.h"
 #include "dcp_video.h"
-#include "server.h"
 #include "cross.h"
 #include "writer.h"
-#include "server_finder.h"
+#include "encode_server_finder.h"
 #include "player.h"
 #include "player_video.h"
-#include "server_description.h"
+#include "encode_server_description.h"
 #include "compose.hpp"
 #include <libcxml/cxml.h>
 #include <boost/foreach.hpp>
@@ -79,8 +79,8 @@ Encoder::~Encoder ()
 void
 Encoder::begin ()
 {
-       if (!ServerFinder::instance()->disabled ()) {
-               _server_found_connection = ServerFinder::instance()->ServersListChanged.connect (boost::bind (&Encoder::servers_list_changed, this));
+       if (!EncodeServerFinder::instance()->disabled ()) {
+               _server_found_connection = EncodeServerFinder::instance()->ServersListChanged.connect (boost::bind (&Encoder::servers_list_changed, this));
        }
 }
 
@@ -277,7 +277,7 @@ Encoder::terminate_threads ()
 }
 
 void
-Encoder::encoder_thread (optional<ServerDescription> server)
+Encoder::encoder_thread (optional<EncodeServerDescription> server)
 try
 {
        if (server) {
@@ -358,7 +358,7 @@ try
                }
 
                if (remote_backoff > 0) {
-                       boost::this_thread::sleep_for (boost::chrono::seconds (remote_backoff));
+                       boost::this_thread::sleep (boost::posix_time::seconds (remote_backoff));
                }
 
                /* The queue might not be full any more, so notify anything that is waiting on that */
@@ -382,13 +382,29 @@ Encoder::servers_list_changed ()
 
        boost::mutex::scoped_lock lm (_threads_mutex);
 
+#ifdef BOOST_THREAD_PLATFORM_WIN32
+       OSVERSIONINFO info;
+       info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+       GetVersionEx (&info);
+       bool const windows_xp = (info.dwMajorVersion == 5 && info.dwMinorVersion == 1);
+       if (windows_xp) {
+               LOG_GENERAL_NC (N_("Setting thread affinity for Windows XP"));
+       }
+#endif
+
        if (!Config::instance()->only_servers_encode ()) {
                for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) {
-                       _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
+                       boost::thread* t = new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<EncodeServerDescription> ()));
+                       _threads.push_back (t);
+#ifdef BOOST_THREAD_PLATFORM_WIN32
+                       if (windows_xp) {
+                               SetThreadAffinityMask (t->native_handle(), 1 << i);
+                       }
+#endif
                }
        }
 
-       BOOST_FOREACH (ServerDescription i, ServerFinder::instance()->servers ()) {
+       BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->servers ()) {
                LOG_GENERAL (N_("Adding %1 worker threads for remote %2"), i.threads(), i.host_name ());
                for (int j = 0; j < i.threads(); ++j) {
                        _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, i)));