X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcross_osx.cc;h=a16907ebe47360f2658724ce849e5583761ac99f;hb=152197adf5b060602ecdd99e6f272c4e8b2b410e;hp=574cc8660887b059185dc5d120fa18fb6d114af7;hpb=7552a04c443c9c641ac580585f6d88900bf84d04;p=dcpomatic.git diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 574cc8660..a16907ebe 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -24,6 +24,7 @@ #include "dcpomatic_log.h" #include "config.h" #include "exceptions.h" +#include "warnings.h" #include #include extern "C" { @@ -35,6 +36,7 @@ extern "C" { #if BOOST_VERSION >= 106100 #include #endif +#include #include #include #include @@ -115,12 +117,26 @@ directory_containing_executable () boost::filesystem::path -shared_path () +resources_path () { return directory_containing_executable().parent_path() / "Resources"; } +boost::filesystem::path +xsd_path () +{ + return resources_path() / "xsd"; +} + + +boost::filesystem::path +tags_path () +{ + return resources_path() / "tags"; +} + + void run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) { @@ -180,10 +196,7 @@ Waker::nudge () Waker::Waker () { boost::mutex::scoped_lock lm (_mutex); - /* We should use this */ - // IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); - /* but it's not available on 10.5, so we use this */ - IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_assertion_id); + IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); } Waker::~Waker () @@ -195,20 +208,22 @@ Waker::~Waker () void start_tool (string executable, string app) { - boost::filesystem::path batch = directory_containing_executable(); - batch = batch.parent_path (); // MacOS - batch = batch.parent_path (); // Contents - batch = batch.parent_path (); // DCP-o-matic.app - batch = batch.parent_path (); // Applications - batch /= app; - batch /= "Contents"; - batch /= "MacOS"; - batch /= executable; + boost::filesystem::path exe_path = directory_containing_executable(); + exe_path = exe_path.parent_path (); // Contents + exe_path = exe_path.parent_path (); // DCP-o-matic 2.app + exe_path = exe_path.parent_path (); // Applications + exe_path /= app; + exe_path /= "Contents"; + exe_path /= "MacOS"; + exe_path /= executable; pid_t pid = fork (); if (pid == 0) { - int const r = system (batch.string().c_str()); + LOG_GENERAL ("start_tool %1 %2 with path %3", executable, app, exe_path.string()); + int const r = system (exe_path.string().c_str()); exit (WEXITSTATUS (r)); + } else if (pid == -1) { + LOG_ERROR_NC("Fork failed in start_tool"); } } @@ -245,12 +260,6 @@ home_directory () return getenv("HOME"); } -string -command_and_read (string cmd) -{ - return ""; -} - /** @return true if this process is a 32-bit one running on a 64-bit-capable OS */ bool running_32_on_64 () @@ -516,7 +525,7 @@ config_path () } -void done_callback(DADiskRef disk, DADissenterRef dissenter, void* context) +void done_callback(DADiskRef, DADissenterRef dissenter, void* context) { LOG_DISK_NC("Unmount finished"); bool* success = reinterpret_cast (context); @@ -566,3 +575,20 @@ disk_write_finished () } + +void +make_foreground_application () +{ + ProcessSerialNumber serial; +DCPOMATIC_DISABLE_WARNINGS + GetCurrentProcess (&serial); +DCPOMATIC_ENABLE_WARNINGS + TransformProcessType (&serial, kProcessTransformToForegroundApplication); +} + + +string +dcpomatic::get_process_id () +{ + return dcp::raw_convert(getpid()); +}