X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.cc;h=36e4fe55d4adba72ca2aff7416393c6a5e7bf85c;hb=3828baf56467224f5d44049bf1e7a7ed11f43a05;hp=e7277d0dd41bc36a2851d802b11e63f83317f956;hpb=fccc63ca722e8156843ecbe2063cb5c3ea6f5ceb;p=dcpomatic.git diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index e7277d0dd..36e4fe55d 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2012-2015 Carl Hetherington - 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 . */ @@ -27,13 +28,12 @@ #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 #include @@ -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 server) +Encoder::encoder_thread (optional 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 ()))); + boost::thread* t = new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional ())); + _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)));