Merge branch 'main' into v2.17.x
[dcpomatic.git] / src / lib / util.cc
index fe6602de380cf60c2b3f0cf9fc197471eeef011b..ef15b90e5b1c4fea79837a814ccce69df84d2017 100644 (file)
@@ -243,6 +243,7 @@ addr2line (void const * const addr)
 {
        char addr2line_cmd[512] = { 0 };
        sprintf (addr2line_cmd, "addr2line -f -p -e %.256s %p > %s", program_name.c_str(), addr, backtrace_file.string().c_str());
+       std::cout << addr2line_cmd << "\n";
        return system(addr2line_cmd);
 }
 
@@ -428,6 +429,11 @@ dcpomatic_setup ()
        SetUnhandledExceptionFilter(exception_handler);
 #endif
 
+#ifdef DCPOMATIC_GROK
+       /* This makes grok support work with CUDA 12.2 */
+       setenv("CUDA_MODULE_LOADING", "EAGER", 1);
+#endif
+
 #ifdef DCPOMATIC_HAVE_AVREGISTER
 LIBDCP_DISABLE_WARNINGS
        av_register_all ();
@@ -877,16 +883,6 @@ remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping m
        return mapped;
 }
 
-Eyes
-increment_eyes (Eyes e)
-{
-       if (e == Eyes::LEFT) {
-               return Eyes::RIGHT;
-       }
-
-       return Eyes::LEFT;
-}
-
 
 size_t
 utf8_strlen (string s)
@@ -1124,6 +1120,33 @@ word_wrap(string input, int columns)
 }
 
 
+#ifdef DCPOMATIC_GROK
+void
+setup_grok_library_path()
+{
+       static std::string old_path;
+       if (old_path.empty()) {
+               auto const old = getenv("LD_LIRARY_PATH");
+               if (old) {
+                       old_path = old;
+               }
+       }
+       auto const grok = Config::instance()->grok();
+       if (!grok || grok->binary_location.empty()) {
+               setenv("LD_LIRARY_PATH", old_path.c_str(), 1);
+               return;
+       }
+
+       std::string new_path = old_path;
+       if (!new_path.empty()) {
+               new_path += ":";
+       }
+       new_path += grok->binary_location.string();
+
+       setenv("LD_LIBRARY_PATH", new_path.c_str(), 1);
+}
+#endif
+
 string
 screen_names_to_string(vector<string> names)
 {