X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.cc;h=36e4fe55d4adba72ca2aff7416393c6a5e7bf85c;hb=ca436a8e96e02f982790d4168ac3dfe1d589451c;hp=8ba794a8e4c43b368e6cb801f4de28aac150e430;hpb=17df947ac256397311a11894062070f8069c7e75;p=dcpomatic.git diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 8ba794a8e..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 . */ @@ -381,9 +382,25 @@ 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 } }