diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-03-14 22:21:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-03-14 22:21:50 +0100 |
| commit | 332b17662dc56488970d1ae1d78b9851f8332e52 (patch) | |
| tree | 5771b3a22f07af02c104b11bb7266d8e15f85496 /src/lib | |
| parent | b733ef1ad671a6dd4817453ec20edf6f8c7cd654 (diff) | |
Allow building of disk writer with boost process version 2.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/grok/util.cc | 36 |
1 files changed, 34 insertions, 2 deletions
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 <boost/asio.hpp> #include <boost/process.hpp> #include <future> @@ -33,9 +34,11 @@ using std::vector; vector<string> 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<string> 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 } |
