summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-08 23:46:21 +0200
committerCarl Hetherington <cth@carlh.net>2025-10-10 21:13:04 +0200
commitc39eb25116392813e064c963a9bce014e92805b3 (patch)
treee7cf32c442018aa9611dd270d58f95471da57ef7
parent81137ff8b9ea1ac55f973df11d55bcae56c1ee02 (diff)
Allow Waker to keep different things awake for different reasons.
-rw-r--r--src/lib/cross.h8
-rw-r--r--src/lib/cross_linux.cc2
-rw-r--r--src/lib/cross_osx.cc3
-rw-r--r--src/lib/cross_windows.cc5
-rw-r--r--src/lib/encode_server.cc1
-rw-r--r--src/lib/ffmpeg_film_encoder.cc2
-rw-r--r--src/lib/j2k_encoder.cc1
-rw-r--r--src/lib/writer.cc2
8 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/cross.h b/src/lib/cross.h
index 4773e2cb9..c304b6dfb 100644
--- a/src/lib/cross.h
+++ b/src/lib/cross.h
@@ -81,13 +81,19 @@ namespace dcpomatic {
class Waker
{
public:
- Waker();
+ enum class Reason {
+ PLAYING,
+ ENCODING
+ };
+
+ Waker(Reason reason);
~Waker();
void nudge();
private:
boost::mutex _mutex;
+ Reason _reason;
#ifdef DCPOMATIC_OSX
IOPMAssertionID _assertion_id;
#endif
diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc
index 528dd4c7a..c9d1322fe 100644
--- a/src/lib/cross_linux.cc
+++ b/src/lib/cross_linux.cc
@@ -188,7 +188,7 @@ Waker::nudge ()
}
-Waker::Waker ()
+Waker::Waker(Reason)
{
}
diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc
index 069b8409a..cda6a643f 100644
--- a/src/lib/cross_osx.cc
+++ b/src/lib/cross_osx.cc
@@ -155,7 +155,8 @@ Waker::nudge()
}
-Waker::Waker()
+Waker::Waker(Reason reason)
+ : _reason(reason)
{
boost::mutex::scoped_lock lm(_mutex);
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR("Encoding DCP"), &_assertion_id);
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc
index 29b16c715..2076f3928 100644
--- a/src/lib/cross_windows.cc
+++ b/src/lib/cross_windows.cc
@@ -256,11 +256,12 @@ void
Waker::nudge()
{
boost::mutex::scoped_lock lm(_mutex);
- SetThreadExecutionState(ES_SYSTEM_REQUIRED);
+ SetThreadExecutionState(_reason == Reason::ENCODING ? ES_SYSTEM_REQUIRED : ES_DISPLAY_REQUIRED);
}
-Waker::Waker()
+Waker::Waker(Reason reason)
+ : _reason(reason)
{
}
diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc
index cd7e89abb..493f727f9 100644
--- a/src/lib/encode_server.cc
+++ b/src/lib/encode_server.cc
@@ -81,6 +81,7 @@ EncodeServer::EncodeServer (bool verbose, int num_threads)
#endif
, _verbose (verbose)
, _num_threads (num_threads)
+ , _waker(Waker::Reason::ENCODING)
, _frames_encoded(0)
{
diff --git a/src/lib/ffmpeg_film_encoder.cc b/src/lib/ffmpeg_film_encoder.cc
index 97a3209e6..9987c406c 100644
--- a/src/lib/ffmpeg_film_encoder.cc
+++ b/src/lib/ffmpeg_film_encoder.cc
@@ -134,7 +134,7 @@ FFmpegFilmEncoder::go()
job->sub (_("Encoding"));
}
- Waker waker;
+ Waker waker(Waker::Reason::ENCODING);
list<FileEncoderSet> file_encoders;
diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc
index 441e91827..97f190d17 100644
--- a/src/lib/j2k_encoder.cc
+++ b/src/lib/j2k_encoder.cc
@@ -92,6 +92,7 @@ grk_plugin::IMessengerLogger* getMessengerLogger(void)
*/
J2KEncoder::J2KEncoder(shared_ptr<const Film> film, Writer& writer)
: VideoEncoder(film, writer)
+ , _waker(Waker::Reason::ENCODING)
#ifdef DCPOMATIC_GROK
, _give_up(false)
#endif
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 80ffb2913..7121c594b 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -923,7 +923,7 @@ Writer::set_digest_progress(Job* job, int id, int64_t done, int64_t size)
job->set_progress(float(total_done) / total_size);
- Waker waker;
+ Waker waker(Waker::Reason::ENCODING);
waker.nudge();
boost::this_thread::interruption_point();