From 332b17662dc56488970d1ae1d78b9851f8332e52 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 14 Mar 2026 22:21:50 +0100 Subject: Allow building of disk writer with boost process version 2. --- src/lib/grok/util.cc | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc index 3d5caeba1..33847e8bb 100644 --- a/src/lib/grok/util.cc +++ b/src/lib/grok/util.cc @@ -22,6 +22,7 @@ #include "util.h" #include "../config.h" #include "../dcpomatic_log.h" +#include #include #include @@ -33,9 +34,11 @@ using std::vector; vector get_gpu_names() { - namespace bp = boost::process; + auto const binary = Config::instance()->grok().binary_location / "gpu_lister"; + +#ifdef DCPOMATIC_BOOST_PROCESS_V1 - auto binary = Config::instance()->grok().binary_location / "gpu_lister"; + namespace bp = boost::process; bp::ipstream stream; @@ -55,6 +58,35 @@ get_gpu_names() LOG_ERROR("Could not fetch GPU names: {}", e.what()); return {}; } + +#else + + namespace bp = boost::process::v2; + + try { + boost::asio::io_context context; + boost::asio::readable_pipe out{context}; + bp::process child(context, binary, {}, bp::process_stdio{{}, out, {}}); + + string output; + boost::system::error_code ec; + while (child.running()) { + string block; + boost::asio::read(out, boost::asio::dynamic_buffer(block), ec); + output += block; + if (ec && ec == boost::asio::error::eof) { + break; + } + } + + vector lines; + boost::algorithm::split(lines, output, boost::is_any_of("\n")); + return lines; + } catch (std::exception& e) { + LOG_ERROR("Could not fetch GPU names: {}", e.what()); + return {}; + } +#endif } -- cgit v1.2.3