if (_context->launch(frame, grok.selected) && _context->scheduleCompress(frame)) {
frame_guard.cancel();
}
+
+ boost::this_thread::interruption_point();
}
}
catch (boost::thread_interrupted& e)
{
#ifdef DCPOMATIC_GROK
{
- boost::mutex::scoped_lock lock(_threads_mutex);
- auto is_grok_thread_with_errors = [](shared_ptr<const J2KEncoderThread> thread) {
- auto grok = dynamic_pointer_cast<const GrokJ2KEncoderThread>(thread);
- return grok && grok->errors();
- };
-
- _give_up = std::any_of(_threads.begin(), _threads.end(), is_grok_thread_with_errors);
+ /* We might be destroying or remaking these threads, and hopefully in that case we'll come back here
+ * to check again; we definitely don't want to block in that case waiting to be allowed to check
+ * _threads.
+ */
+ boost::mutex::scoped_lock lock(_threads_mutex, boost::try_to_lock);
+ if (lock) {
+ auto is_grok_thread_with_errors = [](shared_ptr<const J2KEncoderThread> thread) {
+ auto grok = dynamic_pointer_cast<const GrokJ2KEncoderThread>(thread);
+ return grok && grok->errors();
+ };
+
+ _give_up = std::any_of(_threads.begin(), _threads.end(), is_grok_thread_with_errors);
+ }
}
#endif
#include "lib/dcp_transcode_job.h"
#include "lib/encode_server_description.h"
#include "lib/film.h"
+#ifdef DCPOMATIC_GROK
+#include "lib/grok/context.h"
+#endif
#include "lib/j2k_encoder.h"
#include "lib/job_manager.h"
#include "lib/make_dcp.h"
BOOST_REQUIRE_EQUAL(dcp.cpls()[0]->reels()[0]->main_picture()->intrinsic_duration(), 423U);
}
+
+#ifdef DCPOMATIC_GROK
+BOOST_AUTO_TEST_CASE(transcode_stops_when_gpu_enabled_with_no_gpu)
+{
+ ConfigRestorer cr;
+
+ grk_plugin::setMessengerLogger(new grk_plugin::GrokLogger("[GROK] "));
+
+ Config::Grok grok;
+ grok.enable = true;
+ Config::instance()->set_grok(grok);
+
+ auto content = content_factory(TestPaths::private_data() / "clapperboard.mp4");
+ auto film = new_test_film("transcode_stops_when_gpu_enabled_with_no_gpu", content);
+ film->write_metadata();
+ auto job = make_dcp(film, TranscodeJob::ChangedBehaviour::IGNORE);
+
+ int slept = 0;
+ while (JobManager::instance()->work_to_do() && slept < 10) {
+ dcpomatic_sleep_seconds(1);
+ ++slept;
+ }
+
+ BOOST_REQUIRE(slept < 10);
+
+ JobManager::drop();
+}
+#endif