summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-07-07 18:22:05 +0200
committerCarl Hetherington <cth@carlh.net>2023-07-07 18:22:05 +0200
commit30c546cb120638cf189aa73ed26d7c6ef751c384 (patch)
tree16425a36052331964250327ed2874da32fb73683 /src/lib
parent28c4d55d7e7242c1a414a74751abe29b75e6505f (diff)
Use boost::filesystem::path for _gpu_binary_location.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc8
-rw-r--r--src/lib/config.h6
-rw-r--r--src/lib/grok_context.h19
-rw-r--r--src/lib/grok_messenger.h4
4 files changed, 24 insertions, 13 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 81b7ea857..410b2a899 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -213,7 +213,7 @@ Config::set_defaults ()
set_notification_email_to_default ();
set_cover_sheet_to_default ();
- _gpu_binary_location = "";
+ _gpu_binary_location = {};
_enable_gpu = false;
_selected_gpu = 0;
_gpu_license_server = "";
@@ -642,7 +642,7 @@ try
_isdcf_name_part_length = f.optional_number_child<int>("ISDCFNamePartLength").get_value_or(14);
_enable_gpu = f.optional_bool_child("EnableGpu").get_value_or(false);
- _gpu_binary_location = f.string_child("GpuBinaryLocation");
+ _gpu_binary_location = f.optional_string_child("GpuBinaryLocation");
_selected_gpu = f.number_child<int>("SelectedGpu");
_gpu_license_server = f.string_child("GpuLicenseServer");
_gpu_license_port = f.number_child<int>("GpuLicensePort");
@@ -1134,7 +1134,9 @@ Config::write_config () const
/* [XML] ISDCFNamePartLength Maximum length of the "name" part of an ISDCF name, which should be 14 according to the standard */
root->add_child("ISDCFNamePartLength")->add_child_text(raw_convert<string>(_isdcf_name_part_length));
- root->add_child("GpuBinaryLocation")->add_child_text(_gpu_binary_location);
+ if (_gpu_binary_location) {
+ root->add_child("GpuBinaryLocation")->add_child_text(_gpu_binary_location->string());
+ }
root->add_child("EnableGpu")->add_child_text((_enable_gpu ? "1" : "0"));
root->add_child("SelectedGpu")->add_child_text(raw_convert<string>(_selected_gpu));
root->add_child("GpuLicenseServer")->add_child_text(_gpu_license_server);
diff --git a/src/lib/config.h b/src/lib/config.h
index ad237c04b..eb5e255a7 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -618,7 +618,7 @@ public:
return _allow_smpte_bv20;
}
- std::string gpu_binary_location() const {
+ boost::optional<boost::filesystem::path> gpu_binary_location() const {
return _gpu_binary_location;
}
@@ -1223,7 +1223,7 @@ public:
maybe_set(_allow_smpte_bv20, allow, ALLOW_SMPTE_BV20);
}
- void set_gpu_binary_location(std::string location) {
+ void set_gpu_binary_location(boost::filesystem::path location) {
maybe_set(_gpu_binary_location, location);
}
@@ -1494,7 +1494,7 @@ private:
/* GPU */
bool _enable_gpu;
- std::string _gpu_binary_location;
+ boost::optional<boost::filesystem::path> _gpu_binary_location;
int _selected_gpu;
std::string _gpu_license_server;
int _gpu_license_port;
diff --git a/src/lib/grok_context.h b/src/lib/grok_context.h
index 49f916158..dcc40f237 100644
--- a/src/lib/grok_context.h
+++ b/src/lib/grok_context.h
@@ -18,20 +18,27 @@
*/
+
#pragma once
+
#include "config.h"
+#include "dcpomatic_assert.h"
#include "dcpomatic_log.h"
#include "grok_messenger.h"
#include "log.h"
#include "writer.h"
+
class Film;
+
static std::mutex launchMutex;
+
namespace grk_plugin {
+
struct GrokLogger : public MessengerLogger
{
explicit GrokLogger(const std::string& preamble)
@@ -111,7 +118,7 @@ struct DcpomaticContext
std::shared_ptr<const Film> film_,
Writer& writer_,
EventHistory& history_,
- const std::string& location_
+ const boost::optional<boost::filesystem::path>& location_
)
: film(film_)
, writer(writer_)
@@ -131,7 +138,7 @@ struct DcpomaticContext
std::shared_ptr<const Film> film;
Writer& writer;
EventHistory& history;
- std::string location;
+ boost::optional<boost::filesystem::path> location;
uint32_t width;
uint32_t height;
};
@@ -177,11 +184,12 @@ public:
};
if (Config::instance()->enable_gpu()) {
- boost::filesystem::path folder(_dcpomatic_context.location);
+ DCPOMATIC_ASSERT(_dcpomatic_context.location);
+ boost::filesystem::path folder(*_dcpomatic_context.location);
boost::filesystem::path binaryPath = folder / "grk_compress";
if (!boost::filesystem::exists(binaryPath)) {
get_messenger_logger()->error("Invalid binary location %s",
- _dcpomatic_context.location.c_str());
+ _dcpomatic_context.location->c_str());
return;
}
auto proc = [this](const std::string& str) {
@@ -251,7 +259,8 @@ public:
auto s = dcpv.get_size();
_dcpomatic_context.set_dimensions(s.width, s.height);
auto config = Config::instance();
- _messenger->launch_grok(_dcpomatic_context.location,
+ DCPOMATIC_ASSERT(_dcpomatic_context.location);
+ _messenger->launch_grok(*_dcpomatic_context.location,
_dcpomatic_context.width, _dcpomatic_context.width,
_dcpomatic_context.height,
3, 12, device,
diff --git a/src/lib/grok_messenger.h b/src/lib/grok_messenger.h
index 873233da4..70dc7ccd9 100644
--- a/src/lib/grok_messenger.h
+++ b/src/lib/grok_messenger.h
@@ -699,7 +699,7 @@ struct Messenger
return (pid != -1 && kill(pid, SIGKILL) != -1);
}
- void launch_grok(const std::string& dir, uint32_t width, uint32_t stride,
+ void launch_grok(const boost::filesystem::path& dir, uint32_t width, uint32_t stride,
uint32_t height, uint32_t samplesPerPixel, uint32_t depth,
int device, bool is4K, uint32_t fps, uint32_t bandwidth,
const std::string server, uint32_t port,
@@ -811,7 +811,7 @@ protected:
std::condition_variable clientInitializedCondition_;
private:
- void launch(const std::string& cmd, const std::string& dir)
+ void launch(const std::string& cmd, const boost::filesystem::path& dir)
{
// Change the working directory
if (!dir.empty()) {