diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-04 20:58:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-04 20:58:31 +0100 |
| commit | db0ad7242d39f0fbae04bb6983021c60d57fdcf5 (patch) | |
| tree | 62c52316ff64204b89ba21658dc76ad69009bfec /src/lib | |
| parent | 0c5590dd0e3f367064a6e4d52835a609adf11a06 (diff) | |
Make batch converter basically work.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/job.cc | 28 | ||||
| -rw-r--r-- | src/lib/job.h | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index 1c66d87d3..9a5812fa7 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -26,6 +26,7 @@ #include <libdcp/exceptions.h> #include "job.h" #include "util.h" +#include "cross.h" #include "i18n.h" @@ -155,6 +156,13 @@ Job::finished_cancelled () const return _state == FINISHED_CANCELLED; } +bool +Job::paused () const +{ + boost::mutex::scoped_lock lm (_state_mutex); + return _state == PAUSED; +} + /** Set the state of this job. * @param s New state. */ @@ -190,6 +198,10 @@ Job::set_progress (float p) _progress_unknown = false; _stack.back().normalised = p; boost::this_thread::interruption_point (); + + if (paused ()) { + dvdomatic_sleep (1); + } } /** @return fractional overall progress, or -1 if not known */ @@ -326,3 +338,19 @@ Job::cancel () _thread->interrupt (); _thread->join (); } + +void +Job::pause () +{ + if (running ()) { + set_state (PAUSED); + } +} + +void +Job::resume () +{ + if (paused ()) { + set_state (RUNNING); + } +} diff --git a/src/lib/job.h b/src/lib/job.h index fd036bce2..37fa56d20 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -47,6 +47,8 @@ public: virtual void run () = 0; void start (); + void pause (); + void resume (); void cancel (); bool is_new () const; @@ -55,6 +57,7 @@ public: bool finished_ok () const; bool finished_in_error () const; bool finished_cancelled () const; + bool paused () const; std::string error_summary () const; std::string error_details () const; @@ -79,6 +82,7 @@ protected: enum State { NEW, ///< the job hasn't been started yet RUNNING, ///< the job is running + PAUSED, ///< the job has been paused FINISHED_OK, ///< the job has finished successfully FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled |
