*/
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+
#include "monitor_checker.h"
#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 ()
{
return _instance;
}
+
+#endif