Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
[dcpomatic.git] / src / lib / cross.cc
index 6398e36764be282f60b355fa06613f79c810f7bc..454fe044cb51b2e19b3c646ba4d87738cbf762dc 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -362,20 +363,46 @@ start_batch_converter (boost::filesystem::path dcpomatic)
 #endif
 
 #ifdef DCPOMATIC_OSX
-       boost::filesystem::patch batch = dcpomatic.parent_path ();
+       boost::filesystem::path batch = dcpomatic.parent_path ();
        batch = batch.parent_path (); // MacOS
        batch = batch.parent_path (); // Contents
        batch = batch.parent_path (); // DCP-o-matic.app
        batch = batch.parent_path (); // Applications
-       batch /= "DCP-o-matic 2 Batch Converter.app" / "Contents" / "MacOS" / "dcpomatic2_batch";
+       batch /= "DCP-o-matic\\ 2\\ Batch\\ Converter.app";
+       batch /= "Contents";
+       batch /= "MacOS";
+       batch /= "dcpomatic2_batch";
 #endif
 
-#ifdef DCPOMATIC_LINUX
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_OSX)
        pid_t pid = fork ();
        if (pid == 0) {
-               int const r = system (batch.string().c_str ());
+               std::cout << "start " << batch << " from " << dcpomatic << "\n";
+               int const r = system (batch.string().c_str());
                exit (WEXITSTATUS (r));
        }
 #endif
 
+#ifdef DCPOMATIC_WINDOWS
+       STARTUPINFO startup_info;
+       ZeroMemory (&startup_info, sizeof (startup_info));
+       startup_info.cb = sizeof (startup_info);
+
+       PROCESS_INFORMATION process_info;
+       ZeroMemory (&process_info, sizeof (process_info));
+
+       wchar_t cmd[512];
+       MultiByteToWideChar (CP_UTF8, 0, batch.string().c_str(), -1, cmd, sizeof(cmd));
+       CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
+#endif
+}
+
+uint64_t
+thread_id ()
+{
+#ifdef DCPOMATIC_WINDOWS
+       return (uint64_t) GetCurrentThreadId ();
+#else
+       return (uint64_t) pthread_self ();
+#endif
 }