Merge master.
[dcpomatic.git] / src / lib / job.cc
index 594c0da34f1b5cdc7a55177e61bee698b5ac21d5..7be17141769c78fb22b0e4a669f8c911bfbbaaa1 100644 (file)
@@ -37,7 +37,6 @@
 using std::string;
 using std::list;
 using std::cout;
-using std::stringstream;
 using boost::shared_ptr;
 
 Job::Job (shared_ptr<const Film> f)
@@ -232,8 +231,9 @@ Job::set_progress (float p, bool force)
        _progress = p;
        boost::this_thread::interruption_point ();
 
-       if (paused ()) {
-               dcpomatic_sleep (1);
+       boost::mutex::scoped_lock lm2 (_state_mutex);
+       while (_state == PAUSED) {
+               _pause_changed.wait (lm2);
        }
 
        if (ui_signaller) {
@@ -309,7 +309,7 @@ Job::status () const
                pc = 99;
        }
 
-       stringstream s;
+       SafeStringStream s;
        if (!finished ()) {
                s << pc << N_("%");
                if (p >= 0 && t > 10 && r > 0) {
@@ -328,29 +328,6 @@ Job::status () const
        return s.str ();
 }
 
-string
-Job::json_status () const
-{
-       boost::mutex::scoped_lock lm (_state_mutex);
-
-       switch (_state) {
-       case NEW:
-               return N_("new");
-       case RUNNING:
-               return N_("running");
-       case PAUSED:
-               return N_("paused");
-       case FINISHED_OK:
-               return N_("finished_ok");
-       case FINISHED_ERROR:
-               return N_("finished_error");
-       case FINISHED_CANCELLED:
-               return N_("finished_cancelled");
-       }
-
-       return "";
-}
-
 /** @return An estimate of the remaining time for this sub-job, in seconds */
 int
 Job::remaining_time () const
@@ -374,6 +351,7 @@ Job::pause ()
 {
        if (running ()) {
                set_state (PAUSED);
+               _pause_changed.notify_all ();
        }
 }
 
@@ -382,5 +360,6 @@ Job::resume ()
 {
        if (paused ()) {
                set_state (RUNNING);
+               _pause_changed.notify_all ();
        }
 }