diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-18 00:17:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-18 10:51:44 +0100 |
| commit | f9ab63ab6d2e7eb4b997790e5ca04b38e0ac3f7a (patch) | |
| tree | 5df460c46f7396d7ea66330f907bb0c72a4c8e5a /src/lib | |
| parent | eee26f75150c3650e98c9d0102fd9f0d269c4bd5 (diff) | |
Fix hang when encoding with GPU enabled but not working.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/grok_j2k_encoder_thread.cc | 2 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.cc | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/grok_j2k_encoder_thread.cc b/src/lib/grok_j2k_encoder_thread.cc index 6975d9221..e6c256f11 100644 --- a/src/lib/grok_j2k_encoder_thread.cc +++ b/src/lib/grok_j2k_encoder_thread.cc @@ -67,6 +67,8 @@ try if (_context->launch(frame, grok.selected) && _context->scheduleCompress(frame)) { frame_guard.cancel(); } + + boost::this_thread::interruption_point(); } } catch (boost::thread_interrupted& e) diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index b416f921d..3aaaa4e76 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -475,13 +475,19 @@ J2KEncoder::retry(DCPVideo video) { #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 |
