diff options
Diffstat (limited to 'src/lib/j2k_encoder.cc')
| -rw-r--r-- | src/lib/j2k_encoder.cc | 20 |
1 files changed, 13 insertions, 7 deletions
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 |
