X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.cc;h=8ba794a8e4c43b368e6cb801f4de28aac150e430;hb=6fde557864505b470c438e4161ee494f29b90d63;hp=00d6e63996c96c41717a3ec76d00efb8590c57b3;hpb=01d0c14f03698d25af51f7d1a1b3112958da1cf3;p=dcpomatic.git diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 00d6e6399..8ba794a8e 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -27,13 +27,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 +78,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)); } } @@ -260,12 +259,16 @@ Encoder::terminate_threads () boost::mutex::scoped_lock threads_lock (_threads_mutex); + int n = 0; for (list::iterator i = _threads.begin(); i != _threads.end(); ++i) { + LOG_GENERAL ("Terminating thread %1 of %2", n + 1, _threads.size ()); (*i)->interrupt (); if ((*i)->joinable ()) { (*i)->join (); } delete *i; + LOG_GENERAL_NC ("Thread terminated"); + ++n; } _threads.clear (); @@ -273,7 +276,7 @@ Encoder::terminate_threads () } void -Encoder::encoder_thread (optional server) +Encoder::encoder_thread (optional server) try { if (server) { @@ -354,7 +357,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 */ @@ -380,11 +383,11 @@ Encoder::servers_list_changed () 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 ()))); + _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional ()))); } } - 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)));