/*
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/>.
*/
using std::string;
using std::wstring;
using std::make_pair;
+using std::runtime_error;
using boost::shared_ptr;
/** @param s Number of seconds to sleep for */
uint32_t size = 1024;
char buffer[size];
if (_NSGetExecutablePath (buffer, &size)) {
- throw StringError ("_NSGetExecutablePath failed");
+ throw runtime_error ("_NSGetExecutablePath failed");
}
boost::filesystem::path path (buffer);
IOPMAssertionRelease (_assertion_id);
#endif
}
+
+void
+start_batch_converter (boost::filesystem::path dcpomatic)
+{
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_WINDOWS)
+ boost::filesystem::path batch = dcpomatic.parent_path() / "dcpomatic2_batch";
+#endif
+
+#ifdef DCPOMATIC_OSX
+ 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";
+ batch /= "Contents";
+ batch /= "MacOS";
+ batch /= "dcpomatic2_batch";
+#endif
+
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_OSX)
+ pid_t pid = fork ();
+ if (pid == 0) {
+ 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
+}