Replace assertion with a softer fix.
authorCarl Hetherington <cth@carlh.net>
Tue, 24 Dec 2024 22:28:08 +0000 (23:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 24 Dec 2024 22:41:56 +0000 (23:41 +0100)
Had a report of this assertion tripping with "only servers encode" switched on.
The user had encode servers but they were running old software, so
wouldn't be enabled for use.  Obviously the main DCP-o-matic should not
crash in this situation.

src/lib/j2k_encoder.cc

index 90b8b1d1a1fa5b49efa49d8e29273b706d98dec3..309fce0b374de5516b778d65affe98a2831513bb 100644 (file)
@@ -366,7 +366,12 @@ void
 J2KEncoder::remake_threads(int cpu, int gpu, list<EncodeServerDescription> servers)
 {
        LOG_GENERAL("Making threads: CPU=%1, GPU=%2, Remote=%3", cpu, gpu, servers.size());
-       DCPOMATIC_ASSERT((cpu + gpu + servers.size()) > 0);
+       if ((cpu + gpu + servers.size()) == 0) {
+               /* Make at least one thread, even if all else fails.  Maybe we are configured
+                * for "only servers encode" but no servers have been registered yet.
+                */
+               ++cpu;
+       }
 
        boost::mutex::scoped_lock lm (_threads_mutex);
        if (_ending) {