diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-11-28 18:50:21 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-11-29 23:31:41 +0100 |
| commit | 92eab12404eca23db0a96ad7574d8d500f3d0f8a (patch) | |
| tree | d228554891cda105e85b4955f43f9bcbd3d68b5d /src/lib/j2k_encoder.cc | |
| parent | e995209353552a97676a11fee03f245564df41ba (diff) | |
Abort encode if Grok encoder threads are failing (#2899)
Diffstat (limited to 'src/lib/j2k_encoder.cc')
| -rw-r--r-- | src/lib/j2k_encoder.cc | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 0b50bcd5a..15046b51d 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -93,6 +93,9 @@ grk_plugin::IMessengerLogger* getMessengerLogger(void) */ J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer) : VideoEncoder(film, writer) +#ifdef DCPOMATIC_GROK + , _give_up(false) +#endif { #ifdef DCPOMATIC_GROK auto grok = Config::instance()->grok().get_value_or({}); @@ -271,6 +274,12 @@ J2KEncoder::frame_done () void J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time) { +#ifdef DCPOMATIC_GROK + if (_give_up) { + throw EncodeError(_("GPU acceleration is enabled but the grok decoder is not working. Please check your configuration and license, and ensure that you are connected to the internet.")); + } +#endif + VideoEncoder::encode(pv, time); _waker.nudge (); @@ -463,9 +472,23 @@ J2KEncoder::pop() void J2KEncoder::retry(DCPVideo video) { - boost::mutex::scoped_lock lock(_queue_mutex); - _queue.push_front(video); - _empty_condition.notify_all(); +#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); + } +#endif + + { + boost::mutex::scoped_lock lock(_queue_mutex); + _queue.push_front(video); + _empty_condition.notify_all(); + } } |
