#include "encode_server_description.h"
#include "compose.hpp"
#include <libcxml/cxml.h>
-#include <boost/foreach.hpp>
#include <iostream>
#include "i18n.h"
using std::list;
using std::cout;
using std::exception;
-using boost::shared_ptr;
-using boost::weak_ptr;
+using std::shared_ptr;
+using std::weak_ptr;
using boost::optional;
using dcp::Data;
using namespace dcpomatic;
J2KEncoder::~J2KEncoder ()
{
+ boost::mutex::scoped_lock lm (_threads_mutex);
terminate_threads ();
}
LOG_GENERAL_NC (N_("Terminating encoder threads"));
- terminate_threads ();
+ {
+ boost::mutex::scoped_lock lm (_threads_mutex);
+ terminate_threads ();
+ }
/* Something might have been thrown during terminate_threads */
rethrow ();
{
_waker.nudge ();
- size_t threads = _threads->size();
+ size_t threads = 0;
+ {
+ boost::mutex::scoped_lock lm (_threads_mutex);
+ threads = _threads->size();
+ }
boost::mutex::scoped_lock queue_lock (_queue_mutex);
LOG_DEBUG_ENCODE("Frame @ %1 J2K", to_string(time));
/* This frame already has J2K data, so just write it */
_writer->write (pv->j2k(), position, pv->eyes ());
+ frame_done ();
} else if (_last_player_video[pv->eyes()] && _writer->can_repeat(position) && pv->same (_last_player_video[pv->eyes()])) {
LOG_DEBUG_ENCODE("Frame @ %1 REPEAT", to_string(time));
_writer->repeat (position, pv->eyes ());
_last_player_video_time = time;
}
+
+/** Caller must hold a lock on _threads_mutex */
void
J2KEncoder::terminate_threads ()
{
void
J2KEncoder::servers_list_changed ()
{
+ boost::mutex::scoped_lock lm (_threads_mutex);
+
terminate_threads ();
_threads.reset (new boost::thread_group());
}
}
- BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->servers()) {
+ for (auto i: EncodeServerFinder::instance()->servers()) {
if (!i.current_link_version()) {
continue;
}