#include "film_state.h"
#include "options.h"
#include "log.h"
+#include "job_manager.h"
+#include "ab_transcode_job.h"
+#include "transcode_job.h"
using namespace std;
using namespace boost;
set_progress (float (i) / _fs->length);
}
+ if (_bad) {
+ shared_ptr<Job> tc;
+
+ if (_fs->dcp_ab) {
+ tc.reset (new ABTranscodeJob (_fs, _opt, _log));
+ } else {
+ tc.reset (new TranscodeJob (_fs, _opt, _log));
+ }
+
+ JobManager::instance()->add_after (shared_from_this(), tc);
+ JobManager::instance()->add_after (tc, shared_ptr<Job> (new CheckHashesJob (_fs, _opt, _log)));
+ }
+
set_progress (1);
set_state (FINISHED_OK);
}
CheckHashesJob::status () const
{
stringstream s;
- s << Job::status () << "; " << _bad << " bad frames found";
+ s << Job::status ();
+ if (overall_progress() > 0) {
+ if (_bad == 0) {
+ s << "; no bad frames found";
+ } else if (_bad == 1) {
+ s << "; 1 bad frame found";
+ } else {
+ s << "; " << _bad << " bad frames found";
+ }
+ }
return s.str ();
}
#include <string>
#include <boost/thread/mutex.hpp>
+#include <boost/enable_shared_from_this.hpp>
#include <sigc++/sigc++.h>
class Log;
/** @class Job
* @brief A parent class to represent long-running tasks which are run in their own thread.
*/
-class Job
+class Job : public boost::enable_shared_from_this<Job>
{
public:
Job (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l);
JobManager::add (shared_ptr<Job> j)
{
boost::mutex::scoped_lock lm (_mutex);
-
_jobs.push_back (j);
}
+void
+JobManager::add_after (shared_ptr<Job> after, shared_ptr<Job> j)
+{
+ boost::mutex::scoped_lock lm (_mutex);
+ list<shared_ptr<Job> >::iterator i = find (_jobs.begin(), _jobs.end(), after);
+ assert (i != _jobs.end ());
+ ++i;
+ _jobs.insert (i, j);
+}
+
list<shared_ptr<Job> >
JobManager::get () const
{
boost::mutex::scoped_lock lm (_mutex);
-
return _jobs;
}
public:
void add (boost::shared_ptr<Job>);
+ void add_after (boost::shared_ptr<Job> after, boost::shared_ptr<Job> j);
std::list<boost::shared_ptr<Job> > get () const;
bool work_to_do () const;
}
if (_encoder->skipping () && !finished ()) {
- return "skipping frames already encoded";
+ return "skipping already-encoded frames";
}