summaryrefslogtreecommitdiff
path: root/src/lib/grok
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-09-24 17:23:57 +0200
committerCarl Hetherington <cth@carlh.net>2024-01-28 02:01:57 +0100
commit9aca7d85aa86a9232a2cd83e867d679c30487059 (patch)
tree0161617f7c7a3b3b7164eb8e905d89f7d9bbb009 /src/lib/grok
parent3b1ee8690b21ddc5ff53ba3b2ba50270e3c9f9bf (diff)
Use boost::filesystem::path for gpu_binary_location().
Diffstat (limited to 'src/lib/grok')
-rw-r--r--src/lib/grok/context.h55
-rw-r--r--src/lib/grok/messenger.h28
2 files changed, 54 insertions, 29 deletions
diff --git a/src/lib/grok/context.h b/src/lib/grok/context.h
index 72e62c4fa..3e4144d07 100644
--- a/src/lib/grok/context.h
+++ b/src/lib/grok/context.h
@@ -74,12 +74,22 @@ struct FrameProxy {
};
struct DcpomaticContext {
- DcpomaticContext(std::shared_ptr<const Film> film, Writer& writer,
- EventHistory &history, const std::string &location) :
- film_(film), writer_(writer),
- history_(history), location_(location),
- width_(0), height_(0)
- {}
+ DcpomaticContext(
+ std::shared_ptr<const Film> film,
+ Writer& writer,
+ EventHistory& history,
+ boost::filesystem::path const& location
+ )
+ : film_(film)
+ , writer_(writer)
+ , history_(history)
+ , _location(location)
+ , width_(0)
+ , height_(0)
+ {
+
+ }
+
void setDimensions(uint32_t w, uint32_t h) {
width_ = w;
height_ = h;
@@ -87,7 +97,7 @@ struct DcpomaticContext {
std::shared_ptr<const Film> film_;
Writer& writer_;
EventHistory &history_;
- std::string location_;
+ boost::filesystem::path _location;
uint32_t width_;
uint32_t height_;
};
@@ -100,12 +110,13 @@ public:
launched_(false)
{
if (Config::instance()->enable_gpu ()) {
- boost::filesystem::path folder(dcpomaticContext_.location_);
+ boost::filesystem::path folder(dcpomaticContext_._location);
boost::filesystem::path binaryPath = folder / "grk_compress";
if (!boost::filesystem::exists(binaryPath)) {
- getMessengerLogger()->error("Invalid binary location %s",
- dcpomaticContext_.location_.c_str());
- return;
+ getMessengerLogger()->error(
+ "Invalid binary location %s", dcpomaticContext_._location.c_str()
+ );
+ return;
}
auto proc = [this](const std::string& str) {
try {
@@ -166,16 +177,18 @@ public:
auto s = dcpv.get_size();
dcpomaticContext_.setDimensions(s.width, s.height);
auto config = Config::instance();
- messenger_->launchGrok(dcpomaticContext_.location_,
- dcpomaticContext_.width_,dcpomaticContext_.width_,
- dcpomaticContext_.height_,
- 3, 12, device,
- dcpomaticContext_.film_->resolution() == Resolution::FOUR_K,
- dcpomaticContext_.film_->video_frame_rate(),
- dcpomaticContext_.film_->j2k_bandwidth(),
- config->gpu_license_server(),
- config->gpu_license_port(),
- config->gpu_license());
+ messenger_->launchGrok(
+ dcpomaticContext_._location,
+ dcpomaticContext_.width_,dcpomaticContext_.width_,
+ dcpomaticContext_.height_,
+ 3, 12, device,
+ dcpomaticContext_.film_->resolution() == Resolution::FOUR_K,
+ dcpomaticContext_.film_->video_frame_rate(),
+ dcpomaticContext_.film_->j2k_bandwidth(),
+ config->gpu_license_server(),
+ config->gpu_license_port(),
+ config->gpu_license()
+ );
}
launched_ = messenger_->waitForClientInit();
diff --git a/src/lib/grok/messenger.h b/src/lib/grok/messenger.h
index 008e58dd2..5cb21a1cd 100644
--- a/src/lib/grok/messenger.h
+++ b/src/lib/grok/messenger.h
@@ -542,11 +542,22 @@ struct Messenger
sendQueue.push(oss.str());
}
- void launchGrok(const std::string &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,
- const std::string license)
+
+ void launchGrok(
+ boost::filesystem::path const& 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,
+ const std::string license
+ )
{
std::unique_lock<std::mutex> lk(shutdownMutex_);
@@ -640,13 +651,14 @@ struct Messenger
protected:
std::condition_variable clientInitializedCondition_;
private:
- void launch(const std::string &cmd, const std::string &dir)
+ void launch(std::string const& cmd, boost::filesystem::path const& dir)
{
// Change the working directory
if(!dir.empty())
{
- if(chdir(dir.c_str()) != 0)
- {
+ boost::system::error_code ec;
+ boost::filesystem::current_path(dir, ec);
+ if (ec) {
getMessengerLogger()->error("Error: failed to change the working directory");
return;
}