summaryrefslogtreecommitdiff
path: root/src/lib/monitor_checker.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-11-13 00:04:23 +0000
committerCarl Hetherington <cth@carlh.net>2018-11-13 00:04:23 +0000
commit264583479e79b481251f1772b228f82cd77552d3 (patch)
tree868f3347c1784ecde6ee626f6799334f3ef235b6 /src/lib/monitor_checker.cc
parentf80010debf14112a632f42ddc7588995698b3d19 (diff)
swaroop: only allow playback if configured lock file is present.v2.13.72
Diffstat (limited to 'src/lib/monitor_checker.cc')
-rw-r--r--src/lib/monitor_checker.cc62
1 files changed, 4 insertions, 58 deletions
diff --git a/src/lib/monitor_checker.cc b/src/lib/monitor_checker.cc
index 19d8d8181..d15dee63f 100644
--- a/src/lib/monitor_checker.cc
+++ b/src/lib/monitor_checker.cc
@@ -24,75 +24,21 @@
#include "config.h"
#include "cross.h"
-using boost::bind;
-using boost::ref;
-
MonitorChecker* MonitorChecker::_instance = 0;
MonitorChecker::MonitorChecker ()
- : _thread (0)
- , _terminate (false)
- , _ok (true)
+ : Checker (60)
{
}
-void
-MonitorChecker::run ()
-{
- _thread = new boost::thread (boost::bind (&MonitorChecker::thread, this));
-}
-
-MonitorChecker::~MonitorChecker ()
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _terminate = true;
- }
-
- if (_thread) {
- /* Ideally this would be a DCPOMATIC_ASSERT(_thread->joinable()) but we
- can't throw exceptions from a destructor.
- */
- _thread->interrupt ();
- try {
- if (_thread->joinable ()) {
- _thread->join ();
- }
- } catch (boost::thread_interrupted& e) {
- /* No problem */
- }
- }
- delete _thread;
-}
-
-void
-MonitorChecker::thread ()
-{
- while (true) {
- boost::mutex::scoped_lock lm (_mutex);
- if (_terminate) {
- break;
- }
-
- bool const was_ok = _ok;
- _ok = Config::instance()->required_monitors().empty() || get_monitors() == Config::instance()->required_monitors();
- if (was_ok != _ok) {
- emit (bind(boost::ref(StateChanged)));
- }
-
- lm.unlock ();
- dcpomatic_sleep (60);
- }
-}
-
bool
-MonitorChecker::ok () const
+MonitorChecker::check () const
{
- boost::mutex::scoped_lock lm (_mutex);
- return _ok;
+ return Config::instance()->required_monitors().empty() || get_monitors() == Config::instance()->required_monitors();
}
+
MonitorChecker *
MonitorChecker::instance ()
{