From: Carl Hetherington Date: Sat, 2 May 2020 19:37:14 +0000 (+0200) Subject: Try to start _writer on-demand on macOS (#1739). X-Git-Tag: v2.15.71~6 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=3a715c7e0d5cbb39ffd6816899ef3050e8331882;hp=88ad1ed243572b5310a4e866e87a61e8d8c8969e;p=dcpomatic.git Try to start _writer on-demand on macOS (#1739). --- diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index b4a4488df..1cff3b5bb 100644 --- a/platform/osx/make_dmg.sh +++ b/platform/osx/make_dmg.sh @@ -537,16 +537,21 @@ cat > $pkgroot/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist <DYLD_LIBRARY_PATH - KeepAlive - - RunAtLoad - - Debug - StandardOutPath /var/log/dcpomatic_disk_writer_out.log StandardErrorPath /var/log/dcpomatic_disk_writer_err.log + LaunchEvents + + com.apple.notifyd.matching + + com.dcpomatic.disk.writer.start + + Notification + com.dcpomatic.disk.writer.start + + + EOF diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 6f72bfed0..b2678ce42 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -42,6 +42,7 @@ #endif #ifdef DCPOMATIC_OSX #include +#include #endif using std::string; @@ -132,7 +133,10 @@ public: _writer = new boost::process::child (disk_writer_path()); #endif - /* _writer is always running on macOS at the moment */ +#ifdef DCPOMATIC_OSX + LOG_DISK_NC("Sending notification to writer daemon"); + notify_post ("com.dcpomatic.disk.writer.start"); +#endif } ~DOMFrame () diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index 66f347943..d5599f25b 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -48,6 +48,7 @@ extern "C" { extern "C" { #include } +#include #endif #ifdef DCPOMATIC_LINUX @@ -520,6 +521,13 @@ main () LOG_DISK_NC("dcpomatic_disk_writer started"); #endif +#ifdef DCPOMATIC_OSX + /* I *think* this confumes the notifyd event that we used to start the process, so we only + * get started once per notification. + */ + xpc_set_event_stream_handler("com.apple.notifyd.matching", DISPATCH_TARGET_QUEUE_DEFAULT, ^(xpc_object_t event) {}); +#endif + try { nanomsg = new Nanomsg (false); } catch (runtime_error& e) {