FFmpegContent does not need audio_length().
[dcpomatic.git] / src / lib / job.cc
index 547b484a37affe06e01df7ecd940510f66c902f3..286b38456a8c0b82891e67d8b698cfaf4fedde64 100644 (file)
@@ -27,7 +27,6 @@
 #include "job.h"
 #include "util.h"
 #include "cross.h"
-#include "ui_signaller.h"
 #include "exceptions.h"
 #include "film.h"
 #include "log.h"
@@ -203,8 +202,8 @@ Job::set_state (State s)
                }
        }
 
-       if (finished && ui_signaller) {
-               ui_signaller->emit (boost::bind (boost::ref (Finished)));
+       if (finished) {
+               emit (boost::bind (boost::ref (Finished)));
        }       
 }
 
@@ -239,9 +238,10 @@ Job::set_progress (float p, bool force)
                _pause_changed.wait (lm2);
        }
 
-       if (ui_signaller) {
-               ui_signaller->emit (boost::bind (boost::ref (Progress)));
-       }
+       lm.unlock ();
+       lm2.unlock ();
+
+       emit (boost::bind (boost::ref (Progress)));
 }
 
 /** @return fractional progress of the current sub-job, if known */
@@ -301,9 +301,7 @@ Job::set_progress_unknown ()
        _progress.reset ();
        lm.unlock ();
 
-       if (ui_signaller) {
-               ui_signaller->emit (boost::bind (boost::ref (Progress)));
-       }
+       emit (boost::bind (boost::ref (Progress)));
 }
 
 /** @return Human-readable status of this job */
@@ -340,6 +338,29 @@ 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
@@ -358,6 +379,10 @@ Job::cancel ()
                return;
        }
 
+       if (paused ()) {
+               resume ();
+       }
+
        _thread->interrupt ();
        _thread->join ();
 }